Skip to content

Commit

Permalink
Backed out 5 changesets (bug 1597154) for causing browser-chrome fail…
Browse files Browse the repository at this point in the history
…ures in browser_UITour_showNewTab.js CLOSED TREE

Backed out changeset dc78c6d3d737 (bug 1597154)
Backed out changeset 6e82c600d52f (bug 1597154)
Backed out changeset 9857504c26e6 (bug 1597154)
Backed out changeset e8dccb59bf2a (bug 1597154)
Backed out changeset 3c34ca1e2079 (bug 1597154)
  • Loading branch information
nerli1 committed Feb 21, 2020
1 parent 76889b2 commit f6ff6b7
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 51 deletions.
11 changes: 4 additions & 7 deletions docshell/base/nsDocShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8981,10 +8981,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<nsIWebBrowserChrome3> browserChrome3 = do_GetInterface(mTreeOwner);
if (browserChrome3 && !aLoadState->GetPendingRedirectedChannel()) {
if (browserChrome3) {
bool shouldLoad;
rv = browserChrome3->ShouldLoadURI(
this, aLoadState->URI(), aLoadState->GetReferrerInfo(),
Expand Down Expand Up @@ -9361,9 +9360,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;
}
Expand Down Expand Up @@ -9895,7 +9892,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) {
Expand Down
75 changes: 31 additions & 44 deletions toolkit/modules/E10SUtils.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -270,18 +256,14 @@ function validatedWebRemoteType(

if (
allowLinkedWebInFileUriProcess &&
// This is not supported with documentchannel and will go away in
// Bug 1603007
// This is not supported with documentchannel
!documentChannel &&
aPreferredRemoteType == FILE_REMOTE_TYPE
) {
// If aCurrentUri is passed then we should only allow FILE_REMOTE_TYPE
// when it is same origin as target or the current URI is already a
// file:// URI.
if (aCurrentUri) {
if (aCurrentUri.scheme == "file" || aCurrentUri.spec == "about:blank") {
return FILE_REMOTE_TYPE;
}
try {
// checkSameOriginURI throws when not same origin.
// todo: if you intend to update CheckSameOriginURI to log the error to the
Expand Down Expand Up @@ -740,10 +722,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;
}
Expand Down Expand Up @@ -805,6 +786,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,
Expand All @@ -821,14 +816,6 @@ var E10SUtils = {
return false;
}

let wantRemoteType = this.getRemoteTypeForURIObject(
aURI,
true,
useRemoteSubframes,
Services.appinfo.remoteType,
webNav.currentURI
);

// Allow history load if loaded in this process before.
let requestedIndex = sessionHistory.legacySHistory.requestedIndex;
if (requestedIndex >= 0) {
Expand All @@ -839,23 +826,23 @@ var E10SUtils = {
return true;
}

return Services.appinfo.remoteType == wantRemoteType;
}

// 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.
if (
(useRemoteSubframes || documentChannel) &&
Services.appinfo.remoteType != NOT_REMOTE &&
wantRemoteType != NOT_REMOTE &&
documentChannelPermittedForURI(aURI)
) {
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.
let remoteType = Services.appinfo.remoteType;
return (
remoteType ==
this.getRemoteTypeForURIObject(
aURI,
true,
useRemoteSubframes,
remoteType,
webNav.currentURI
)
);
}

// If the URI can be loaded in the current process then continue
return Services.appinfo.remoteType == wantRemoteType;
return this.shouldLoadURIInThisProcess(aURI, useRemoteSubframes);
},

redirectLoad(
Expand Down
1 change: 1 addition & 0 deletions uriloader/exthandler/tests/mochitest/browser.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ support-files =
file_with[funny_name.webm
file_with[funny_name.webm^headers^
[browser_protocolhandler_loop.js]
skip-if = fission # Bug 1597154
[browser_remember_download_option.js]
[browser_web_protocol_handlers.js]

0 comments on commit f6ff6b7

Please sign in to comment.