Backed out changeset 724cb235ebec (bug 1783504) for crashes on crash stats on Android Nightly

This commit is contained in:
Sandor Molnar
2023-11-15 14:46:45 +02:00
parent dd2deb8736
commit 2646858129
4 changed files with 11 additions and 92 deletions

View File

@@ -8743,9 +8743,7 @@ bool nsDocShell::IsSameDocumentNavigation(nsDocShellLoadState* aLoadState,
}
nsresult nsDocShell::HandleSameDocumentNavigation(
nsDocShellLoadState* aLoadState, SameDocumentNavigationState& aState,
bool& aSameDocument) {
aSameDocument = true;
nsDocShellLoadState* aLoadState, SameDocumentNavigationState& aState) {
#ifdef DEBUG
SameDocumentNavigationState state;
MOZ_ASSERT(IsSameDocumentNavigation(aLoadState, state));
@@ -8770,37 +8768,6 @@ nsresult nsDocShell::HandleSameDocumentNavigation(
("Upgraded URI to %s", newURI->GetSpecOrDefault().get()));
}
// check if aLoadState->URI(), principalURI, mCurrentURI are same origin
// skip handling otherwise
nsCOMPtr<nsIPrincipal> origPrincipal = doc->NodePrincipal();
nsCOMPtr<nsIURI> principalURI = origPrincipal->GetURI();
if (origPrincipal->GetIsNullPrincipal()) {
nsCOMPtr<nsIPrincipal> precursor = origPrincipal->GetPrecursorPrincipal();
if (precursor) {
principalURI = precursor->GetURI();
}
auto isLoadableViaInternet = [](nsIURI* uri) {
return (uri && (net::SchemeIsHTTP(uri) || net::SchemeIsHTTPS(uri)));
};
if (isLoadableViaInternet(principalURI) &&
isLoadableViaInternet(mCurrentURI) && isLoadableViaInternet(newURI)) {
nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
if (!NS_SUCCEEDED(
ssm->CheckSameOriginURI(newURI, principalURI, false, false)) ||
!NS_SUCCEEDED(ssm->CheckSameOriginURI(mCurrentURI, principalURI,
false, false))) {
MOZ_LOG(gSHLog, LogLevel::Debug,
("nsDocShell[%p]: possible violation of the same origin policy "
"during same document navigation",
this));
aSameDocument = false;
return NS_OK;
}
}
}
#ifdef DEBUG
if (aState.mSameExceptHashes) {
bool sameExceptHashes = false;
@@ -9397,15 +9364,13 @@ nsresult nsDocShell::InternalLoad(nsDocShellLoadState* aLoadState,
// document. If the process fails, or if we successfully navigate within the
// same document, return.
if (sameDocument) {
nsresult rv = HandleSameDocumentNavigation(
aLoadState, sameDocumentNavigationState, sameDocument);
nsresult rv =
HandleSameDocumentNavigation(aLoadState, sameDocumentNavigationState);
NS_ENSURE_SUCCESS(rv, rv);
if (shouldTakeFocus) {
mBrowsingContext->Focus(CallerType::System, IgnoreErrors());
}
if (sameDocument) {
return rv;
}
return rv;
}
// mContentViewer->PermitUnload can destroy |this| docShell, which