Source code
Revision control
Copy as Markdown
Other Tools
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width,initial-scale=1">
  <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>
    async function getLayersIdAndViewId(iframe) {
      let [layersId, viewId] = await SpecialPowers.spawn(iframe, [], () => {
        content.document.body.style.backgroundColor = 'green'; // To ensure opaqueness
        let utils = SpecialPowers.getDOMWindowUtils(content.window);
        return [utils.getLayersId(), utils.getViewId(content.document.scrollingElement)];
      });
      dump("OOPIF got layersId: " + layersId + ", scrollId: " + viewId + "\n");
      return [layersId, viewId];
    }
    async function getRemoteType(iframe) {
      return await SpecialPowers.spawn(iframe, [], async () => {
        return await SpecialPowers.spawnChrome([], () => {
          return windowGlobalParent.domProcess.remoteType;
        });
      });
    }
    async function test() {
      // Set up iframes
      let iframe1 = document.getElementById("testframe1");
      let iframe2 = document.getElementById("testframe2");
      await setupCrossOriginIFrame(iframe1, "helper_fission_plain.html");
      await setupCrossOriginIFrame(iframe2, "helper_fission_plain.html");
      let iframe1RemoteType = await getRemoteType(iframe1);
      let iframe2RemoteType = await getRemoteType(iframe2);
      if (iframe1RemoteType === "web" || iframe2RemoteType === "web") {
        is(SpecialPowers.effectiveIsolationStrategy(), SpecialPowers.ISOLATION_STRATEGY.IsolateHighValue);
        ok(true, "Skipping this test since the document on example.com got loaded in the same content process");
        return;
      }
      await getLayersIdAndViewId(iframe1);
      let [iframe2LayersId, iframe2ViewId] = await getLayersIdAndViewId(iframe2);
      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 hitTestOOPIF(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 hitTestOOPIF(centerOf(iframe2), iframe2),
        APZHitResultFlags.VISIBLE,
        iframe2ViewId,
        iframe2LayersId,
        "center of regular iframe should hit iframe doc");
    }
    if (!SpecialPowers.Services.appinfo.fissionAutostart) {
      ok(true, "This test doesn't need to run with disabling Fission");
      subtestDone();
    } else {
      waitUntilApzStable()
        .then(test)
        .then(subtestDone, subtestFailed);
    }
  </script>
</head>
<body>
  <iframe id="testframe1" style="pointer-events:none"></iframe>
  <iframe id="testframe2"></iframe>
</body>
</html>