summaryrefslogtreecommitdiffstats
path: root/gfx/layers/apz/test/mochitest/helper_fission_large_subframe.html
blob: 3d5595f48ef8fd9d1255f9b052c60c3cc170c1c6 (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
60
61
62
63
64
65
66
67
<!DOCTYPE HTML>
<html id="rcd_docelement">
<head>
  <meta charset="utf-8">
  <title>Test that large OOPIF does not get a too-large displayport</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 src="apz_test_native_event_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);

// Code that will run inside the iframe.
let get_iframe_displayport = function() {
  // Give the page a scroll range. This will make the unclamped displayport
  // even taller.
  document.body.style.height = "200vh";
  // Do a round-trip to APZ to make sure the scroll range is reflected
  // in the displayport it sets.
  promiseApzFlushedRepaints().then(() => {
    // Query the composed displayport and report it to the embedder.
    let result = getLastContentDisplayportFor("fission_empty_docelement");
    FissionTestHelper.fireEventInEmbedder("OOPIF:Displayport", result);
  });
  return true;
};

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

  // Give the page a scroll range and make sure APZ sets non-empty displayport margins.
  document.body.style.height = "500vh";
  await promiseApzFlushedRepaints();

  // Query the iframe's displayport.
  let displayportPromise = promiseOneEvent(window, "OOPIF:Displayport", null);
  ok(await FissionTestHelper.sendToOopif(iframeElement, `(${get_iframe_displayport})()`), "Gotten iframe displayport");
  let iframeDp = (await displayportPromise).data;
  dump("iframe displayport is " + JSON.stringify(iframeDp) + "\n");

  // Query the page's displayport.
  let dp = getLastContentDisplayportFor("rcd_docelement");
  dump("page displayport is " + JSON.stringify(dp) + "\n");

  // Check that the iframe's displayport is no more than twice as tall as
  // the page's displayport. The reason it can be up to twice as tall is
  // described in bug 1690697; we may be able to assert a tighter bound
  // after making improvements in that bug.
  ok(iframeDp.height <= (dp.height * 2), "iframe displayport should be no more than twice as tall as page displayport");
}

  </script>
</head>
<body>
<!-- Make the iframe's viewport very tall -->
<iframe style="margin-top: 200px" id="testframe" height="10000px"></iframe>
</body>
</html>