Bug 1671983 - Part 1: Remove now-unused process switching shouldLoadURI methods, r=annyG,geckoview-reviewers,snorp

These methods are no longer necessary, as all loads which can trigger process
switches now go through DocumentChannel.

The shouldLoadURI methods on nsIWebBrowserChrome3 are unfortunately still
necessary as they're used by the disabled-by-default "Single-Site Browser"
feature. In the future this may be possible to clean-up.

Differential Revision: https://phabricator.services.mozilla.com/D94638
This commit is contained in:
Nika Layzell 2020-11-12 18:00:53 +00:00
Родитель 67a1f9eb04
Коммит 9ff27adca3
9 изменённых файлов: 6 добавлений и 291 удалений

Просмотреть файл

@ -30,15 +30,6 @@ class BrowserTabParent extends JSWindowActorParent {
browser.ownerGlobal.gBrowserInit._firstContentWindowPaintDeferred.resolve();
break;
}
case "Browser:LoadURI": {
if (gBrowser.sessionHistoryInParent) {
message.data.historyIndex =
browsingContext.sessionHistory.requestedIndex;
}
gBrowser.ownerGlobal.RedirectLoad(browser, message.data);
break;
}
}
}
}

Просмотреть файл

@ -1639,32 +1639,6 @@ function LoadInOtherProcess(browser, loadOptions, historyIndex = -1) {
SessionStore.navigateAndRestore(tab, loadOptions, historyIndex);
}
// Called when a docshell has attempted to load a page in an incorrect process.
// This function is responsible for loading the page in the correct process.
function RedirectLoad(browser, data) {
if (browser.getAttribute("preloadedState") === "consumed") {
browser.removeAttribute("preloadedState");
data.loadOptions.newFrameloader = true;
}
// We should only start the redirection if the browser window has finished
// starting up. Otherwise, we should wait until the startup is done.
if (gBrowserInit.delayedStartupFinished) {
LoadInOtherProcess(browser, data.loadOptions, data.historyIndex);
} else {
let delayedStartupFinished = (subject, topic) => {
if (topic == "browser-delayed-startup-finished" && subject == window) {
Services.obs.removeObserver(delayedStartupFinished, topic);
LoadInOtherProcess(browser, data.loadOptions, data.historyIndex);
}
};
Services.obs.addObserver(
delayedStartupFinished,
"browser-delayed-startup-finished"
);
}
}
let _resolveDelayedStartup;
var delayedStartupPromise = new Promise(resolve => {
_resolveDelayedStartup = resolve;
@ -5193,50 +5167,6 @@ var XULBrowserWindow = {
);
},
// Check whether this URI should load in the current process
shouldLoadURI(
aDocShell,
aURI,
aReferrerInfo,
aHasPostData,
aTriggeringPrincipal,
aCsp
) {
if (!gMultiProcessBrowser) {
return true;
}
let browser = aDocShell
.QueryInterface(Ci.nsIDocShellTreeItem)
.sameTypeRootTreeItem.QueryInterface(Ci.nsIDocShell).chromeEventHandler;
// Ignore loads that aren't in the main tabbrowser
if (
browser.localName != "browser" ||
!browser.getTabBrowser ||
browser.getTabBrowser() != gBrowser
) {
return true;
}
if (!E10SUtils.shouldLoadURI(aDocShell, aURI, aHasPostData)) {
// XXX: Do we want to complain if we have post data but are still
// redirecting the load? Perhaps a telemetry probe? Theoretically we
// shouldn't do this, as it throws out data. See bug 1348018.
E10SUtils.redirectLoad(
aDocShell,
aURI,
aReferrerInfo,
aTriggeringPrincipal,
null,
aCsp
);
return false;
}
return true;
},
onProgressChange(
aWebProgress,
aRequest,
@ -6253,9 +6183,9 @@ nsBrowserAccess.prototype = {
// If we have an opener, that means that the caller is expecting access
// to the nsIDOMWindow of the opened tab right away. For e10s windows,
// this means forcing the newly opened browser to be non-remote so that
// we can hand back the nsIDOMWindow. The XULBrowserWindow.shouldLoadURI
// will do the job of shuttling off the newly opened browser to run in
// the right process once it starts loading a URI.
// we can hand back the nsIDOMWindow. DocumentLoadListener will do the
// job of shuttling off the newly opened browser to run in the right
// process once it starts loading a URI.
let forceNotRemote = aOpenWindowInfo && !aOpenWindowInfo.isRemote;
let userContextId = aOpenWindowInfo
? aOpenWindowInfo.originAttributes.userContextId

Просмотреть файл

@ -9,11 +9,6 @@
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.defineModuleGetter(
this,
"E10SUtils",
"resource://gre/modules/E10SUtils.jsm"
);
ChromeUtils.defineModuleGetter(
this,
"BrowserUtils",
@ -42,25 +37,11 @@ var WebBrowserChrome = {
aTriggeringPrincipal,
aCsp
) {
if (!E10SUtils.shouldLoadURI(aDocShell, aURI, aHasPostData)) {
E10SUtils.redirectLoad(
aDocShell,
aURI,
aReferrerInfo,
aTriggeringPrincipal,
null,
aCsp
);
return false;
}
return true;
},
shouldLoadURIInThisProcess(aURI) {
let remoteSubframes = docShell.QueryInterface(Ci.nsILoadContext)
.useRemoteSubframes;
return E10SUtils.shouldLoadURIInThisProcess(aURI, remoteSubframes);
return true;
},
};

Просмотреть файл

@ -131,11 +131,6 @@ var waitForLoad = async function(uri) {
// Tests referrerInfo when navigating from a page in the remote process to main
// process and vice versa.
// The changing process code flow is (cpp) docshell.shouldLoadURI
// -> (JS) browser.shouldLoadURI -> E10sUtils.redirectLoad
// -> ContentRestore.restoreTabContent.
// Finally, docshell will do the load in correct process with the input
// referrerInfo and store an entry to SessionHistory
add_task(async function test_navigation() {
// Navigate from non remote to remote
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");

Просмотреть файл

@ -12,7 +12,6 @@ const { GeckoViewActorChild } = ChromeUtils.import(
XPCOMUtils.defineLazyModuleGetters(this, {
BrowserUtils: "resource://gre/modules/BrowserUtils.jsm",
E10SUtils: "resource://gre/modules/E10SUtils.jsm",
GeckoViewSettings: "resource://gre/modules/GeckoViewSettings.jsm",
});
@ -40,28 +39,12 @@ class WebBrowserChromeChild extends GeckoViewActorChild {
aTriggeringPrincipal,
aCsp
) {
debug`shouldLoadURI ${aURI.displaySpec}`;
if (!E10SUtils.shouldLoadURI(aDocShell, aURI, aHasPostData)) {
E10SUtils.redirectLoad(
aDocShell,
aURI,
aReferrerInfo,
aTriggeringPrincipal,
null,
aCsp
);
return false;
}
return true;
}
// nsIWebBrowserChrome
shouldLoadURIInThisProcess(aURI) {
debug`shouldLoadURIInThisProcess ${aURI.displaySpec}`;
const remoteSubframes = this.docShell.nsILoadContext.useRemoteSubframes;
return E10SUtils.shouldLoadURIInThisProcess(aURI, remoteSubframes);
return true;
}
}

Просмотреть файл

@ -10,7 +10,6 @@ var { XPCOMUtils } = ChromeUtils.import(
XPCOMUtils.defineLazyModuleGetters(this, {
BrowserUtils: "resource://gre/modules/BrowserUtils.jsm",
clearTimeout: "resource://gre/modules/Timer.jsm",
E10SUtils: "resource://gre/modules/E10SUtils.jsm",
ExtensionCommon: "resource://gre/modules/ExtensionCommon.jsm",
setTimeout: "resource://gre/modules/Timer.jsm",
});
@ -336,9 +335,7 @@ var WebBrowserChrome = {
},
shouldLoadURIInThisProcess(URI) {
let remoteSubframes = docShell.QueryInterface(Ci.nsILoadContext)
.useRemoteSubframes;
return E10SUtils.shouldLoadURIInThisProcess(URI, remoteSubframes);
return true;
},
};

Просмотреть файл

@ -972,133 +972,6 @@ var E10SUtils = {
};
},
shouldLoadURIInThisProcess(aURI, aRemoteSubframes) {
let remoteType = Services.appinfo.remoteType;
let wantRemoteType = this.getRemoteTypeForURIObject(
aURI,
/* remote */ true,
aRemoteSubframes,
remoteType
);
this.log().info(
`shouldLoadURIInThisProcess: have ${remoteType} want ${wantRemoteType}`
);
if (documentChannelPermittedForURI(aURI)) {
// We can switch later with documentchannel.
return true;
}
return remoteType == wantRemoteType;
},
shouldLoadURI(aDocShell, aURI, aHasPostData) {
let { useRemoteSubframes } = aDocShell;
this.log().debug(`shouldLoadURI(${this._uriStr(aURI)})`);
let remoteType = Services.appinfo.remoteType;
if (aDocShell.browsingContext.parent) {
return true;
}
let webNav = aDocShell.QueryInterface(Ci.nsIWebNavigation);
let sessionHistory = webNav.sessionHistory;
let wantRemoteType = this.getRemoteTypeForURIObject(
aURI,
true,
useRemoteSubframes,
remoteType,
webNav.currentURI
);
// If we are using DocumentChannel or remote subframes (fission), we
// can start the load in the current process, and then perform the
// switch later-on using the DocumentLoadListener mechanism.
if (documentChannelPermittedForURI(aURI)) {
return true;
}
if (
!aHasPostData &&
remoteType == WEB_REMOTE_TYPE &&
sessionHistory.count == 1 &&
webNav.currentURI.spec == "about:newtab"
) {
// This is possibly a preloaded browser and we're about to navigate away for
// the first time. On the child side there is no way to tell for sure if that
// is the case, so let's redirect this request to the parent to decide if a new
// process is needed. But we don't currently properly handle POST data in
// redirects (bug 1457520), so if there is POST data, don't return false here.
return false;
}
// Allow history load if loaded in this process before.
if (!Services.appinfo.sessionHistoryInParent) {
let requestedIndex = sessionHistory.legacySHistory.requestedIndex;
if (requestedIndex >= 0) {
this.log().debug("Checking history case\n");
if (
sessionHistory.legacySHistory.getEntryAtIndex(requestedIndex)
.loadedInThisProcess
) {
this.log().info("History entry loaded in this process");
return true;
}
// If not originally loaded in this process allow it if the URI would
// normally be allowed to load in this process by default.
this.log().debug(
`Checking remote type, got: ${remoteType} want: ${wantRemoteType}\n`
);
return remoteType == wantRemoteType;
}
}
// If the URI can be loaded in the current process then continue
return remoteType == wantRemoteType;
},
redirectLoad(
aDocShell,
aURI,
aReferrerInfo,
aTriggeringPrincipal,
aFlags,
aCsp
) {
const actor = aDocShell.domWindow.windowGlobalChild.getActor("BrowserTab");
let loadOptions = {
uri: aURI.spec,
flags: aFlags || Ci.nsIWebNavigation.LOAD_FLAGS_NONE,
referrerInfo: this.serializeReferrerInfo(aReferrerInfo),
triggeringPrincipal: this.serializePrincipal(
aTriggeringPrincipal ||
Services.scriptSecurityManager.createNullPrincipal({})
),
csp: aCsp ? this.serializeCSP(aCsp) : null,
};
// Retarget the load to the correct process
if (!Services.appinfo.sessionHistoryInParent) {
let sessionHistory = aDocShell.QueryInterface(Ci.nsIWebNavigation)
.sessionHistory;
actor.sendAsyncMessage("Browser:LoadURI", {
loadOptions,
historyIndex: sessionHistory.legacySHistory.requestedIndex,
});
} else {
// If we can't access legacySHistory, session history in the
// parent is enabled. Browser:LoadURI knows about this and will
// act accordingly.
actor.sendAsyncMessage("Browser:LoadURI", {
loadOptions,
});
}
return false;
},
wrapHandlingUserInput(aWindow, aIsHandling, aCallback) {
var handlingUserInput;
try {

Просмотреть файл

@ -386,16 +386,6 @@ NS_IMETHODIMP nsContentTreeOwner::ShouldLoadURI(
nsIDocShell* aDocShell, nsIURI* aURI, nsIReferrerInfo* aReferrerInfo,
bool aHasPostData, nsIPrincipal* aTriggeringPrincipal,
nsIContentSecurityPolicy* aCsp, bool* _retval) {
NS_ENSURE_STATE(mAppWindow);
nsCOMPtr<nsIXULBrowserWindow> xulBrowserWindow;
mAppWindow->GetXULBrowserWindow(getter_AddRefs(xulBrowserWindow));
if (xulBrowserWindow)
return xulBrowserWindow->ShouldLoadURI(aDocShell, aURI, aReferrerInfo,
aHasPostData, aTriggeringPrincipal,
aCsp, _retval);
*_retval = true;
return NS_OK;
}

Просмотреть файл

@ -42,31 +42,6 @@ interface nsIXULBrowserWindow : nsISupports
in Node linkNode,
in boolean isAppTab);
/**
* Determines whether a load should continue.
*
* @param aDocShell
* The docshell performing the load.
* @param aURI
* The URI being loaded.
* @param aReferrerInfo
* The referrerInfo of the load.
* @param aHasPostData
* True if the load which is being asked about has associated post data
* which would be discarded if the load was redirected across process
* boundaries.
* @param aTriggeringPrincipal
* The principal that initiated the load of aURI.
* @param aCsp
* The CSP to be used for that load. That is the CSP that e.g. upgrades
* the load to HTTPS in case upgrade-insecure-requests is set
*/
bool shouldLoadURI(in nsIDocShell aDocShell,
in nsIURI aURI,
in nsIReferrerInfo aReferrerInfo,
in boolean aHasPostData,
in nsIPrincipal aTriggeringPrincipal,
in nsIContentSecurityPolicy aCsp);
/**
* Show/hide a tooltip (when the user mouses over a link, say).
*/