зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 724cb235ebec (bug 1783504) for crashes on crash stats on Android Nightly
This commit is contained in:
Родитель
5d51c81f0e
Коммит
bb5a11d7f2
|
@ -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
|
||||
|
|
|
@ -1060,8 +1060,7 @@ class nsDocShell final : public nsDocLoader,
|
|||
// continuing with new document navigation.
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
nsresult HandleSameDocumentNavigation(nsDocShellLoadState* aLoadState,
|
||||
SameDocumentNavigationState& aState,
|
||||
bool& aSameDocument);
|
||||
SameDocumentNavigationState& aState);
|
||||
|
||||
uint32_t GetSameDocumentNavigationFlags(nsIURI* aNewURI);
|
||||
|
||||
|
|
|
@ -58,8 +58,6 @@
|
|||
#include "nsISharePicker.h"
|
||||
#include "nsIURIMutator.h"
|
||||
#include "nsIWebProgressListener.h"
|
||||
#include "nsScriptSecurityManager.h"
|
||||
#include "nsIOService.h"
|
||||
|
||||
#include "mozilla/dom/DOMException.h"
|
||||
#include "mozilla/dom/DOMExceptionBinding.h"
|
||||
|
@ -92,6 +90,7 @@ WindowGlobalParent::WindowGlobalParent(
|
|||
uint64_t aOuterWindowId, FieldValues&& aInit)
|
||||
: WindowContext(aBrowsingContext, aInnerWindowId, aOuterWindowId,
|
||||
std::move(aInit)),
|
||||
mIsInitialDocument(false),
|
||||
mSandboxFlags(0),
|
||||
mDocumentHasLoaded(false),
|
||||
mDocumentHasUserInteracted(false),
|
||||
|
@ -118,7 +117,7 @@ already_AddRefed<WindowGlobalParent> WindowGlobalParent::CreateDisconnected(
|
|||
aInit.context().mOuterWindowId, std::move(fields));
|
||||
wgp->mDocumentPrincipal = aInit.principal();
|
||||
wgp->mDocumentURI = aInit.documentURI();
|
||||
wgp->mIsInitialDocument = Some(aInit.isInitialDocument());
|
||||
wgp->mIsInitialDocument = aInit.isInitialDocument();
|
||||
wgp->mBlockAllMixedContent = aInit.blockAllMixedContent();
|
||||
wgp->mUpgradeInsecureRequests = aInit.upgradeInsecureRequests();
|
||||
wgp->mSandboxFlags = aInit.sandboxFlags();
|
||||
|
@ -381,44 +380,7 @@ mozilla::ipc::IPCResult WindowGlobalParent::RecvInternalLoad(
|
|||
|
||||
IPCResult WindowGlobalParent::RecvUpdateDocumentURI(nsIURI* aURI) {
|
||||
// XXX(nika): Assert that the URI change was one which makes sense (either
|
||||
// about:blank -> a real URI, or a legal push/popstate URI change):
|
||||
nsAutoCString scheme;
|
||||
if (NS_FAILED(aURI->GetScheme(scheme))) {
|
||||
return IPC_FAIL(this, "Setting DocumentURI without scheme.");
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIIOService> ios = do_GetIOService();
|
||||
if (!ios) {
|
||||
return IPC_FAIL(this, "Cannot get IOService");
|
||||
}
|
||||
nsCOMPtr<nsIProtocolHandler> handler;
|
||||
ios->GetProtocolHandler(scheme.get(), getter_AddRefs(handler));
|
||||
if (!handler) {
|
||||
return IPC_FAIL(this, "Setting DocumentURI with unknown protocol.");
|
||||
}
|
||||
|
||||
auto isLoadableViaInternet = [](nsIURI* uri) {
|
||||
return (uri && (net::SchemeIsHTTP(uri) || net::SchemeIsHTTPS(uri)));
|
||||
};
|
||||
|
||||
if (isLoadableViaInternet(aURI)) {
|
||||
nsCOMPtr<nsIURI> principalURI = mDocumentPrincipal->GetURI();
|
||||
if (mDocumentPrincipal->GetIsNullPrincipal()) {
|
||||
nsCOMPtr<nsIPrincipal> precursor =
|
||||
mDocumentPrincipal->GetPrecursorPrincipal();
|
||||
if (precursor) {
|
||||
principalURI = precursor->GetURI();
|
||||
}
|
||||
}
|
||||
|
||||
if (isLoadableViaInternet(principalURI) &&
|
||||
!nsScriptSecurityManager::SecurityCompareURIs(principalURI, aURI)) {
|
||||
return IPC_FAIL(this,
|
||||
"Setting DocumentURI with a different Origin than "
|
||||
"principal URI");
|
||||
}
|
||||
}
|
||||
|
||||
// about:blank -> a real URI, or a legal push/popstate URI change?)
|
||||
mDocumentURI = aURI;
|
||||
return IPC_OK();
|
||||
}
|
||||
|
|
|
@ -151,9 +151,7 @@ class WindowGlobalParent final : public WindowContext,
|
|||
|
||||
void GetContentBlockingLog(nsAString& aLog);
|
||||
|
||||
bool IsInitialDocument() {
|
||||
return mIsInitialDocument.isSome() && mIsInitialDocument.value();
|
||||
}
|
||||
bool IsInitialDocument() { return mIsInitialDocument; }
|
||||
|
||||
already_AddRefed<mozilla::dom::Promise> PermitUnload(
|
||||
PermitUnloadAction aAction, uint32_t aTimeout, mozilla::ErrorResult& aRv);
|
||||
|
@ -257,12 +255,7 @@ class WindowGlobalParent final : public WindowContext,
|
|||
mozilla::ipc::IPCResult RecvUpdateDocumentTitle(const nsString& aTitle);
|
||||
mozilla::ipc::IPCResult RecvUpdateHttpsOnlyStatus(uint32_t aHttpsOnlyStatus);
|
||||
mozilla::ipc::IPCResult RecvSetIsInitialDocument(bool aIsInitialDocument) {
|
||||
if (aIsInitialDocument && mIsInitialDocument.isSome() &&
|
||||
(mIsInitialDocument.value() != aIsInitialDocument)) {
|
||||
return IPC_FAIL_NO_REASON(this);
|
||||
}
|
||||
|
||||
mIsInitialDocument = Some(aIsInitialDocument);
|
||||
mIsInitialDocument = aIsInitialDocument;
|
||||
return IPC_OK();
|
||||
}
|
||||
mozilla::ipc::IPCResult RecvUpdateDocumentSecurityInfo(
|
||||
|
@ -354,7 +347,7 @@ class WindowGlobalParent final : public WindowContext,
|
|||
nsCOMPtr<nsIURI> mDocumentURI;
|
||||
Maybe<nsString> mDocumentTitle;
|
||||
|
||||
Maybe<bool> mIsInitialDocument;
|
||||
bool mIsInitialDocument;
|
||||
|
||||
// True if this window has a "beforeunload" event listener.
|
||||
bool mHasBeforeUnload;
|
||||
|
|
Загрузка…
Ссылка в новой задаче