diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 7b9487c30215..40827243c024 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -8994,10 +8994,9 @@ nsresult nsDocShell::InternalLoad(nsDocShellLoadState* aLoadState, } // Check if the webbrowser chrome wants the load to proceed; this can be - // used to cancel attempts to load URIs in the wrong process. use - // GetPendingRedirectedChannel() to avoid revisiting a redirect decision. + // used to cancel attempts to load URIs in the wrong process. nsCOMPtr browserChrome3 = do_GetInterface(mTreeOwner); - if (browserChrome3 && !aLoadState->GetPendingRedirectedChannel()) { + if (browserChrome3) { bool shouldLoad; rv = browserChrome3->ShouldLoadURI( this, aLoadState->URI(), aLoadState->GetReferrerInfo(), @@ -9374,9 +9373,7 @@ static bool IsConsideredSameOriginForUIR(nsIPrincipal* aTriggeringPrincipal, return NS_OK; } -// Changes here should also be made in -// E10SUtils.documentChannelPermittedForURI(). -static bool URIUsesDocChannel(nsIURI* aURI) { +static bool SchemeUsesDocChannel(nsIURI* aURI) { if (SchemeIsJavascript(aURI) || NS_IsAboutBlank(aURI)) { return false; } @@ -9985,7 +9982,7 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState, bool canUseDocumentChannel = aLoadState->HasLoadFlags(INTERNAL_LOAD_FLAGS_IS_SRCDOC) ? (sandboxFlags & SANDBOXED_ORIGIN) - : URIUsesDocChannel(aLoadState->URI()); + : SchemeUsesDocChannel(aLoadState->URI()); if (StaticPrefs::browser_tabs_documentchannel() && XRE_IsContentProcess() && canUseDocumentChannel) { diff --git a/toolkit/modules/E10SUtils.jsm b/toolkit/modules/E10SUtils.jsm index c51e8cd309fb..3475d5cd8717 100644 --- a/toolkit/modules/E10SUtils.jsm +++ b/toolkit/modules/E10SUtils.jsm @@ -137,21 +137,7 @@ const kSafeSchemes = [ "xmpp", ]; -const kDocumentChannelDeniedSchemes = ["javascript"]; -const kDocumentChannelDeniedURIs = [ - "about:blank", - "about:printpreview", - "about:privatebrowsing", - "about:crashcontent", -]; - -// Changes here should also be made in URIUsesDocChannel in nsDocShell.cpp. -function documentChannelPermittedForURI(aURI) { - return ( - !kDocumentChannelDeniedSchemes.includes(aURI.scheme) && - !kDocumentChannelDeniedURIs.includes(aURI.spec) - ); -} +const kDocumentChannelAllowedSchemes = ["http", "https", "ftp", "data"]; // Note that even if the scheme fits the criteria for a web-handled scheme // (ie it is compatible with the checks registerProtocolHandler uses), it may @@ -738,10 +724,9 @@ var E10SUtils = { // for now, and let DocumentChannel do it during the response. if ( currentRemoteType != NOT_REMOTE && - requiredRemoteType != NOT_REMOTE && uriObject && (remoteSubframes || documentChannel) && - documentChannelPermittedForURI(uriObject) + kDocumentChannelAllowedSchemes.includes(uriObject.scheme) ) { mustChangeProcess = false; } @@ -803,6 +788,20 @@ var E10SUtils = { return false; } + // If we are performing HTTP response process selection, and are loading an + // HTTP URI, we can start the load in the current process, and then perform + // the switch later-on using the RedirectProcessChooser mechanism. + // + // We should never be sending a POST request from the parent process to a + // http(s) uri, so make sure we switch if we're currently in that process. + if ( + Services.appinfo.remoteType != NOT_REMOTE && + (useRemoteSubframes || documentChannel) && + kDocumentChannelAllowedSchemes.includes(aURI.scheme) + ) { + return true; + } + // If we are in a Large-Allocation process, and it wouldn't be content visible // to change processes, we want to load into a new process so that we can throw // this one out. We don't want to move into a new process if we have post data, @@ -844,25 +843,6 @@ var E10SUtils = { ); } - // 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 nsIProcessSwitchRequestor mechanism. - let wantRemoteType = this.getRemoteTypeForURIObject( - aURI, - true, - useRemoteSubframes, - Services.appinfo.remoteType, - webNav.currentURI - ); - if ( - (useRemoteSubframes || documentChannel) && - Services.appinfo.remoteType != NOT_REMOTE && - wantRemoteType != NOT_REMOTE && - documentChannelPermittedForURI(aURI) - ) { - return true; - } - // If the URI can be loaded in the current process then continue return this.shouldLoadURIInThisProcess(aURI, useRemoteSubframes); }, diff --git a/uriloader/exthandler/tests/mochitest/browser.ini b/uriloader/exthandler/tests/mochitest/browser.ini index 98c49736cbc0..1828fee560d6 100644 --- a/uriloader/exthandler/tests/mochitest/browser.ini +++ b/uriloader/exthandler/tests/mochitest/browser.ini @@ -12,5 +12,6 @@ support-files = [browser_download_always_ask_preferred_app.js] [browser_download_privatebrowsing.js] [browser_protocolhandler_loop.js] +skip-if = fission # Bug 1597154 [browser_remember_download_option.js] [browser_web_protocol_handlers.js]