summaryrefslogtreecommitdiffstats
path: root/gfx/layers/apz/test/mochitest/helper_fission_setResolution.html
blob: 6bcf3fa2ce6d08c84e518b614d6d33bec17fc12b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <title>setResolutionAndScaleTo is properly delivered to OOP iframes</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <script src="/tests/SimpleTest/paint_listener.js"></script>
  <script src="helper_fission_utils.js"></script>
  <script src="apz_test_utils.js"></script>
  <script>

fission_subtest_init();

FissionTestHelper.startTestPromise
  .then(waitUntilApzStable)
  .then(loadOOPIFrame("testframe", "helper_fission_empty.html"))
  .then(waitUntilApzStable)
  .then(test)
  .then(FissionTestHelper.subtestDone, FissionTestHelper.subtestFailed);

async function test() {
  let iframeElement = document.getElementById("testframe");

  const scale = 2.0;

  SpecialPowers.getDOMWindowUtils(window).setResolutionAndScaleTo(scale);
  await promiseApzFlushedRepaints(window);
  await waitUntilApzStable();

  const originalWidth = originalHeight = 100;
  // eslint-disable-next-line no-unused-vars
  let { _x, _y, width, height } = await SpecialPowers.spawn(
    iframeElement,
    [originalWidth, originalHeight],
    // eslint-disable-next-line no-shadow
    (width, height) => {
      // nsIDOMWindowUtils.toScreenRect uses the iframe's transform which should
      // have been informed from APZ.
      return SpecialPowers.DOMWindowUtils.toScreenRect(0, 0, width, height);
    }
  );

  is(width, scale * originalWidth,
     "The resolution value should be properly delivered into OOP iframes");
  is(height, scale * originalHeight,
     "The resolution value should be properly delivered into OOP iframes");
}

  </script>
  <style>
    body, html {
        margin: 0;
    }
  </style>
</head>
<body>
<iframe id="testframe"></iframe>
</body>
</html>