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 /docshell/base/nsDocShell.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 'docshell/base/nsDocShell.cpp')
-rw-r--r-- | docshell/base/nsDocShell.cpp | 67 |
1 files changed, 13 insertions, 54 deletions
diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 3404597343..87a34cf5b2 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -144,6 +144,7 @@ #include "nsIScriptChannel.h" #include "nsIScriptObjectPrincipal.h" #include "nsIScriptSecurityManager.h" +#include "nsScriptSecurityManager.h" #include "nsIScrollableFrame.h" #include "nsIScrollObserver.h" #include "nsISupportsPrimitives.h" @@ -332,7 +333,6 @@ nsDocShell::nsDocShell(BrowsingContext* aBrowsingContext, mAppType(nsIDocShell::APP_TYPE_UNKNOWN), mLoadType(0), mFailedLoadType(0), - mMetaViewportOverride(nsIDocShell::META_VIEWPORT_OVERRIDE_NONE), mChannelToDisconnectOnPageHide(0), mCreatingDocument(false), #ifdef DEBUG @@ -2376,37 +2376,6 @@ nsDocShell::ClearCachedUserAgent() { return NS_OK; } -NS_IMETHODIMP -nsDocShell::GetMetaViewportOverride( - MetaViewportOverride* aMetaViewportOverride) { - NS_ENSURE_ARG_POINTER(aMetaViewportOverride); - - *aMetaViewportOverride = mMetaViewportOverride; - return NS_OK; -} - -NS_IMETHODIMP -nsDocShell::SetMetaViewportOverride( - MetaViewportOverride aMetaViewportOverride) { - // We don't have a way to verify this coming from Javascript, so this check is - // still needed. - if (!(aMetaViewportOverride == META_VIEWPORT_OVERRIDE_NONE || - aMetaViewportOverride == META_VIEWPORT_OVERRIDE_ENABLED || - aMetaViewportOverride == META_VIEWPORT_OVERRIDE_DISABLED)) { - return NS_ERROR_INVALID_ARG; - } - - mMetaViewportOverride = aMetaViewportOverride; - - // Inform our presShell that it needs to re-check its need for a viewport - // override. - if (RefPtr<PresShell> presShell = GetPresShell()) { - presShell->MaybeRecreateMobileViewportManager(true); - } - - return NS_OK; -} - /* virtual */ int32_t nsDocShell::ItemType() { return mItemType; } @@ -2586,10 +2555,6 @@ nsresult nsDocShell::SetDocLoaderParent(nsDocLoader* aParent) { value = false; } SetAllowDNSPrefetch(mAllowDNSPrefetch && value); - - // We don't need to inherit metaViewportOverride, because the viewport - // is only relevant for the outermost nsDocShell, not for any iframes - // like this that might be embedded within it. } nsCOMPtr<nsIURIContentListener> parentURIListener(do_GetInterface(parent)); @@ -8689,24 +8654,18 @@ nsresult nsDocShell::HandleSameDocumentNavigation( } } - 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; - } + if (nsScriptSecurityManager::IsHttpOrHttpsAndCrossOrigin(principalURI, + newURI) || + nsScriptSecurityManager::IsHttpOrHttpsAndCrossOrigin(principalURI, + mCurrentURI) || + nsScriptSecurityManager::IsHttpOrHttpsAndCrossOrigin(mCurrentURI, + newURI)) { + aSameDocument = false; + MOZ_LOG(gSHLog, LogLevel::Debug, + ("nsDocShell[%p]: possible violation of the same origin policy " + "during same document navigation", + this)); + return NS_OK; } } |