mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-01 13:57:32 +00:00
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
This commit is contained in:
parent
f8e974fdd8
commit
6eb2084136
@ -408,6 +408,10 @@ var gMultiProcessBrowser =
|
||||
window.docShell
|
||||
.QueryInterface(Ci.nsILoadContext)
|
||||
.useRemoteTabs;
|
||||
var gFissionBrowser =
|
||||
window.docShell
|
||||
.QueryInterface(Ci.nsILoadContext)
|
||||
.useRemoteSubframes;
|
||||
|
||||
var gBrowserAllowScriptsToCloseInitialTabs = false;
|
||||
|
||||
@ -1204,7 +1208,7 @@ function _loadURI(browser, uri, params = {}) {
|
||||
mustChangeProcess,
|
||||
newFrameloader,
|
||||
} = E10SUtils.shouldLoadURIInBrowser(browser, uri, gMultiProcessBrowser,
|
||||
flags);
|
||||
gFissionBrowser, flags);
|
||||
if (uriObject && handleUriInChrome(browser, uriObject)) {
|
||||
// If we've handled the URI in Chrome then just return here.
|
||||
return;
|
||||
@ -1316,7 +1320,8 @@ function RedirectLoad({ target: browser, data }) {
|
||||
// If we're in a Large-Allocation process, we prefer switching back into a
|
||||
// normal content process, as that way we can clean up the L-A process.
|
||||
data.loadOptions.remoteType =
|
||||
E10SUtils.getRemoteTypeForURI(data.loadOptions.uri, gMultiProcessBrowser);
|
||||
E10SUtils.getRemoteTypeForURI(data.loadOptions.uri, gMultiProcessBrowser,
|
||||
gFissionBrowser);
|
||||
}
|
||||
|
||||
// We should only start the redirection if the browser window has finished
|
||||
@ -2719,7 +2724,8 @@ async function BrowserViewSourceOfDocument(aArgsOrDocument) {
|
||||
// that of the original URL, so disable remoteness if necessary for this
|
||||
// URL.
|
||||
preferredRemoteType =
|
||||
E10SUtils.getRemoteTypeForURI(args.URL, gMultiProcessBrowser);
|
||||
E10SUtils.getRemoteTypeForURI(args.URL, gMultiProcessBrowser,
|
||||
gFissionBrowser);
|
||||
}
|
||||
|
||||
// In the case of popups, we need to find a non-popup browser window.
|
||||
|
@ -44,7 +44,8 @@ var WebBrowserChrome = {
|
||||
},
|
||||
|
||||
shouldLoadURIInThisProcess(aURI) {
|
||||
return E10SUtils.shouldLoadURIInThisProcess(aURI);
|
||||
let remoteSubframes = docShell.QueryInterface(Ci.nsILoadContext).useRemoteSubframes;
|
||||
return E10SUtils.shouldLoadURIInThisProcess(aURI, remoteSubframes);
|
||||
},
|
||||
|
||||
// Try to reload the currently active or currently loading page in a new process.
|
||||
|
@ -310,6 +310,7 @@ window._gBrowser = {
|
||||
remoteType = E10SUtils.getRemoteTypeForURI(
|
||||
uriToLoad,
|
||||
gMultiProcessBrowser,
|
||||
gFissionBrowser,
|
||||
E10SUtils.DEFAULT_REMOTE_TYPE
|
||||
);
|
||||
} else {
|
||||
@ -1811,6 +1812,7 @@ window._gBrowser = {
|
||||
aOptions.remoteType =
|
||||
E10SUtils.getRemoteTypeForURI(aURL,
|
||||
gMultiProcessBrowser,
|
||||
gFissionBrowser,
|
||||
oldRemoteType,
|
||||
aBrowser.currentURI);
|
||||
|
||||
@ -2025,6 +2027,7 @@ window._gBrowser = {
|
||||
}
|
||||
return E10SUtils.getRemoteTypeForURI(url,
|
||||
gMultiProcessBrowser,
|
||||
gFissionBrowser,
|
||||
undefined,
|
||||
uri);
|
||||
};
|
||||
@ -2457,13 +2460,14 @@ window._gBrowser = {
|
||||
referrerInfo.originalReferrer) {
|
||||
preferredRemoteType =
|
||||
E10SUtils.getRemoteTypeForURI(referrerInfo.originalReferrer.spec,
|
||||
gMultiProcessBrowser);
|
||||
gMultiProcessBrowser, gFissionBrowser);
|
||||
}
|
||||
|
||||
let remoteType =
|
||||
forceNotRemote ? E10SUtils.NOT_REMOTE :
|
||||
E10SUtils.getRemoteTypeForURI(aURI, gMultiProcessBrowser,
|
||||
preferredRemoteType);
|
||||
gFissionBrowser,
|
||||
preferredRemoteType);
|
||||
|
||||
// If we open a new tab with the newtab URL in the default
|
||||
// userContext, check if there is a preloaded browser ready.
|
||||
|
@ -96,40 +96,40 @@ registerCleanupFunction(() => {
|
||||
});
|
||||
|
||||
function test_url(url, chromeResult, webContentResult, privilegedContentResult, extensionProcessResult) {
|
||||
is(E10SUtils.canLoadURIInRemoteType(url, CHROME_PROCESS),
|
||||
is(E10SUtils.canLoadURIInRemoteType(url, /* fission */ false, CHROME_PROCESS),
|
||||
chromeResult, "Check URL in chrome process.");
|
||||
is(E10SUtils.canLoadURIInRemoteType(url, WEB_CONTENT_PROCESS),
|
||||
is(E10SUtils.canLoadURIInRemoteType(url, /* fission */ false, WEB_CONTENT_PROCESS),
|
||||
webContentResult, "Check URL in web content process.");
|
||||
is(E10SUtils.canLoadURIInRemoteType(url, PRIVILEGED_CONTENT_PROCESS),
|
||||
is(E10SUtils.canLoadURIInRemoteType(url, /* fission */ false, PRIVILEGED_CONTENT_PROCESS),
|
||||
privilegedContentResult, "Check URL in privileged content process.");
|
||||
is(E10SUtils.canLoadURIInRemoteType(url, EXTENSION_PROCESS),
|
||||
is(E10SUtils.canLoadURIInRemoteType(url, /* fission */ false, EXTENSION_PROCESS),
|
||||
extensionProcessResult, "Check URL in extension process.");
|
||||
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "#foo", CHROME_PROCESS),
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "#foo", /* fission */ false, CHROME_PROCESS),
|
||||
chromeResult, "Check URL with ref in chrome process.");
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "#foo", WEB_CONTENT_PROCESS),
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "#foo", /* fission */ false, WEB_CONTENT_PROCESS),
|
||||
webContentResult, "Check URL with ref in web content process.");
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "#foo", PRIVILEGED_CONTENT_PROCESS),
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "#foo", /* fission */ false, PRIVILEGED_CONTENT_PROCESS),
|
||||
privilegedContentResult, "Check URL with ref in privileged content process.");
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "#foo", EXTENSION_PROCESS),
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "#foo", /* fission */ false, EXTENSION_PROCESS),
|
||||
extensionProcessResult, "Check URL with ref in extension process.");
|
||||
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "?foo", CHROME_PROCESS),
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "?foo", /* fission */ false, CHROME_PROCESS),
|
||||
chromeResult, "Check URL with query in chrome process.");
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "?foo", WEB_CONTENT_PROCESS),
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "?foo", /* fission */ false, WEB_CONTENT_PROCESS),
|
||||
webContentResult, "Check URL with query in web content process.");
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "?foo", PRIVILEGED_CONTENT_PROCESS),
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "?foo", /* fission */ false, PRIVILEGED_CONTENT_PROCESS),
|
||||
privilegedContentResult, "Check URL with query in privileged content process.");
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "?foo", EXTENSION_PROCESS),
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "?foo", /* fission */ false, EXTENSION_PROCESS),
|
||||
extensionProcessResult, "Check URL with query in extension process.");
|
||||
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "?foo#bar", CHROME_PROCESS),
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "?foo#bar", /* fission */ false, CHROME_PROCESS),
|
||||
chromeResult, "Check URL with query and ref in chrome process.");
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "?foo#bar", WEB_CONTENT_PROCESS),
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "?foo#bar", /* fission */ false, WEB_CONTENT_PROCESS),
|
||||
webContentResult, "Check URL with query and ref in web content process.");
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "?foo#bar", PRIVILEGED_CONTENT_PROCESS),
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "?foo#bar", /* fission */ false, PRIVILEGED_CONTENT_PROCESS),
|
||||
privilegedContentResult, "Check URL with query and ref in privileged content process.");
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "?foo#bar", EXTENSION_PROCESS),
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "?foo#bar", /* fission */ false, EXTENSION_PROCESS),
|
||||
extensionProcessResult, "Check URL with query and ref in extension process.");
|
||||
}
|
||||
|
||||
|
@ -49,24 +49,24 @@ registerCleanupFunction(() => {
|
||||
});
|
||||
|
||||
function test_url(url, chromeResult, contentResult) {
|
||||
is(E10SUtils.canLoadURIInRemoteType(url, CHROME_PROCESS),
|
||||
is(E10SUtils.canLoadURIInRemoteType(url, /* fission */ false, CHROME_PROCESS),
|
||||
chromeResult, "Check URL in chrome process.");
|
||||
is(E10SUtils.canLoadURIInRemoteType(url, WEB_CONTENT_PROCESS),
|
||||
is(E10SUtils.canLoadURIInRemoteType(url, /* fission */ false, WEB_CONTENT_PROCESS),
|
||||
contentResult, "Check URL in web content process.");
|
||||
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "#foo", CHROME_PROCESS),
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "#foo", /* fission */ false, CHROME_PROCESS),
|
||||
chromeResult, "Check URL with ref in chrome process.");
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "#foo", WEB_CONTENT_PROCESS),
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "#foo", /* fission */ false, WEB_CONTENT_PROCESS),
|
||||
contentResult, "Check URL with ref in web content process.");
|
||||
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "?foo", CHROME_PROCESS),
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "?foo", /* fission */ false, CHROME_PROCESS),
|
||||
chromeResult, "Check URL with query in chrome process.");
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "?foo", WEB_CONTENT_PROCESS),
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "?foo", /* fission */ false, WEB_CONTENT_PROCESS),
|
||||
contentResult, "Check URL with query in web content process.");
|
||||
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "?foo#bar", CHROME_PROCESS),
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "?foo#bar", /* fission */ false, CHROME_PROCESS),
|
||||
chromeResult, "Check URL with query and ref in chrome process.");
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "?foo#bar", WEB_CONTENT_PROCESS),
|
||||
is(E10SUtils.canLoadURIInRemoteType(url + "?foo#bar", /* fission */ false, WEB_CONTENT_PROCESS),
|
||||
contentResult, "Check URL with query and ref in web content process.");
|
||||
}
|
||||
|
||||
|
@ -4,8 +4,8 @@ const WEB_CONTENT_PROCESS = E10SUtils.WEB_REMOTE_TYPE;
|
||||
add_task(async function() {
|
||||
let url = "javascript:dosomething()";
|
||||
|
||||
ok(E10SUtils.canLoadURIInRemoteType(url, CHROME_PROCESS),
|
||||
ok(E10SUtils.canLoadURIInRemoteType(url, /* fission */ false, CHROME_PROCESS),
|
||||
"Check URL in chrome process.");
|
||||
ok(E10SUtils.canLoadURIInRemoteType(url, WEB_CONTENT_PROCESS),
|
||||
ok(E10SUtils.canLoadURIInRemoteType(url, /* fission */ false, WEB_CONTENT_PROCESS),
|
||||
"Check URL in web content process.");
|
||||
});
|
||||
|
@ -51,7 +51,9 @@ function getBrowser(panel) {
|
||||
if (panel.extension.remote) {
|
||||
browser.setAttribute("remote", "true");
|
||||
browser.setAttribute("remoteType",
|
||||
E10SUtils.getRemoteTypeForURI(panel.uri, true,
|
||||
E10SUtils.getRemoteTypeForURI(panel.uri,
|
||||
/* remote */ true,
|
||||
/* fission */ false,
|
||||
E10SUtils.EXTENSION_REMOTE_TYPE));
|
||||
readyPromise = promiseEvent(browser, "XULFrameLoaderCreated");
|
||||
|
||||
|
@ -2349,20 +2349,6 @@ var SessionStoreInternal = {
|
||||
browsingContext = aChannel.loadInfo.browsingContext;
|
||||
} else {
|
||||
browsingContext = aChannel.loadInfo.frameBrowsingContext;
|
||||
|
||||
let top = browsingContext.top;
|
||||
if (!top.embedderElement) {
|
||||
debug(`[process-switch]: no embedder for top - ignoring`);
|
||||
return;
|
||||
}
|
||||
|
||||
let docShell = top.embedderElement.ownerGlobal.docShell;
|
||||
let loadContext = docShell.QueryInterface(Ci.nsILoadContext);
|
||||
|
||||
if (!loadContext.useRemoteSubframes) {
|
||||
debug(`[process-switch]: remote subframes disabled - ignoring`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!browsingContext) {
|
||||
@ -2370,6 +2356,21 @@ var SessionStoreInternal = {
|
||||
return;
|
||||
}
|
||||
|
||||
// Determine if remote subframes should be used for this load.
|
||||
let topBC = browsingContext.top;
|
||||
if (!topBC.embedderElement) {
|
||||
debug(`[process-switch]: no embedder for top - ignoring`);
|
||||
return;
|
||||
}
|
||||
|
||||
let topDocShell = topBC.embedderElement.ownerGlobal.docShell;
|
||||
let useRemoteSubframes = topDocShell.QueryInterface(Ci.nsILoadContext)
|
||||
.useRemoteSubframes;
|
||||
if (!useRemoteSubframes && cp != Ci.nsIContentPolicy.TYPE_DOCUMENT) {
|
||||
debug(`[process-switch]: remote subframes disabled - ignoring`);
|
||||
return;
|
||||
}
|
||||
|
||||
// Get principal for a document already loaded in the BrowsingContext.
|
||||
let currentPrincipal = null;
|
||||
if (browsingContext.currentWindowGlobal) {
|
||||
@ -2408,6 +2409,7 @@ var SessionStoreInternal = {
|
||||
Services.scriptSecurityManager.getChannelResultPrincipal(aChannel);
|
||||
let remoteType = E10SUtils.getRemoteTypeForPrincipal(resultPrincipal,
|
||||
true,
|
||||
useRemoteSubframes,
|
||||
currentRemoteType,
|
||||
currentPrincipal);
|
||||
if (currentRemoteType == remoteType &&
|
||||
|
@ -44,9 +44,17 @@ let NewTabPagePreloading = {
|
||||
* Create a browser in the right process type.
|
||||
*/
|
||||
_createBrowser(win) {
|
||||
const {gBrowser, gMultiProcessBrowser, BROWSER_NEW_TAB_URL} = win;
|
||||
const {
|
||||
gBrowser,
|
||||
gMultiProcessBrowser,
|
||||
gFissionBrowser,
|
||||
BROWSER_NEW_TAB_URL,
|
||||
} = win;
|
||||
|
||||
let remoteType =
|
||||
E10SUtils.getRemoteTypeForURI(BROWSER_NEW_TAB_URL, gMultiProcessBrowser);
|
||||
E10SUtils.getRemoteTypeForURI(BROWSER_NEW_TAB_URL,
|
||||
gMultiProcessBrowser,
|
||||
gFissionBrowser);
|
||||
let browser = gBrowser.createBrowser({ isPreloadBrowser: true, remoteType });
|
||||
gBrowser.preloadedBrowser = browser;
|
||||
|
||||
|
@ -53,11 +53,11 @@ function run_test() {
|
||||
for (let preferredRemoteType of TEST_PREFERRED_REMOTE_TYPES) {
|
||||
let plainUri = Services.io.newURI(testCase.plainURL);
|
||||
let plainRemoteType =
|
||||
E10SUtils.getRemoteTypeForURIObject(plainUri, true, preferredRemoteType);
|
||||
E10SUtils.getRemoteTypeForURIObject(plainUri, true, false, preferredRemoteType);
|
||||
|
||||
let nestedUri = Services.io.newURI(testCase.nestedURL);
|
||||
let nestedRemoteType =
|
||||
E10SUtils.getRemoteTypeForURIObject(nestedUri, true, preferredRemoteType);
|
||||
E10SUtils.getRemoteTypeForURIObject(nestedUri, true, false, preferredRemoteType);
|
||||
|
||||
let nestedStr = nestedUri.scheme + ":";
|
||||
do {
|
||||
|
@ -29,7 +29,8 @@ add_task(async function() {
|
||||
// Open tab with correct remote type so we don't switch processes when we load
|
||||
// the file:// URI, otherwise we won't get the same web console.
|
||||
const remoteType = E10SUtils.getRemoteTypeForURI(uri.spec,
|
||||
gMultiProcessBrowser);
|
||||
gMultiProcessBrowser,
|
||||
gFissionBrowser);
|
||||
const { browser } = await loadTab("about:blank", remoteType);
|
||||
|
||||
hud = await openConsole();
|
||||
|
@ -91,7 +91,8 @@ class GeckoViewNavigationChild extends GeckoViewChildModule {
|
||||
// nsIWebBrowserChrome
|
||||
shouldLoadURIInThisProcess(aURI) {
|
||||
debug `shouldLoadURIInThisProcess ${aURI.displaySpec}`;
|
||||
return E10SUtils.shouldLoadURIInThisProcess(aURI);
|
||||
let remoteSubframes = docShell.QueryInterface(Ci.nsILoadContext).useRemoteSubframes;
|
||||
return E10SUtils.shouldLoadURIInThisProcess(aURI, remoteSubframes);
|
||||
}
|
||||
|
||||
// nsIWebBrowserChrome
|
||||
|
@ -113,6 +113,7 @@ var ModuleManager = {
|
||||
this.browser.remoteType || E10SUtils.NOT_REMOTE;
|
||||
const remoteType = E10SUtils.getRemoteTypeForURI(
|
||||
aURI, this.settings.useMultiprocess,
|
||||
/* useRemoteSubframes */ false,
|
||||
currentType, this.browser.currentURI);
|
||||
|
||||
debug `updateRemoteType: uri=${aURI} currentType=${currentType}
|
||||
|
@ -600,7 +600,7 @@ var BrowserTestUtils = {
|
||||
let browser = win.gBrowser.selectedBrowser;
|
||||
|
||||
if (win.gMultiProcessBrowser &&
|
||||
!E10SUtils.canLoadURIInRemoteType(url, browser.remoteType,
|
||||
!E10SUtils.canLoadURIInRemoteType(url, win.gFissionBrowser, browser.remoteType,
|
||||
browser.remoteType /* aPreferredRemoteType */)) {
|
||||
await this.waitForEvent(browser, "XULFrameLoaderCreated");
|
||||
}
|
||||
@ -647,7 +647,9 @@ var BrowserTestUtils = {
|
||||
// If the new URI can't load in the browser's current process then we
|
||||
// should wait for the new frameLoader to be created. This will happen
|
||||
// asynchronously when the browser's remoteness changes.
|
||||
if (!E10SUtils.canLoadURIInRemoteType(uri, browser.remoteType)) {
|
||||
if (!E10SUtils.canLoadURIInRemoteType(uri,
|
||||
browser.ownerGlobal.gFissionBrowser,
|
||||
browser.remoteType)) {
|
||||
await this.waitForEvent(browser, "XULFrameLoaderCreated");
|
||||
}
|
||||
},
|
||||
|
@ -207,7 +207,7 @@ function plInit() {
|
||||
// instance which adds the load listener and injects tpRecordTime), all the
|
||||
// pages should be able to load in the same mode as the initial page - due
|
||||
// to this reinitialization on the switch.
|
||||
let remoteType = E10SUtils.getRemoteTypeForURI(pageUrls[0], true);
|
||||
let remoteType = E10SUtils.getRemoteTypeForURI(pageUrls[0], /* remote */ true, /* fission */ false);
|
||||
let tabbrowser = browserWindow.gBrowser;
|
||||
if (remoteType) {
|
||||
tabbrowser.updateBrowserRemoteness(tabbrowser.initialBrowser, { remoteType });
|
||||
|
@ -325,7 +325,8 @@ var WebBrowserChrome = {
|
||||
},
|
||||
|
||||
shouldLoadURIInThisProcess(URI) {
|
||||
return E10SUtils.shouldLoadURIInThisProcess(URI);
|
||||
let remoteSubframes = docShell.QueryInterface(Ci.nsILoadContext).useRemoteSubframes;
|
||||
return E10SUtils.shouldLoadURIInThisProcess(URI, remoteSubframes);
|
||||
},
|
||||
|
||||
reloadInFreshProcess(docShell, URI, referrer, triggeringPrincipal, loadFlags) {
|
||||
|
@ -51,3 +51,58 @@ add_task(async function oopProcessSwap() {
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
|
@ -52,7 +52,7 @@ const PRIVILEGED_REMOTE_TYPE = "privileged";
|
||||
const LARGE_ALLOCATION_REMOTE_TYPE = "webLargeAllocation";
|
||||
const DEFAULT_REMOTE_TYPE = WEB_REMOTE_TYPE;
|
||||
|
||||
function validatedWebRemoteType(aPreferredRemoteType, aTargetUri, aCurrentUri) {
|
||||
function validatedWebRemoteType(aPreferredRemoteType, aTargetUri, aCurrentUri, aRemoteSubframes) {
|
||||
// If the domain is whitelisted to allow it to use file:// URIs, then we have
|
||||
// to run it in a file content process, in case it uses file:// sub-resources.
|
||||
const sm = Services.scriptSecurityManager;
|
||||
@ -60,6 +60,13 @@ function validatedWebRemoteType(aPreferredRemoteType, aTargetUri, aCurrentUri) {
|
||||
return FILE_REMOTE_TYPE;
|
||||
}
|
||||
|
||||
// If we're within a fission window, extract site information from the URI in
|
||||
// question, and use it to generate an isolated origin.
|
||||
if (aRemoteSubframes) {
|
||||
let targetPrincipal = sm.createCodebasePrincipal(aTargetUri, {});
|
||||
return "webIsolated=" + targetPrincipal.siteOrigin;
|
||||
}
|
||||
|
||||
if (!aPreferredRemoteType) {
|
||||
return WEB_REMOTE_TYPE;
|
||||
}
|
||||
@ -146,7 +153,8 @@ var E10SUtils = {
|
||||
return null;
|
||||
},
|
||||
|
||||
canLoadURIInRemoteType(aURL, aRemoteType = DEFAULT_REMOTE_TYPE,
|
||||
canLoadURIInRemoteType(aURL, aRemoteSubframes,
|
||||
aRemoteType = DEFAULT_REMOTE_TYPE,
|
||||
aPreferredRemoteType = undefined) {
|
||||
// We need a strict equality here because the value of `NOT_REMOTE` is
|
||||
// `null`, and there is a possibility that `undefined` is passed as an
|
||||
@ -157,10 +165,10 @@ var E10SUtils = {
|
||||
: DEFAULT_REMOTE_TYPE;
|
||||
}
|
||||
|
||||
return aRemoteType == this.getRemoteTypeForURI(aURL, true, aPreferredRemoteType);
|
||||
return aRemoteType == this.getRemoteTypeForURI(aURL, true, aRemoteSubframes, aPreferredRemoteType);
|
||||
},
|
||||
|
||||
getRemoteTypeForURI(aURL, aMultiProcess,
|
||||
getRemoteTypeForURI(aURL, aMultiProcess, aRemoteSubframes,
|
||||
aPreferredRemoteType = DEFAULT_REMOTE_TYPE,
|
||||
aCurrentUri) {
|
||||
if (!aMultiProcess) {
|
||||
@ -183,11 +191,11 @@ var E10SUtils = {
|
||||
return DEFAULT_REMOTE_TYPE;
|
||||
}
|
||||
|
||||
return this.getRemoteTypeForURIObject(uri, aMultiProcess,
|
||||
return this.getRemoteTypeForURIObject(uri, aMultiProcess, aRemoteSubframes,
|
||||
aPreferredRemoteType, aCurrentUri);
|
||||
},
|
||||
|
||||
getRemoteTypeForURIObject(aURI, aMultiProcess,
|
||||
getRemoteTypeForURIObject(aURI, aMultiProcess, aRemoteSubframes,
|
||||
aPreferredRemoteType = DEFAULT_REMOTE_TYPE,
|
||||
aCurrentUri) {
|
||||
if (!aMultiProcess) {
|
||||
@ -282,15 +290,16 @@ var E10SUtils = {
|
||||
if (aURI instanceof Ci.nsINestedURI) {
|
||||
let innerURI = aURI.QueryInterface(Ci.nsINestedURI).innerURI;
|
||||
return this.getRemoteTypeForURIObject(innerURI, aMultiProcess,
|
||||
aRemoteSubframes,
|
||||
aPreferredRemoteType,
|
||||
aCurrentUri);
|
||||
}
|
||||
|
||||
return validatedWebRemoteType(aPreferredRemoteType, aURI, aCurrentUri);
|
||||
return validatedWebRemoteType(aPreferredRemoteType, aURI, aCurrentUri, aRemoteSubframes);
|
||||
}
|
||||
},
|
||||
|
||||
getRemoteTypeForPrincipal(aPrincipal, aMultiProcess,
|
||||
getRemoteTypeForPrincipal(aPrincipal, aMultiProcess, aRemoteSubframes,
|
||||
aPreferredRemoteType = DEFAULT_REMOTE_TYPE,
|
||||
aCurrentPrincipal) {
|
||||
if (!aMultiProcess) {
|
||||
@ -316,6 +325,7 @@ var E10SUtils = {
|
||||
? aCurrentPrincipal.URI : null;
|
||||
return E10SUtils.getRemoteTypeForURIObject(aPrincipal.URI,
|
||||
aMultiProcess,
|
||||
aRemoteSubframes,
|
||||
aPreferredRemoteType,
|
||||
currentURI);
|
||||
},
|
||||
@ -397,7 +407,7 @@ var E10SUtils = {
|
||||
return fallbackPrincipalCallback();
|
||||
},
|
||||
|
||||
shouldLoadURIInBrowser(browser, uri, multiProcess = true,
|
||||
shouldLoadURIInBrowser(browser, uri, multiProcess = true, remoteSubframes = false,
|
||||
flags = Ci.nsIWebNavigation.LOAD_FLAGS_NONE) {
|
||||
let currentRemoteType = browser.remoteType;
|
||||
let requiredRemoteType;
|
||||
@ -414,7 +424,7 @@ var E10SUtils = {
|
||||
// Note that I had thought that we could set uri = uriObject.spec here, to
|
||||
// save on fixup later on, but that changes behavior and breaks tests.
|
||||
requiredRemoteType =
|
||||
this.getRemoteTypeForURIObject(uriObject, multiProcess,
|
||||
this.getRemoteTypeForURIObject(uriObject, multiProcess, remoteSubframes,
|
||||
currentRemoteType, browser.currentURI);
|
||||
} catch (e) {
|
||||
// createFixupURI throws if it can't create a URI. If that's the case then
|
||||
@ -440,13 +450,20 @@ var E10SUtils = {
|
||||
};
|
||||
},
|
||||
|
||||
shouldLoadURIInThisProcess(aURI) {
|
||||
shouldLoadURIInThisProcess(aURI, aRemoteSubframes) {
|
||||
let remoteType = Services.appinfo.remoteType;
|
||||
return remoteType == this.getRemoteTypeForURIObject(aURI, true, remoteType);
|
||||
return remoteType == this.getRemoteTypeForURIObject(aURI,
|
||||
/* remote */ true,
|
||||
aRemoteSubframes,
|
||||
remoteType);
|
||||
},
|
||||
|
||||
shouldLoadURI(aDocShell, aURI, aReferrer, aHasPostData) {
|
||||
let remoteSubframes = aDocShell.useRemoteSubframes;
|
||||
|
||||
// Inner frames should always load in the current process
|
||||
// XXX(nika): Handle shouldLoadURI-triggered process switches for remote
|
||||
// subframes! (bug 1548942)
|
||||
if (aDocShell.sameTypeParent) {
|
||||
return true;
|
||||
}
|
||||
@ -499,11 +516,12 @@ var E10SUtils = {
|
||||
// normally be allowed to load in this process by default.
|
||||
let remoteType = Services.appinfo.remoteType;
|
||||
return remoteType ==
|
||||
this.getRemoteTypeForURIObject(aURI, true, remoteType, webNav.currentURI);
|
||||
this.getRemoteTypeForURIObject(aURI, true, remoteSubframes,
|
||||
remoteType, webNav.currentURI);
|
||||
}
|
||||
|
||||
// If the URI can be loaded in the current process then continue
|
||||
return this.shouldLoadURIInThisProcess(aURI);
|
||||
return this.shouldLoadURIInThisProcess(aURI, remoteSubframes);
|
||||
},
|
||||
|
||||
redirectLoad(aDocShell, aURI, aReferrer, aTriggeringPrincipal, aFreshProcess, aFlags, aCsp) {
|
||||
|
@ -3349,8 +3349,11 @@ var gDetailView = {
|
||||
browser.sameProcessAsFrameLoader = policy.extension.groupFrameLoader;
|
||||
}
|
||||
|
||||
let remoteSubframes = window.docShell.QueryInterface(Ci.nsILoadContext).useRemoteSubframes;
|
||||
|
||||
let readyPromise;
|
||||
if (E10SUtils.canLoadURIInRemoteType(optionsURL, E10SUtils.EXTENSION_REMOTE_TYPE)) {
|
||||
if (E10SUtils.canLoadURIInRemoteType(optionsURL, remoteSubframes,
|
||||
E10SUtils.EXTENSION_REMOTE_TYPE)) {
|
||||
browser.setAttribute("remote", "true");
|
||||
browser.setAttribute("remoteType", E10SUtils.EXTENSION_REMOTE_TYPE);
|
||||
readyPromise = promiseEvent("XULFrameLoaderCreated", browser);
|
||||
|
Loading…
x
Reference in New Issue
Block a user