diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
commit | da4c7e7ed675c3bf405668739c3012d140856109 (patch) | |
tree | cdd868dba063fecba609a1d819de271f0d51b23e /dom/ipc/WindowGlobalChild.cpp | |
parent | Adding upstream version 125.0.3. (diff) | |
download | firefox-da4c7e7ed675c3bf405668739c3012d140856109.tar.xz firefox-da4c7e7ed675c3bf405668739c3012d140856109.zip |
Adding upstream version 126.0.upstream/126.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/ipc/WindowGlobalChild.cpp')
-rw-r--r-- | dom/ipc/WindowGlobalChild.cpp | 35 |
1 files changed, 12 insertions, 23 deletions
diff --git a/dom/ipc/WindowGlobalChild.cpp b/dom/ipc/WindowGlobalChild.cpp index ec2811f972..4072828911 100644 --- a/dom/ipc/WindowGlobalChild.cpp +++ b/dom/ipc/WindowGlobalChild.cpp @@ -35,7 +35,7 @@ #include "nsQueryObject.h" #include "nsSerializationHelper.h" #include "nsFrameLoader.h" -#include "nsIScriptSecurityManager.h" +#include "nsScriptSecurityManager.h" #include "mozilla/dom/JSWindowActorBinding.h" #include "mozilla/dom/JSWindowActorChild.h" @@ -588,30 +588,19 @@ void WindowGlobalChild::SetDocumentURI(nsIURI* aDocumentURI) { embedderInnerWindowID, BrowsingContext()->UsePrivateBrowsing()); if (StaticPrefs::dom_security_setdocumenturi()) { - auto isLoadableViaInternet = [](nsIURI* uri) { - return (uri && (net::SchemeIsHTTP(uri) || net::SchemeIsHTTPS(uri))); - }; - if (isLoadableViaInternet(aDocumentURI)) { - nsCOMPtr<nsIURI> principalURI = mDocumentPrincipal->GetURI(); - if (mDocumentPrincipal->GetIsNullPrincipal()) { - nsCOMPtr<nsIPrincipal> precursor = - mDocumentPrincipal->GetPrecursorPrincipal(); - if (precursor) { - principalURI = precursor->GetURI(); - } - } - - if (isLoadableViaInternet(principalURI)) { - nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager(); - - if (!NS_SUCCEEDED(ssm->CheckSameOriginURI(principalURI, aDocumentURI, - false, false))) { - MOZ_DIAGNOSTIC_ASSERT(false, - "Setting DocumentURI with a different origin " - "than principal URI"); - } + nsCOMPtr<nsIURI> principalURI = mDocumentPrincipal->GetURI(); + if (mDocumentPrincipal->GetIsNullPrincipal()) { + nsCOMPtr<nsIPrincipal> precursor = + mDocumentPrincipal->GetPrecursorPrincipal(); + if (precursor) { + principalURI = precursor->GetURI(); } } + + MOZ_DIAGNOSTIC_ASSERT(!nsScriptSecurityManager::IsHttpOrHttpsAndCrossOrigin( + principalURI, aDocumentURI), + "Setting DocumentURI with a different origin " + "than principal URI"); } mDocumentURI = aDocumentURI; |