gecko-dev/toolkit/components/remotebrowserutils/tests/browser/browser_oopProcessSwap.js
Nika Layzell 6eb2084136 Bug 1544811 - Use web processes on a per-site basis for fission-enabled windows, r=mconley
This patch introduces a new type of content process, which has a dynamic name.
This type of content process is labeled as `webIsolated=${SITE_ORIGIN}` and is
used within fission-enabled windows.

To enable this, additional information about the fission status of the target
window must be passed into E10SUtils. This was done by updating every call site
manually to pass an extra boolean. A better solution perhaps should be used in
the future.

With this patch enabled, we now perform process switches, but only when
navigating to HTTP URIs. If we navigate to a non-HTTP URI in an iframe with
fission enabled, it will not behave correctly. This must be done in a
follow-up.

Differential Revision: https://phabricator.services.mozilla.com/D29570

--HG--
extra : moz-landing-system : lando
2019-05-03 21:31:57 +00:00

108 lines
3.8 KiB
JavaScript

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);
});
add_task(async function oopOriginProcessSwap() {
const COM_DUMMY = httpURL("dummy_page.html", "https://example.com/");
const ORG_POSTMSG = httpURL("file_postmsg_parent.html", "https://example.org/");
let win = await BrowserTestUtils.openNewBrowserWindow({fission: true});
await BrowserTestUtils.withNewTab({gBrowser: win.gBrowser, url: COM_DUMMY}, async browser => {
is(browser.browsingContext.getChildren().length, 0);
info("creating an in-process frame");
let frameId = await ContentTask.spawn(browser, {COM_DUMMY}, async ({COM_DUMMY}) => {
let iframe = content.document.createElement("iframe");
iframe.setAttribute("src", COM_DUMMY);
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, {ORG_POSTMSG}, async ({ORG_POSTMSG}) => {
let iframe = content.document.querySelector("iframe");
iframe.contentWindow.location = ORG_POSTMSG;
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, ORG_POSTMSG, "correct location");
});
await BrowserTestUtils.closeWindow(win);
});