Bug 1625249 - test hittest with SVG in parent over OOP iframe. r=kats
☠☠ backed out by 4631dfa1abbe ☠ ☠
authorYura Zenevich <yura.zenevich@gmail.com>
Wed, 15 Apr 2020 19:43:05 +0000
changeset 526546 5d9701c4fb3b4fe9ccc3f2a052af66aa883bf19b
parent 526545 8c02d6099aa347ea174816b0101aae9948707d90
child 526547 316c72999bc16821fe301434afbbeafb9be43207
push id37358
push useropoprus@mozilla.com
push dateWed, 29 Apr 2020 03:05:14 +0000
treeherdermozilla-central@6bb8423186c1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1625249
milestone77.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1625249 - test hittest with SVG in parent over OOP iframe. r=kats Differential Revision: https://phabricator.services.mozilla.com/D69664
gfx/layers/apz/test/mochitest/browser.ini
gfx/layers/apz/test/mochitest/browser_test_hittest_svg_over_iframe.js
--- a/gfx/layers/apz/test/mochitest/browser.ini
+++ b/gfx/layers/apz/test/mochitest/browser.ini
@@ -1,9 +1,13 @@
+[DEFAULT]
+support-files =
+  apz_test_native_event_utils.js
+
 [browser_test_group_fission.js]
 skip-if = (os == 'win' && bits == 32) # Some subtests fail intermittently on Win7.
 support-files =
-  apz_test_native_event_utils.js
   apz_test_utils.js
   FissionTestHelperParent.jsm
   FissionTestHelperChild.jsm
   helper_fission_*.*
   !/dom/animation/test/testcommon.js
+[browser_test_hittest_svg_over_iframe.js]
new file mode 100644
--- /dev/null
+++ b/gfx/layers/apz/test/mochitest/browser_test_hittest_svg_over_iframe.js
@@ -0,0 +1,108 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+Services.scriptloader.loadSubScript(
+  "chrome://mochitests/content/browser/gfx/layers/apz/test/mochitest/apz_test_native_event_utils.js",
+  this
+);
+
+const srcURL = new URL(`http://example.net/document-builder.sjs`);
+srcURL.searchParams.append(
+  "html",
+  `<html>
+    <head>
+      <meta charset="utf-8"/>
+      <title>OOP Document</title>
+    </head>
+    <body></body>
+  </html>`
+);
+const iframeHTML = `<iframe title="OOP IFrame" src="${srcURL.href}"/>`;
+const url = `data:text/html;charset=UTF-8,${encodeURIComponent(iframeHTML)}`;
+
+const SVG_NS = "http://www.w3.org/2000/svg";
+const STYLES_SHEET = `data:text/css;charset=utf-8,
+.test-svg {
+  position: absolute;
+  width: 100%;
+  height: 100%;
+  pointer-events: none;
+}
+
+.test-path {
+  opacity: 0.6;
+}`;
+
+add_task(async () => {
+  const tab = BrowserTestUtils.addTab(gBrowser, url);
+  gBrowser.selectedTab = tab;
+  const browser = tab.linkedBrowser;
+  await BrowserTestUtils.browserLoaded(browser);
+
+  const browserContainer = gBrowser.getBrowserContainer(browser);
+  const parent = browserContainer.querySelector(".browserStack");
+  const window = gBrowser.ownerGlobal;
+  const iframe = window.document.createElement("iframe");
+  iframe.classList.add("devtools-highlighter-renderer");
+  parent.querySelector("browser").after(iframe);
+  if (
+    iframe.contentWindow.readyState != "interactive" &&
+    iframe.contentWindow.readyState != "complete"
+  ) {
+    await new Promise(resolve => {
+      iframe.contentWindow.addEventListener("DOMContentLoaded", resolve, {
+        once: true,
+      });
+    });
+  }
+
+  iframe.contentWindow.windowUtils.loadSheetUsingURIString(
+    STYLES_SHEET,
+    iframe.contentWindow.windowUtils.AGENT_SHEET
+  );
+
+  const svg = iframe.contentWindow.document.createElementNS(SVG_NS, "svg");
+  svg.setAttribute("class", "test-svg");
+  const path = iframe.contentWindow.document.createElementNS(SVG_NS, "path");
+  path.setAttribute("class", "test-path");
+  path.setAttributeNS(null, "fill", "#6a5acd");
+  path.setAttributeNS(
+    null,
+    "d",
+    `M${0},${0} L${innerWidth},${0} L${innerWidth},${innerHeight} L${0},${innerHeight}`
+  );
+  svg.appendChild(path);
+  iframe.contentWindow.document.insertAnonymousContent(svg);
+
+  await SpecialPowers.spawn(browser, [], () => {
+    const frame = content.document.getElementsByTagName("iframe")[0];
+    return SpecialPowers.spawn(frame, [], () => {
+      const deferred = {};
+      content.iframeClicked = new Promise(resolve => {
+        deferred.resolve = resolve;
+      });
+      content.docShell.chromeEventHandler.addEventListener(
+        "click",
+        () => deferred.resolve(true),
+        {
+          capture: true,
+          once: true,
+        }
+      );
+    });
+  });
+
+  const iframeClicked = SpecialPowers.spawn(browser, [], () => {
+    const frame = content.document.getElementsByTagName("iframe")[0];
+    return SpecialPowers.spawn(frame, [], () => content.iframeClicked);
+  });
+
+  const { width, height } = await SpecialPowers.spawn(browser, [], () =>
+    content.document.getElementsByTagName("iframe")[0].getBoundingClientRect()
+  );
+  synthesizeNativeClick(browser, width / 2, height / 2);
+  ok(await iframeClicked, "Mouse event was fired in the OOP iframe.");
+  BrowserTestUtils.removeTab(tab);
+});