Bug 1637869 - P2. Allow ParentProcessDocumentChannel to perform process switching. r=nika,mattwoodrow
The moves all decisions to perform a process switch into the DocumentLoadListerner. This removes the unnecessary need to go via a content process to start the load. Differential Revision: https://phabricator.services.mozilla.com/D76315
This commit is contained in:
@@ -8755,48 +8755,12 @@ nsresult nsDocShell::InternalLoad(nsDocShellLoadState* aLoadState,
|
||||
|
||||
// In e10s, in the parent process, we refuse to load anything other than
|
||||
// "safe" resources that we ship or trust enough to give "special" URLs.
|
||||
if (XRE_IsE10sParentProcess()) {
|
||||
nsCOMPtr<nsIURI> uri = aLoadState->URI();
|
||||
do {
|
||||
bool canLoadInParent = false;
|
||||
if (NS_SUCCEEDED(NS_URIChainHasFlags(
|
||||
uri, nsIProtocolHandler::URI_IS_UI_RESOURCE, &canLoadInParent)) &&
|
||||
canLoadInParent) {
|
||||
// We allow UI resources.
|
||||
break;
|
||||
}
|
||||
// For about: and extension-based URIs, which don't get
|
||||
// URI_IS_UI_RESOURCE, first remove layers of view-source:, if present.
|
||||
while (uri && uri->SchemeIs("view-source")) {
|
||||
nsCOMPtr<nsINestedURI> nested = do_QueryInterface(uri);
|
||||
if (nested) {
|
||||
nested->GetInnerURI(getter_AddRefs(uri));
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Allow about: URIs, and allow moz-extension ones if we're running
|
||||
// extension content in the parent process.
|
||||
if (!uri || uri->SchemeIs("about") ||
|
||||
(!StaticPrefs::extensions_webextensions_remote() &&
|
||||
uri->SchemeIs("moz-extension"))) {
|
||||
break;
|
||||
}
|
||||
nsAutoCString scheme;
|
||||
uri->GetScheme(scheme);
|
||||
// Allow ext+foo URIs (extension-registered custom protocols). See
|
||||
// https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/protocol_handlers
|
||||
if (StringBeginsWith(scheme, NS_LITERAL_CSTRING("ext+")) &&
|
||||
!StaticPrefs::extensions_webextensions_remote()) {
|
||||
break;
|
||||
}
|
||||
// Final exception for some legacy automated tests:
|
||||
if (xpc::IsInAutomation() &&
|
||||
Preferences::GetBool("security.allow_unsafe_parent_loads", false)) {
|
||||
break;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
} while (0);
|
||||
// Similar check will be performed by the ParentProcessDocumentChannel if in
|
||||
// use.
|
||||
if (XRE_IsE10sParentProcess() &&
|
||||
!DocumentChannel::CanUseDocumentChannel(aLoadState) &&
|
||||
!CanLoadInParentProcess(aLoadState->URI())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Whenever a top-level browsing context is navigated, the user agent MUST
|
||||
@@ -8957,6 +8921,51 @@ nsresult nsDocShell::InternalLoad(nsDocShellLoadState* aLoadState,
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool nsDocShell::CanLoadInParentProcess(nsIURI* aURI) {
|
||||
nsCOMPtr<nsIURI> uri = aURI;
|
||||
// In e10s, in the parent process, we refuse to load anything other than
|
||||
// "safe" resources that we ship or trust enough to give "special" URLs.
|
||||
bool canLoadInParent = false;
|
||||
if (NS_SUCCEEDED(NS_URIChainHasFlags(
|
||||
uri, nsIProtocolHandler::URI_IS_UI_RESOURCE, &canLoadInParent)) &&
|
||||
canLoadInParent) {
|
||||
// We allow UI resources.
|
||||
return true;
|
||||
}
|
||||
// For about: and extension-based URIs, which don't get
|
||||
// URI_IS_UI_RESOURCE, first remove layers of view-source:, if present.
|
||||
while (uri && uri->SchemeIs("view-source")) {
|
||||
nsCOMPtr<nsINestedURI> nested = do_QueryInterface(uri);
|
||||
if (nested) {
|
||||
nested->GetInnerURI(getter_AddRefs(uri));
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Allow about: URIs, and allow moz-extension ones if we're running
|
||||
// extension content in the parent process.
|
||||
if (!uri || uri->SchemeIs("about") ||
|
||||
(!StaticPrefs::extensions_webextensions_remote() &&
|
||||
uri->SchemeIs("moz-extension"))) {
|
||||
return true;
|
||||
}
|
||||
nsAutoCString scheme;
|
||||
uri->GetScheme(scheme);
|
||||
// Allow ext+foo URIs (extension-registered custom protocols). See
|
||||
// https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/protocol_handlers
|
||||
if (StringBeginsWith(scheme, NS_LITERAL_CSTRING("ext+")) &&
|
||||
!StaticPrefs::extensions_webextensions_remote()) {
|
||||
return true;
|
||||
}
|
||||
// Final exception for some legacy automated tests:
|
||||
if (xpc::IsInAutomation() &&
|
||||
Preferences::GetBool("security.allow_unsafe_parent_loads", false)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
nsIPrincipal* nsDocShell::GetInheritedPrincipal(
|
||||
bool aConsiderCurrentDocument, bool aConsiderStoragePrincipal) {
|
||||
RefPtr<Document> document;
|
||||
|
||||
Reference in New Issue
Block a user