summaryrefslogtreecommitdiffstats
path: root/gfx/layers/apz/test/mochitest/helper_fission_force_empty_hit_region.html
blob: 7baa552c3740c274d41809923e592a68b01f2ec9 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <title>Ensure the ForceEmptyHitRegion flag works properly</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("testframe1", "helper_fission_empty.html"))
  .then(loadOOPIFrame("testframe2", "helper_fission_empty.html"))
  .then(waitUntilApzStable)
  .then(test)
  .then(FissionTestHelper.subtestDone, FissionTestHelper.subtestFailed);


// The actual test

let code_for_oopif_to_run = function() {
  document.body.style.backgroundColor = 'green'; // To ensure opaqueness
  let utils = SpecialPowers.getDOMWindowUtils(window);
  dump("OOPIF got layersId: " + utils.getLayersId() +
       ", scrollId: " + utils.getViewId(document.scrollingElement) + "\n");
  return JSON.stringify({
      layersId: utils.getLayersId(),
      viewId: utils.getViewId(document.scrollingElement)
  });
};

let iframe_compositor_test_data = function() {
  let utils = SpecialPowers.getDOMWindowUtils(window);
  let result = JSON.stringify(utils.getCompositorAPZTestData());
  dump("OOPIF got compositor APZ data: " + result + "\n");
  return result;
};

async function test() {
  let iframe1 = document.getElementById("testframe1");
  let iframe2 = document.getElementById("testframe2");

  let iframeResponse = await FissionTestHelper.sendToOopif(iframe1, `(${code_for_oopif_to_run})()`);
  dump("OOPIF response: " + iframeResponse + "\n");
  ok(iframeResponse, "code_for_oopif_to_run successfully installed in frame1");

  iframeResponse = await FissionTestHelper.sendToOopif(iframe2, `(${code_for_oopif_to_run})()`);
  dump("OOPIF response: " + iframeResponse + "\n");
  ok(iframeResponse, "code_for_oopif_to_run successfully installed in frame2");
  let iframe2Expected = JSON.parse(iframeResponse);

  let utils = SpecialPowers.getDOMWindowUtils(window);

  // Hit-testing the iframe with pointer-events:none should end up hitting the
  // document containing the iframe instead (i.e. this document).
  checkHitResult(await fissionHitTest(centerOf(iframe1), iframe1),
                 APZHitResultFlags.VISIBLE,
                 utils.getViewId(document.scrollingElement),
                 utils.getLayersId(),
                 "center of pointer-events:none iframe should hit parent doc");

  // Hit-testing the iframe that doesn't have pointer-events:none should end up
  // hitting that iframe.
  checkHitResult(await fissionHitTest(centerOf(iframe2), iframe2),
                 APZHitResultFlags.VISIBLE,
                 iframe2Expected.viewId,
                 iframe2Expected.layersId,
                 "center of regular iframe should hit iframe doc");
}

  </script>
</head>
<body>
<iframe id="testframe1" style="pointer-events:none"></iframe>
<iframe id="testframe2"></iframe>
</body>
</html>