Bug 1147911 Part 2: Add a remote type property and use it to drive the process switching in frontend code. r=gijs, r=jryans, r=mikedeboer
This commit is contained in:
@@ -830,14 +830,13 @@ function _loadURIWithFlags(browser, uri, params) {
|
|||||||
Ci.nsIHttpChannel.REFERRER_POLICY_DEFAULT);
|
Ci.nsIHttpChannel.REFERRER_POLICY_DEFAULT);
|
||||||
let postData = params.postData;
|
let postData = params.postData;
|
||||||
|
|
||||||
let wasRemote = browser.isRemoteBrowser;
|
let currentRemoteType = browser.remoteType;
|
||||||
|
let requiredRemoteType =
|
||||||
|
E10SUtils.getRemoteTypeForURI(uri, gMultiProcessBrowser, currentRemoteType);
|
||||||
|
let mustChangeProcess = requiredRemoteType != currentRemoteType;
|
||||||
|
|
||||||
let process = browser.isRemoteBrowser ? Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT
|
// !requiredRemoteType means we're loading in the parent/this process.
|
||||||
: Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
|
if (!requiredRemoteType) {
|
||||||
let mustChangeProcess = gMultiProcessBrowser &&
|
|
||||||
!E10SUtils.canLoadURIInProcess(uri, process);
|
|
||||||
if ((!wasRemote && !mustChangeProcess) ||
|
|
||||||
(wasRemote && mustChangeProcess)) {
|
|
||||||
browser.inLoadURI = true;
|
browser.inLoadURI = true;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -888,8 +887,7 @@ function _loadURIWithFlags(browser, uri, params) {
|
|||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if ((!wasRemote && !mustChangeProcess) ||
|
if (!requiredRemoteType) {
|
||||||
(wasRemote && mustChangeProcess)) {
|
|
||||||
browser.inLoadURI = false;
|
browser.inLoadURI = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1145,22 +1143,12 @@ var gBrowserInit = {
|
|||||||
gBrowser.selectedBrowser.setAttribute("usercontextid", usercontextid);
|
gBrowser.selectedBrowser.setAttribute("usercontextid", usercontextid);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the browser that we're swapping in was remote, then we'd better
|
|
||||||
// be able to support remote browsers, and then make our selectedTab
|
|
||||||
// remote.
|
|
||||||
try {
|
try {
|
||||||
if (tabToOpen.linkedBrowser.isRemoteBrowser) {
|
// Make sure selectedBrowser has the same remote settings as the one
|
||||||
if (!gMultiProcessBrowser) {
|
// we are swapping in.
|
||||||
throw new Error("Cannot drag a remote browser into a window " +
|
gBrowser.updateBrowserRemoteness(gBrowser.selectedBrowser,
|
||||||
"without the remote tabs load context.");
|
tabToOpen.linkedBrowser.isRemoteBrowser,
|
||||||
}
|
tabToOpen.linkedBrowser.remoteType);
|
||||||
gBrowser.updateBrowserRemoteness(gBrowser.selectedBrowser, true);
|
|
||||||
} else if (gBrowser.selectedBrowser.isRemoteBrowser) {
|
|
||||||
// If the browser is remote, then it's implied that
|
|
||||||
// gMultiProcessBrowser is true. We need to flip the remoteness
|
|
||||||
// of this tab to false in order for the tab drag to work.
|
|
||||||
gBrowser.updateBrowserRemoteness(gBrowser.selectedBrowser, false);
|
|
||||||
}
|
|
||||||
gBrowser.swapBrowsersAndCloseOther(gBrowser.selectedTab, tabToOpen);
|
gBrowser.swapBrowsersAndCloseOther(gBrowser.selectedTab, tabToOpen);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Cu.reportError(e);
|
Cu.reportError(e);
|
||||||
@@ -2271,24 +2259,22 @@ function BrowserViewSourceOfDocument(aArgsOrDocument) {
|
|||||||
let inTab = Services.prefs.getBoolPref("view_source.tab");
|
let inTab = Services.prefs.getBoolPref("view_source.tab");
|
||||||
if (inTab) {
|
if (inTab) {
|
||||||
let tabBrowser = gBrowser;
|
let tabBrowser = gBrowser;
|
||||||
let forceNotRemote = false;
|
let preferredRemoteType;
|
||||||
if (!tabBrowser) {
|
if (!tabBrowser) {
|
||||||
if (!args.browser) {
|
if (!args.browser) {
|
||||||
throw new Error("BrowserViewSourceOfDocument should be passed the " +
|
throw new Error("BrowserViewSourceOfDocument should be passed the " +
|
||||||
"subject browser if called from a window without " +
|
"subject browser if called from a window without " +
|
||||||
"gBrowser defined.");
|
"gBrowser defined.");
|
||||||
}
|
}
|
||||||
forceNotRemote = !args.browser.isRemoteBrowser;
|
preferredRemoteType = args.browser.remoteType;
|
||||||
} else {
|
} else {
|
||||||
// Some internal URLs (such as specific chrome: and about: URLs that are
|
// Some internal URLs (such as specific chrome: and about: URLs that are
|
||||||
// not yet remote ready) cannot be loaded in a remote browser. View
|
// not yet remote ready) cannot be loaded in a remote browser. View
|
||||||
// source in tab expects the new view source browser's remoteness to match
|
// source in tab expects the new view source browser's remoteness to match
|
||||||
// that of the original URL, so disable remoteness if necessary for this
|
// that of the original URL, so disable remoteness if necessary for this
|
||||||
// URL.
|
// URL.
|
||||||
let contentProcess = Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT
|
preferredRemoteType =
|
||||||
forceNotRemote =
|
E10SUtils.getRemoteTypeForURI(args.URL, gMultiProcessBrowser);
|
||||||
gMultiProcessBrowser &&
|
|
||||||
!E10SUtils.canLoadURIInProcess(args.URL, contentProcess)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// In the case of popups, we need to find a non-popup browser window.
|
// In the case of popups, we need to find a non-popup browser window.
|
||||||
@@ -2306,7 +2292,7 @@ function BrowserViewSourceOfDocument(aArgsOrDocument) {
|
|||||||
let tab = tabBrowser.loadOneTab("about:blank", {
|
let tab = tabBrowser.loadOneTab("about:blank", {
|
||||||
relatedToCurrent: true,
|
relatedToCurrent: true,
|
||||||
inBackground: false,
|
inBackground: false,
|
||||||
forceNotRemote,
|
preferredRemoteType,
|
||||||
relatedBrowser: args.browser
|
relatedBrowser: args.browser
|
||||||
});
|
});
|
||||||
args.viewSourceBrowser = tabBrowser.getBrowserForTab(tab);
|
args.viewSourceBrowser = tabBrowser.getBrowserForTab(tab);
|
||||||
@@ -3265,11 +3251,11 @@ var PrintPreviewListener = {
|
|||||||
getPrintPreviewBrowser: function() {
|
getPrintPreviewBrowser: function() {
|
||||||
if (!this._printPreviewTab) {
|
if (!this._printPreviewTab) {
|
||||||
let browser = gBrowser.selectedTab.linkedBrowser;
|
let browser = gBrowser.selectedTab.linkedBrowser;
|
||||||
let forceNotRemote = gMultiProcessBrowser && !browser.isRemoteBrowser;
|
let preferredRemoteType = browser.remoteType;
|
||||||
this._tabBeforePrintPreview = gBrowser.selectedTab;
|
this._tabBeforePrintPreview = gBrowser.selectedTab;
|
||||||
this._printPreviewTab = gBrowser.loadOneTab("about:blank",
|
this._printPreviewTab = gBrowser.loadOneTab("about:blank",
|
||||||
{ inBackground: false,
|
{ inBackground: false,
|
||||||
forceNotRemote,
|
preferredRemoteType,
|
||||||
relatedBrowser: browser });
|
relatedBrowser: browser });
|
||||||
gBrowser.selectedTab = this._printPreviewTab;
|
gBrowser.selectedTab = this._printPreviewTab;
|
||||||
}
|
}
|
||||||
@@ -4232,7 +4218,7 @@ var XULBrowserWindow = {
|
|||||||
forceInitialBrowserNonRemote: function(aOpener) {
|
forceInitialBrowserNonRemote: function(aOpener) {
|
||||||
let initBrowser =
|
let initBrowser =
|
||||||
document.getAnonymousElementByAttribute(gBrowser, "anonid", "initialBrowser");
|
document.getAnonymousElementByAttribute(gBrowser, "anonid", "initialBrowser");
|
||||||
gBrowser.updateBrowserRemoteness(initBrowser, false, aOpener);
|
gBrowser.updateBrowserRemoteness(initBrowser, false, E10SUtils.NOT_REMOTE, aOpener);
|
||||||
},
|
},
|
||||||
|
|
||||||
setDefaultStatus: function(status) {
|
setDefaultStatus: function(status) {
|
||||||
|
|||||||
@@ -1514,6 +1514,7 @@
|
|||||||
var aAllowMixedContent;
|
var aAllowMixedContent;
|
||||||
var aSkipAnimation;
|
var aSkipAnimation;
|
||||||
var aForceNotRemote;
|
var aForceNotRemote;
|
||||||
|
var aPreferredRemoteType;
|
||||||
var aNoReferrer;
|
var aNoReferrer;
|
||||||
var aUserContextId;
|
var aUserContextId;
|
||||||
var aRelatedBrowser;
|
var aRelatedBrowser;
|
||||||
@@ -1534,6 +1535,7 @@
|
|||||||
aAllowMixedContent = params.allowMixedContent;
|
aAllowMixedContent = params.allowMixedContent;
|
||||||
aSkipAnimation = params.skipAnimation;
|
aSkipAnimation = params.skipAnimation;
|
||||||
aForceNotRemote = params.forceNotRemote;
|
aForceNotRemote = params.forceNotRemote;
|
||||||
|
aPreferredRemoteType = params.preferredRemoteType;
|
||||||
aNoReferrer = params.noReferrer;
|
aNoReferrer = params.noReferrer;
|
||||||
aUserContextId = params.userContextId;
|
aUserContextId = params.userContextId;
|
||||||
aRelatedBrowser = params.relatedBrowser;
|
aRelatedBrowser = params.relatedBrowser;
|
||||||
@@ -1556,6 +1558,7 @@
|
|||||||
skipAnimation: aSkipAnimation,
|
skipAnimation: aSkipAnimation,
|
||||||
allowMixedContent: aAllowMixedContent,
|
allowMixedContent: aAllowMixedContent,
|
||||||
forceNotRemote: aForceNotRemote,
|
forceNotRemote: aForceNotRemote,
|
||||||
|
preferredRemoteType: aPreferredRemoteType,
|
||||||
noReferrer: aNoReferrer,
|
noReferrer: aNoReferrer,
|
||||||
userContextId: aUserContextId,
|
userContextId: aUserContextId,
|
||||||
originPrincipal: aOriginPrincipal,
|
originPrincipal: aOriginPrincipal,
|
||||||
@@ -1673,26 +1676,38 @@
|
|||||||
<method name="updateBrowserRemoteness">
|
<method name="updateBrowserRemoteness">
|
||||||
<parameter name="aBrowser"/>
|
<parameter name="aBrowser"/>
|
||||||
<parameter name="aShouldBeRemote"/>
|
<parameter name="aShouldBeRemote"/>
|
||||||
|
<parameter name="aNewRemoteType"/>
|
||||||
<parameter name="aOpener"/>
|
<parameter name="aOpener"/>
|
||||||
<parameter name="aFreshProcess"/>
|
<parameter name="aFreshProcess"/>
|
||||||
<body>
|
<body>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
|
if (!gMultiProcessBrowser && aShouldBeRemote) {
|
||||||
|
throw new Error("Cannot switch to remote browser in a window " +
|
||||||
|
"without the remote tabs load context.");
|
||||||
|
}
|
||||||
|
|
||||||
let isRemote = aBrowser.getAttribute("remote") == "true";
|
let isRemote = aBrowser.getAttribute("remote") == "true";
|
||||||
|
|
||||||
|
// If going remote and no aNewRemoteType then use default.
|
||||||
|
if (aShouldBeRemote && !aNewRemoteType) {
|
||||||
|
aNewRemoteType = E10SUtils.DEFAULT_REMOTE_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
// If we are passed an opener, we must be making the browser non-remote, and
|
// If we are passed an opener, we must be making the browser non-remote, and
|
||||||
// if the browser is _currently_ non-remote, we need the openers to match,
|
// if the browser is _currently_ non-remote, we need the openers to match,
|
||||||
// because it is already too late to change it.
|
// because it is already too late to change it.
|
||||||
if (aOpener) {
|
if (aOpener) {
|
||||||
if (aShouldBeRemote) {
|
if (aShouldBeRemote) {
|
||||||
throw new Exception("Cannot set an opener on a browser which should be remote!");
|
throw new Error("Cannot set an opener on a browser which should be remote!");
|
||||||
}
|
}
|
||||||
if (!isRemote && aBrowser.contentWindow.opener != aOpener) {
|
if (!isRemote && aBrowser.contentWindow.opener != aOpener) {
|
||||||
throw new Exception("Cannot change opener on an already non-remote browser!");
|
throw new Error("Cannot change opener on an already non-remote browser!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Abort if we're not going to change anything
|
// Abort if we're not going to change anything
|
||||||
if (isRemote == aShouldBeRemote && !aFreshProcess) {
|
if (isRemote == aShouldBeRemote && !aFreshProcess &&
|
||||||
|
(!isRemote || aBrowser.getAttribute("remoteType") == aNewRemoteType)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1729,7 +1744,13 @@
|
|||||||
// Change the "remote" attribute.
|
// Change the "remote" attribute.
|
||||||
let parent = aBrowser.parentNode;
|
let parent = aBrowser.parentNode;
|
||||||
parent.removeChild(aBrowser);
|
parent.removeChild(aBrowser);
|
||||||
aBrowser.setAttribute("remote", aShouldBeRemote ? "true" : "false");
|
if (aShouldBeRemote) {
|
||||||
|
aBrowser.setAttribute("remote", "true");
|
||||||
|
aBrowser.setAttribute("remoteType", aNewRemoteType);
|
||||||
|
} else {
|
||||||
|
aBrowser.setAttribute("remote", "false");
|
||||||
|
aBrowser.removeAttribute("remoteType");
|
||||||
|
}
|
||||||
|
|
||||||
// NB: This works with the hack in the browser constructor that
|
// NB: This works with the hack in the browser constructor that
|
||||||
// turns this normal property into a field.
|
// turns this normal property into a field.
|
||||||
@@ -1813,37 +1834,28 @@
|
|||||||
</body>
|
</body>
|
||||||
</method>
|
</method>
|
||||||
|
|
||||||
<method name="switchBrowserIntoFreshProcess">
|
|
||||||
<parameter name="aBrowser"/>
|
|
||||||
<body>
|
|
||||||
<![CDATA[
|
|
||||||
if (!gMultiProcessBrowser) {
|
|
||||||
return this.updateBrowserRemoteness(aBrowser, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.updateBrowserRemoteness(aBrowser,
|
|
||||||
/* aShouldBeRemote */ true,
|
|
||||||
/* aOpener */ null,
|
|
||||||
/* aFreshProcess */ true);
|
|
||||||
]]>
|
|
||||||
</body>
|
|
||||||
</method>
|
|
||||||
|
|
||||||
<method name="updateBrowserRemotenessByURL">
|
<method name="updateBrowserRemotenessByURL">
|
||||||
<parameter name="aBrowser"/>
|
<parameter name="aBrowser"/>
|
||||||
<parameter name="aURL"/>
|
<parameter name="aURL"/>
|
||||||
|
<parameter name="aFreshProcess"/>
|
||||||
<body>
|
<body>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
if (!gMultiProcessBrowser)
|
if (!gMultiProcessBrowser)
|
||||||
return this.updateBrowserRemoteness(aBrowser, false);
|
return this.updateBrowserRemoteness(aBrowser, false);
|
||||||
|
|
||||||
let process = aBrowser.isRemoteBrowser ? Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT
|
// If this URL can't load in the current browser then flip it to the
|
||||||
: Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
|
// correct type.
|
||||||
|
let currentRemoteType = aBrowser.remoteType;
|
||||||
// If this URL can't load in the browser's current process then flip
|
let requiredRemoteType =
|
||||||
// it to the other process
|
E10SUtils.getRemoteTypeForURI(aURL, gMultiProcessBrowser,
|
||||||
if (!E10SUtils.canLoadURIInProcess(aURL, process))
|
currentRemoteType);
|
||||||
return this.updateBrowserRemoteness(aBrowser, !aBrowser.isRemoteBrowser);
|
if (currentRemoteType != requiredRemoteType || aFreshProcess) {
|
||||||
|
return this.updateBrowserRemoteness(aBrowser,
|
||||||
|
!!requiredRemoteType,
|
||||||
|
requiredRemoteType,
|
||||||
|
/* aOpener */ null,
|
||||||
|
aFreshProcess);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
]]>
|
]]>
|
||||||
@@ -1900,15 +1912,16 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let remote = gMultiProcessBrowser &&
|
let remoteType =
|
||||||
E10SUtils.canLoadURIInProcess(BROWSER_NEW_TAB_URL, Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT);
|
E10SUtils.getRemoteTypeForURI(BROWSER_NEW_TAB_URL,
|
||||||
let browser = this._createBrowser({isPreloadBrowser: true, remote: remote});
|
gMultiProcessBrowser);
|
||||||
|
let browser = this._createBrowser({isPreloadBrowser: true, remoteType});
|
||||||
this._preloadedBrowser = browser;
|
this._preloadedBrowser = browser;
|
||||||
|
|
||||||
let notificationbox = this.getNotificationBox(browser);
|
let notificationbox = this.getNotificationBox(browser);
|
||||||
this.mPanelContainer.appendChild(notificationbox);
|
this.mPanelContainer.appendChild(notificationbox);
|
||||||
|
|
||||||
if (remote) {
|
if (remoteType != E10SUtils.NOT_REMOTE) {
|
||||||
// For remote browsers, we need to make sure that the webProgress is
|
// For remote browsers, we need to make sure that the webProgress is
|
||||||
// instantiated, otherwise the parent won't get informed about the state
|
// instantiated, otherwise the parent won't get informed about the state
|
||||||
// of the preloaded browser until it gets attached to a tab.
|
// of the preloaded browser until it gets attached to a tab.
|
||||||
@@ -1926,7 +1939,8 @@
|
|||||||
<body>
|
<body>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
// Supported parameters:
|
// Supported parameters:
|
||||||
// userContextId, remote, isPreloadBrowser, uriIsAboutBlank, permanentKey
|
// userContextId, remote, remoteType, isPreloadBrowser,
|
||||||
|
// uriIsAboutBlank, permanentKey
|
||||||
|
|
||||||
const NS_XUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
const NS_XUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||||
|
|
||||||
@@ -1942,12 +1956,18 @@
|
|||||||
b.setAttribute("usercontextid", aParams.userContextId);
|
b.setAttribute("usercontextid", aParams.userContextId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aParams.remote) {
|
// remote parameter used by some addons, use default in this case.
|
||||||
|
if (aParams.remote && !aParams.remoteType) {
|
||||||
|
aParams.remoteType = E10SUtils.DEFAULT_REMOTE_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aParams.remoteType) {
|
||||||
|
b.setAttribute("remoteType", aParams.remoteType);
|
||||||
b.setAttribute("remote", "true");
|
b.setAttribute("remote", "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aParams.opener) {
|
if (aParams.opener) {
|
||||||
if (aParams.remote) {
|
if (aParams.remoteType) {
|
||||||
throw new Exception("Cannot set opener window on a remote browser!");
|
throw new Exception("Cannot set opener window on a remote browser!");
|
||||||
}
|
}
|
||||||
b.QueryInterface(Ci.nsIFrameLoaderOwner).presetOpenerWindow(aParams.opener);
|
b.QueryInterface(Ci.nsIFrameLoaderOwner).presetOpenerWindow(aParams.opener);
|
||||||
@@ -2020,15 +2040,14 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// Supported parameters:
|
// Supported parameters:
|
||||||
// forceNotRemote, userContextId
|
// forceNotRemote, preferredRemoteType, userContextId
|
||||||
|
|
||||||
let uriIsAboutBlank = !aURI || aURI == "about:blank";
|
let uriIsAboutBlank = !aURI || aURI == "about:blank";
|
||||||
|
|
||||||
// The new browser should be remote if this is an e10s window and
|
let remoteType =
|
||||||
// the uri to load can be loaded remotely.
|
aParams.forceNotRemote ? E10SUtils.NOT_REMOTE
|
||||||
let remote = gMultiProcessBrowser &&
|
: E10SUtils.getRemoteTypeForURI(aURI, gMultiProcessBrowser,
|
||||||
!aParams.forceNotRemote &&
|
aParams.preferredRemoteType);
|
||||||
E10SUtils.canLoadURIInProcess(aURI, Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT);
|
|
||||||
|
|
||||||
let browser;
|
let browser;
|
||||||
let usingPreloadedContent = false;
|
let usingPreloadedContent = false;
|
||||||
@@ -2050,7 +2069,7 @@
|
|||||||
if (!browser) {
|
if (!browser) {
|
||||||
// No preloaded browser found, create one.
|
// No preloaded browser found, create one.
|
||||||
browser = this._createBrowser({permanentKey: aTab.permanentKey,
|
browser = this._createBrowser({permanentKey: aTab.permanentKey,
|
||||||
remote: remote,
|
remoteType,
|
||||||
uriIsAboutBlank: uriIsAboutBlank,
|
uriIsAboutBlank: uriIsAboutBlank,
|
||||||
userContextId: aParams.userContextId,
|
userContextId: aParams.userContextId,
|
||||||
relatedBrowser: aParams.relatedBrowser,
|
relatedBrowser: aParams.relatedBrowser,
|
||||||
@@ -2095,7 +2114,7 @@
|
|||||||
// from being created as soon as the linked <browser> is inserted
|
// from being created as soon as the linked <browser> is inserted
|
||||||
// into the DOM. We thus have to register the new outerWindowID
|
// into the DOM. We thus have to register the new outerWindowID
|
||||||
// for non-remote browsers after we have called browser.loadURI().
|
// for non-remote browsers after we have called browser.loadURI().
|
||||||
if (!remote) {
|
if (remoteType == E10SUtils.NOT_REMOTE) {
|
||||||
this._outerWindowIDBrowserMap.set(browser.outerWindowID, browser);
|
this._outerWindowIDBrowserMap.set(browser.outerWindowID, browser);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2125,6 +2144,7 @@
|
|||||||
var aSkipAnimation;
|
var aSkipAnimation;
|
||||||
var aAllowMixedContent;
|
var aAllowMixedContent;
|
||||||
var aForceNotRemote;
|
var aForceNotRemote;
|
||||||
|
var aPreferredRemoteType;
|
||||||
var aNoReferrer;
|
var aNoReferrer;
|
||||||
var aUserContextId;
|
var aUserContextId;
|
||||||
var aEventDetail;
|
var aEventDetail;
|
||||||
@@ -2147,6 +2167,7 @@
|
|||||||
aSkipAnimation = params.skipAnimation;
|
aSkipAnimation = params.skipAnimation;
|
||||||
aAllowMixedContent = params.allowMixedContent;
|
aAllowMixedContent = params.allowMixedContent;
|
||||||
aForceNotRemote = params.forceNotRemote;
|
aForceNotRemote = params.forceNotRemote;
|
||||||
|
aPreferredRemoteType = params.preferredRemoteType;
|
||||||
aNoReferrer = params.noReferrer;
|
aNoReferrer = params.noReferrer;
|
||||||
aUserContextId = params.userContextId;
|
aUserContextId = params.userContextId;
|
||||||
aEventDetail = params.eventDetail;
|
aEventDetail = params.eventDetail;
|
||||||
@@ -2220,6 +2241,7 @@
|
|||||||
// of tab.linkedBrowser.
|
// of tab.linkedBrowser.
|
||||||
let browserParams = {
|
let browserParams = {
|
||||||
forceNotRemote: aForceNotRemote,
|
forceNotRemote: aForceNotRemote,
|
||||||
|
preferredRemoteType: aPreferredRemoteType,
|
||||||
userContextId: aUserContextId,
|
userContextId: aUserContextId,
|
||||||
relatedBrowser: aRelatedBrowser,
|
relatedBrowser: aRelatedBrowser,
|
||||||
opener: aOpener,
|
opener: aOpener,
|
||||||
|
|||||||
@@ -3543,13 +3543,8 @@ var SessionStoreInternal = {
|
|||||||
// flip the remoteness of any browser that is not being displayed.
|
// flip the remoteness of any browser that is not being displayed.
|
||||||
this.markTabAsRestoring(aTab);
|
this.markTabAsRestoring(aTab);
|
||||||
|
|
||||||
let isRemotenessUpdate = false;
|
let isRemotenessUpdate =
|
||||||
if (aReloadInFreshProcess) {
|
tabbrowser.updateBrowserRemotenessByURL(browser, uri, aReloadInFreshProcess);
|
||||||
isRemotenessUpdate = tabbrowser.switchBrowserIntoFreshProcess(browser);
|
|
||||||
} else {
|
|
||||||
isRemotenessUpdate = tabbrowser.updateBrowserRemotenessByURL(browser, uri);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isRemotenessUpdate) {
|
if (isRemotenessUpdate) {
|
||||||
// We updated the remoteness, so we need to send the history down again.
|
// We updated the remoteness, so we need to send the history down again.
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -28,31 +28,69 @@ function getAboutModule(aURL) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const NOT_REMOTE = null;
|
||||||
|
const WEB_REMOTE_TYPE = "web";
|
||||||
|
const DEFAULT_REMOTE_TYPE = WEB_REMOTE_TYPE;
|
||||||
|
|
||||||
this.E10SUtils = {
|
this.E10SUtils = {
|
||||||
|
DEFAULT_REMOTE_TYPE,
|
||||||
|
NOT_REMOTE,
|
||||||
|
WEB_REMOTE_TYPE,
|
||||||
|
|
||||||
canLoadURIInProcess: function(aURL, aProcess) {
|
canLoadURIInProcess: function(aURL, aProcess) {
|
||||||
|
let remoteType = aProcess == Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT
|
||||||
|
? DEFAULT_REMOTE_TYPE : NOT_REMOTE;
|
||||||
|
return remoteType == this.getRemoteTypeForURI(aURL, true, remoteType);
|
||||||
|
},
|
||||||
|
|
||||||
|
getRemoteTypeForURI: function(aURL, aMultiProcess,
|
||||||
|
aPreferredRemoteType = DEFAULT_REMOTE_TYPE) {
|
||||||
|
if (!aMultiProcess) {
|
||||||
|
return NOT_REMOTE;
|
||||||
|
}
|
||||||
|
|
||||||
// loadURI in browser.xml treats null as about:blank
|
// loadURI in browser.xml treats null as about:blank
|
||||||
if (!aURL)
|
if (!aURL) {
|
||||||
aURL = "about:blank";
|
aURL = "about:blank";
|
||||||
|
}
|
||||||
|
|
||||||
// Javascript urls can load in any process, they apply to the current document
|
// Javascript urls can load in any process, they apply to the current document
|
||||||
if (aURL.startsWith("javascript:"))
|
if (aURL.startsWith("javascript:")) {
|
||||||
return true;
|
return aPreferredRemoteType;
|
||||||
|
}
|
||||||
|
|
||||||
let processIsRemote = aProcess == Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT;
|
// We need data: URIs to load in any remote process, because some of our
|
||||||
|
// tests rely on this.
|
||||||
let canLoadRemote = true;
|
if (aURL.startsWith("data:")) {
|
||||||
let mustLoadRemote = true;
|
return aPreferredRemoteType == NOT_REMOTE ? DEFAULT_REMOTE_TYPE
|
||||||
|
: aPreferredRemoteType;
|
||||||
|
}
|
||||||
|
|
||||||
if (aURL.startsWith("about:")) {
|
if (aURL.startsWith("about:")) {
|
||||||
|
// We need to special case about:blank because it needs to load in any.
|
||||||
|
if (aURL == "about:blank") {
|
||||||
|
return aPreferredRemoteType;
|
||||||
|
}
|
||||||
|
|
||||||
let url = Services.io.newURI(aURL, null, null);
|
let url = Services.io.newURI(aURL, null, null);
|
||||||
let module = getAboutModule(url);
|
let module = getAboutModule(url);
|
||||||
// If the module doesn't exist then an error page will be loading, that
|
// If the module doesn't exist then an error page will be loading, that
|
||||||
// should be ok to load in either process
|
// should be ok to load in any process
|
||||||
if (module) {
|
if (!module) {
|
||||||
let flags = module.getURIFlags(url);
|
return aPreferredRemoteType;
|
||||||
canLoadRemote = !!(flags & Ci.nsIAboutModule.URI_CAN_LOAD_IN_CHILD);
|
|
||||||
mustLoadRemote = !!(flags & Ci.nsIAboutModule.URI_MUST_LOAD_IN_CHILD);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let flags = module.getURIFlags(url);
|
||||||
|
if (flags & Ci.nsIAboutModule.URI_MUST_LOAD_IN_CHILD) {
|
||||||
|
return DEFAULT_REMOTE_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flags & Ci.nsIAboutModule.URI_CAN_LOAD_IN_CHILD &&
|
||||||
|
aPreferredRemoteType != NOT_REMOTE) {
|
||||||
|
return DEFAULT_REMOTE_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NOT_REMOTE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aURL.startsWith("chrome:")) {
|
if (aURL.startsWith("chrome:")) {
|
||||||
@@ -62,34 +100,33 @@ this.E10SUtils = {
|
|||||||
// not loading anything anyway.
|
// not loading anything anyway.
|
||||||
url = Services.io.newURI(aURL, null, null);
|
url = Services.io.newURI(aURL, null, null);
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
canLoadRemote = true;
|
return aPreferredRemoteType;
|
||||||
mustLoadRemote = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (url) {
|
|
||||||
let chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"].
|
let chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"].
|
||||||
getService(Ci.nsIXULChromeRegistry);
|
getService(Ci.nsIXULChromeRegistry);
|
||||||
canLoadRemote = chromeReg.canLoadURLRemotely(url);
|
if (chromeReg.mustLoadURLRemotely(url)) {
|
||||||
mustLoadRemote = chromeReg.mustLoadURLRemotely(url);
|
return DEFAULT_REMOTE_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (chromeReg.canLoadURLRemotely(url) &&
|
||||||
|
aPreferredRemoteType != NOT_REMOTE) {
|
||||||
|
return DEFAULT_REMOTE_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NOT_REMOTE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aURL.startsWith("moz-extension:")) {
|
if (aURL.startsWith("moz-extension:")) {
|
||||||
canLoadRemote = useRemoteWebExtensions;
|
return useRemoteWebExtensions ? WEB_REMOTE_TYPE : NOT_REMOTE;
|
||||||
mustLoadRemote = useRemoteWebExtensions;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aURL.startsWith("view-source:")) {
|
if (aURL.startsWith("view-source:")) {
|
||||||
return this.canLoadURIInProcess(aURL.substr("view-source:".length), aProcess);
|
return this.getRemoteTypeForURI(aURL.substr("view-source:".length),
|
||||||
|
aMultiProcess, aPreferredRemoteType);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mustLoadRemote)
|
return WEB_REMOTE_TYPE;
|
||||||
return processIsRemote;
|
|
||||||
|
|
||||||
if (!canLoadRemote && processIsRemote)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
shouldLoadURI: function(aDocShell, aURI, aReferrer) {
|
shouldLoadURI: function(aDocShell, aURI, aReferrer) {
|
||||||
|
|||||||
@@ -139,7 +139,8 @@ function swapToInnerBrowser({ tab, containerURL, getInnerBrowser }) {
|
|||||||
// 5. Force the original browser tab to be remote since web content is
|
// 5. Force the original browser tab to be remote since web content is
|
||||||
// loaded in the child process, and we're about to swap the content
|
// loaded in the child process, and we're about to swap the content
|
||||||
// into this tab.
|
// into this tab.
|
||||||
gBrowser.updateBrowserRemoteness(tab.linkedBrowser, true);
|
gBrowser.updateBrowserRemoteness(tab.linkedBrowser, true,
|
||||||
|
contentBrowser.remoteType);
|
||||||
|
|
||||||
// 6. Swap the content into the original browser tab and close the
|
// 6. Swap the content into the original browser tab and close the
|
||||||
// temporary tab used to hold the content via
|
// temporary tab used to hold the content via
|
||||||
@@ -212,6 +213,15 @@ function addXULBrowserDecorations(browser) {
|
|||||||
enumerable: true,
|
enumerable: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (browser.remoteType == undefined) {
|
||||||
|
Object.defineProperty(browser, "remoteType", {
|
||||||
|
get() {
|
||||||
|
return this.getAttribute("remoteType");
|
||||||
|
},
|
||||||
|
configurable: true,
|
||||||
|
enumerable: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
if (browser.messageManager == undefined) {
|
if (browser.messageManager == undefined) {
|
||||||
Object.defineProperty(browser, "messageManager", {
|
Object.defineProperty(browser, "messageManager", {
|
||||||
get() {
|
get() {
|
||||||
|
|||||||
@@ -143,6 +143,7 @@ function tunnelToInnerBrowser(outer, inner) {
|
|||||||
// down to the inner browser by this tunnel, the tab's remoteness effectively is the
|
// down to the inner browser by this tunnel, the tab's remoteness effectively is the
|
||||||
// remoteness of the inner browser.
|
// remoteness of the inner browser.
|
||||||
outer.setAttribute("remote", "true");
|
outer.setAttribute("remote", "true");
|
||||||
|
outer.setAttribute("remoteType", inner.remoteType);
|
||||||
|
|
||||||
// Clear out any cached state that references the current non-remote XBL binding,
|
// Clear out any cached state that references the current non-remote XBL binding,
|
||||||
// such as form fill controllers. Otherwise they will remain in place and leak the
|
// such as form fill controllers. Otherwise they will remain in place and leak the
|
||||||
@@ -269,6 +270,7 @@ function tunnelToInnerBrowser(outer, inner) {
|
|||||||
|
|
||||||
// Reset @remote since this is now back to a regular, non-remote browser
|
// Reset @remote since this is now back to a regular, non-remote browser
|
||||||
outer.setAttribute("remote", "false");
|
outer.setAttribute("remote", "false");
|
||||||
|
outer.removeAttribute("remoteType");
|
||||||
|
|
||||||
// Delete browser window properties exposed on content's owner global
|
// Delete browser window properties exposed on content's owner global
|
||||||
delete inner.ownerGlobal.PopupNotifications;
|
delete inner.ownerGlobal.PopupNotifications;
|
||||||
|
|||||||
@@ -127,9 +127,9 @@ module.exports = createClass({
|
|||||||
* React uses a whitelist for attributes, so we need some way to set
|
* React uses a whitelist for attributes, so we need some way to set
|
||||||
* attributes it does not know about, such as @mozbrowser. If this were
|
* attributes it does not know about, such as @mozbrowser. If this were
|
||||||
* the only issue, we could use componentDidMount or ref: node => {} to
|
* the only issue, we could use componentDidMount or ref: node => {} to
|
||||||
* set the atttibutes. In the case of @remote, the attribute must be set
|
* set the atttibutes. In the case of @remote and @remoteType, the
|
||||||
* before the element is added to the DOM to have any effect, which we
|
* attribute must be set before the element is added to the DOM to have
|
||||||
* are able to do with this approach.
|
* any effect, which we are able to do with this approach.
|
||||||
*
|
*
|
||||||
* @noisolation and @allowfullscreen are needed so that these frames
|
* @noisolation and @allowfullscreen are needed so that these frames
|
||||||
* have the same access to browser features as regular browser tabs.
|
* have the same access to browser features as regular browser tabs.
|
||||||
@@ -137,7 +137,8 @@ module.exports = createClass({
|
|||||||
* before allowing the swap to proceed.
|
* before allowing the swap to proceed.
|
||||||
*/
|
*/
|
||||||
dangerouslySetInnerHTML: {
|
dangerouslySetInnerHTML: {
|
||||||
__html: `<iframe class="browser" mozbrowser="true" remote="true"
|
__html: `<iframe class="browser" mozbrowser="true"
|
||||||
|
remote="true" remoteType="web"
|
||||||
noisolation="true" allowfullscreen="true"
|
noisolation="true" allowfullscreen="true"
|
||||||
src="${location}" width="100%" height="100%">
|
src="${location}" width="100%" height="100%">
|
||||||
</iframe>`
|
</iframe>`
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ ViewSourceBrowser.prototype = {
|
|||||||
|
|
||||||
// If we're dealing with a remote browser, then the browser
|
// If we're dealing with a remote browser, then the browser
|
||||||
// for view source needs to be remote as well.
|
// for view source needs to be remote as well.
|
||||||
this.updateBrowserRemoteness(browser.isRemoteBrowser);
|
this.updateBrowserRemoteness(browser.isRemoteBrowser, browser.remoteType);
|
||||||
} else if (outerWindowID) {
|
} else if (outerWindowID) {
|
||||||
throw new Error("Must supply the browser if passing the outerWindowID");
|
throw new Error("Must supply the browser if passing the outerWindowID");
|
||||||
}
|
}
|
||||||
@@ -221,9 +221,12 @@ ViewSourceBrowser.prototype = {
|
|||||||
* True if the browser should be made remote. If the browsers
|
* True if the browser should be made remote. If the browsers
|
||||||
* remoteness already matches this value, this function does
|
* remoteness already matches this value, this function does
|
||||||
* nothing.
|
* nothing.
|
||||||
|
* @param remoteType
|
||||||
|
* The type of remote browser process.
|
||||||
*/
|
*/
|
||||||
updateBrowserRemoteness(shouldBeRemote) {
|
updateBrowserRemoteness(shouldBeRemote, remoteType) {
|
||||||
if (this.browser.isRemoteBrowser != shouldBeRemote) {
|
if (this.browser.isRemoteBrowser != shouldBeRemote ||
|
||||||
|
this.browser.remoteType != remoteType) {
|
||||||
// In this base case, where we are handed a <browser> someone else is
|
// In this base case, where we are handed a <browser> someone else is
|
||||||
// managing, we don't know for sure that it's safe to toggle remoteness.
|
// managing, we don't know for sure that it's safe to toggle remoteness.
|
||||||
// For view source in a window, this is overridden to actually do the
|
// For view source in a window, this is overridden to actually do the
|
||||||
|
|||||||
@@ -666,9 +666,12 @@ ViewSourceChrome.prototype = {
|
|||||||
* True if the browser should be made remote. If the browsers
|
* True if the browser should be made remote. If the browsers
|
||||||
* remoteness already matches this value, this function does
|
* remoteness already matches this value, this function does
|
||||||
* nothing.
|
* nothing.
|
||||||
|
* @param remoteType
|
||||||
|
* The type of remote browser process.
|
||||||
*/
|
*/
|
||||||
updateBrowserRemoteness(shouldBeRemote) {
|
updateBrowserRemoteness(shouldBeRemote, remoteType) {
|
||||||
if (this.browser.isRemoteBrowser == shouldBeRemote) {
|
if (this.browser.isRemoteBrowser == shouldBeRemote &&
|
||||||
|
this.browser.remoteType == remoteType) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -685,8 +688,10 @@ ViewSourceChrome.prototype = {
|
|||||||
this.browser.remove();
|
this.browser.remove();
|
||||||
if (shouldBeRemote) {
|
if (shouldBeRemote) {
|
||||||
this.browser.setAttribute("remote", "true");
|
this.browser.setAttribute("remote", "true");
|
||||||
|
this.browser.setAttribute("remoteType", remoteType);
|
||||||
} else {
|
} else {
|
||||||
this.browser.removeAttribute("remote");
|
this.browser.removeAttribute("remote");
|
||||||
|
this.browser.removeAttribute("remoteType");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.browser.relatedBrowser = relatedBrowser;
|
this.browser.relatedBrowser = relatedBrowser;
|
||||||
|
|||||||
@@ -338,6 +338,25 @@
|
|||||||
onget="return (this.getAttribute('remote') == 'true');"
|
onget="return (this.getAttribute('remote') == 'true');"
|
||||||
readonly="true"/>
|
readonly="true"/>
|
||||||
|
|
||||||
|
<property name="remoteType"
|
||||||
|
readonly="true">
|
||||||
|
<getter>
|
||||||
|
<![CDATA[
|
||||||
|
if (!this.isRemoteBrowser) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
let remoteType = this.getAttribute("remoteType");
|
||||||
|
if (remoteType) {
|
||||||
|
return remoteType;
|
||||||
|
}
|
||||||
|
|
||||||
|
let E10SUtils = Components.utils.import("resource://gre/modules/E10SUtils.jsm", {}).E10SUtils;
|
||||||
|
return E10SUtils.DEFAULT_REMOTE_TYPE;
|
||||||
|
]]>
|
||||||
|
</getter>
|
||||||
|
</property>
|
||||||
|
|
||||||
<property name="messageManager"
|
<property name="messageManager"
|
||||||
readonly="true">
|
readonly="true">
|
||||||
<getter>
|
<getter>
|
||||||
|
|||||||
Reference in New Issue
Block a user