Bug 1539163 - Part 3: tests for switch processes, r=qdot
authorNika Layzell <nika@thelayzells.com>
Wed, 17 Apr 2019 00:53:34 +0000
changeset 469836 3592e8434aa07e699e29a1abcb96c72d5f9eb9f0
parent 469835 578f5c0681dffc1162a51dc1d8b3a7daf86c30da
child 469837 144a2491cbd523c2d4d3bff136165c8a97d00f40
push id35883
push userbtara@mozilla.com
push dateWed, 17 Apr 2019 21:47:29 +0000
treeherdermozilla-central@02b89c29412b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersqdot
bugs1539163
milestone68.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 1539163 - Part 3: tests for switch processes, r=qdot Adds a basic test for this process switching functionality in subframes. This tests one of the few forms of remoteness which are supported with the Part 1 patch, which is when navigating an iframe in a file:// document to a webpage. Differential Revision: https://phabricator.services.mozilla.com/D26565
toolkit/components/remotebrowserutils/tests/browser/browser.ini
toolkit/components/remotebrowserutils/tests/browser/browser_oopProcessSwap.js
toolkit/components/remotebrowserutils/tests/browser/file_postmsg_parent.html
--- a/toolkit/components/remotebrowserutils/tests/browser/browser.ini
+++ b/toolkit/components/remotebrowserutils/tests/browser/browser.ini
@@ -1,13 +1,15 @@
 [DEFAULT]
 run-if = e10s
 support-files =
   dummy_page.html
   print_postdata.sjs
   307redirect.sjs
   head.js
   coop_header.sjs
+  file_postmsg_parent.html
 
 [browser_RemoteWebNavigation.js]
 [browser_httpResponseProcessSelection.js]
 [browser_httpCrossOriginOpenerPolicy.js]
 [browser_httpToFileHistory.js]
+[browser_oopProcessSwap.js]
new file mode 100644
--- /dev/null
+++ b/toolkit/components/remotebrowserutils/tests/browser/browser_oopProcessSwap.js
@@ -0,0 +1,53 @@
+add_task(async function oopProcessSwap() {
+  const FILE = fileURL("dummy_page.html");
+  const WEB = httpURL("file_postmsg_parent.html");
+
+  let win = await BrowserTestUtils.openNewBrowserWindow({fission: true});
+
+  await BrowserTestUtils.withNewTab({gBrowser: win.gBrowser, url: FILE}, async browser => {
+    is(browser.browsingContext.getChildren().length, 0);
+
+    info("creating an in-process frame");
+    let frameId = await ContentTask.spawn(browser, {FILE}, async ({FILE}) => {
+      let iframe = content.document.createElement("iframe");
+      iframe.setAttribute("src", FILE);
+      content.document.body.appendChild(iframe);
+
+      // The nested URI should be same-process
+      ok(iframe.browsingContext.docShell, "Should be in-process");
+
+      return iframe.browsingContext.id;
+    });
+
+    is(browser.browsingContext.getChildren().length, 1);
+
+    info("navigating to x-process frame");
+    let oopinfo = await ContentTask.spawn(browser, {WEB}, async ({WEB}) => {
+      let iframe = content.document.querySelector("iframe");
+
+      iframe.contentWindow.location = WEB;
+
+      let data = await new Promise(resolve => {
+        content.window.addEventListener("message", function(evt) {
+          info("oop iframe loaded");
+          is(evt.source, iframe.contentWindow);
+          resolve(evt.data);
+        }, {once: true});
+      });
+
+      is(iframe.browsingContext.docShell, null, "Should be out-of-process");
+      is(iframe.browsingContext.embedderElement, iframe, "correct embedder");
+
+      return {
+        location: data.location,
+        browsingContextId: iframe.browsingContext.id,
+      };
+    });
+
+    is(browser.browsingContext.getChildren().length, 1);
+    todo(frameId == oopinfo.browsingContextId, "BrowsingContext should not have changed");
+    is(oopinfo.location, WEB, "correct location");
+  });
+
+  await BrowserTestUtils.closeWindow(win);
+});
new file mode 100644
--- /dev/null
+++ b/toolkit/components/remotebrowserutils/tests/browser/file_postmsg_parent.html
@@ -0,0 +1,5 @@
+<!DOCTYPE html>
+<html>
+<body onload="parent.postMessage({location: window.location.href}, '*')">
+</body>
+</html>
\ No newline at end of file