Backed out changeset a364609f354a (bug 1783504) for causing Bug 1832321. a=backout

This commit is contained in:
Iulian Moraru 2023-05-11 12:44:23 +03:00
parent ee6ab6eb2d
commit 1d434c7d1b
2 changed files with 6 additions and 51 deletions

View File

@ -54,7 +54,6 @@
#include "nsITransportSecurityInfo.h"
#include "nsISharePicker.h"
#include "nsIURIMutator.h"
#include "nsScriptSecurityManager.h"
#include "mozilla/dom/DOMException.h"
#include "mozilla/dom/DOMExceptionBinding.h"
@ -66,7 +65,6 @@
#include "SessionStoreFunctions.h"
#include "nsIXPConnect.h"
#include "nsImportModule.h"
#include "nsIOService.h"
#include "mozilla/dom/PBackgroundSessionStorageCache.h"
@ -83,6 +81,7 @@ WindowGlobalParent::WindowGlobalParent(
uint64_t aOuterWindowId, FieldValues&& aInit)
: WindowContext(aBrowsingContext, aInnerWindowId, aOuterWindowId,
std::move(aInit)),
mIsInitialDocument(false),
mSandboxFlags(0),
mDocumentHasLoaded(false),
mDocumentHasUserInteracted(false),
@ -109,7 +108,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();
@ -372,44 +371,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.");
}
nsIIOService* ios = nsContentUtils::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();
}

View File

@ -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);
@ -254,12 +252,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(
@ -344,7 +337,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;