diff options
-rw-r--r-- | docshell/base/nsDocShell.cpp | 28 | ||||
-rw-r--r-- | docshell/base/nsDocShell.h | 1 | ||||
-rw-r--r-- | docshell/base/nsDocShellLoadInfo.cpp | 17 | ||||
-rw-r--r-- | docshell/base/nsDocShellLoadInfo.h | 4 | ||||
-rw-r--r-- | docshell/base/nsIDocShell.idl | 5 | ||||
-rw-r--r-- | docshell/base/nsIDocShellLoadInfo.idl | 6 | ||||
-rw-r--r-- | dom/base/nsFrameLoader.cpp | 3 | ||||
-rw-r--r-- | ipc/glue/BackgroundUtils.cpp | 13 | ||||
-rw-r--r-- | netwerk/base/LoadInfo.cpp | 18 | ||||
-rw-r--r-- | netwerk/base/LoadInfo.h | 6 | ||||
-rw-r--r-- | netwerk/base/nsILoadInfo.idl | 7 | ||||
-rw-r--r-- | netwerk/ipc/NeckoChannelParams.ipdlh | 1 | ||||
-rw-r--r-- | netwerk/protocol/http/HttpBaseChannel.cpp | 11 |
13 files changed, 108 insertions, 12 deletions
diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index ae307431d..e6fa5a200 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -1263,6 +1263,7 @@ nsDocShell::LoadURI(nsIURI* aURI, nsCOMPtr<nsIURI> referrer; nsCOMPtr<nsIURI> originalURI; bool loadReplace = false; + bool isFromProcessingFrameAttributes = false; nsCOMPtr<nsIInputStream> postStream; nsCOMPtr<nsIInputStream> headersStream; nsCOMPtr<nsIPrincipal> triggeringPrincipal; @@ -1292,6 +1293,7 @@ nsDocShell::LoadURI(nsIURI* aURI, aLoadInfo->GetReferrer(getter_AddRefs(referrer)); aLoadInfo->GetOriginalURI(getter_AddRefs(originalURI)); aLoadInfo->GetLoadReplace(&loadReplace); + aLoadInfo->GetIsFromProcessingFrameAttributes(&isFromProcessingFrameAttributes); nsDocShellInfoLoadType lt = nsIDocShellLoadInfo::loadNormal; aLoadInfo->GetLoadType(<); // Get the appropriate loadType from nsIDocShellLoadInfo type @@ -1571,6 +1573,7 @@ nsDocShell::LoadURI(nsIURI* aURI, return InternalLoad(aURI, originalURI, loadReplace, + isFromProcessingFrameAttributes, referrer, referrerPolicy, triggeringPrincipal, @@ -5340,8 +5343,8 @@ nsDocShell::LoadErrorPage(nsIURI* aURI, const char16_t* aURL, rv = NS_NewURI(getter_AddRefs(errorPageURI), errorPageUrl); NS_ENSURE_SUCCESS(rv, rv); - return InternalLoad(errorPageURI, nullptr, false, nullptr, - mozilla::net::RP_Default, + return InternalLoad(errorPageURI, nullptr, false, false, + nullptr, mozilla::net::RP_Default, nsContentUtils::GetSystemPrincipal(), nullptr, INTERNAL_LOAD_FLAGS_NONE, EmptyString(), nullptr, NullString(), nullptr, nullptr, LOAD_ERROR_PAGE, @@ -5427,6 +5430,7 @@ nsDocShell::Reload(uint32_t aReloadFlags) rv = InternalLoad(currentURI, originalURI, loadReplace, + false, // Is from processing frame attributes referrerURI, referrerPolicy, triggeringPrincipal, @@ -9578,6 +9582,7 @@ class InternalLoadEvent : public Runnable public: InternalLoadEvent(nsDocShell* aDocShell, nsIURI* aURI, nsIURI* aOriginalURI, bool aLoadReplace, + bool aIsFromProcessingFrameAttributes, nsIURI* aReferrer, uint32_t aReferrerPolicy, nsIPrincipal* aTriggeringPrincipal, nsIPrincipal* aPrincipalToInherit, uint32_t aFlags, @@ -9591,6 +9596,7 @@ public: , mURI(aURI) , mOriginalURI(aOriginalURI) , mLoadReplace(aLoadReplace) + , mIsFromProcessingFrameAttributes(aIsFromProcessingFrameAttributes) , mReferrer(aReferrer) , mReferrerPolicy(aReferrerPolicy) , mTriggeringPrincipal(aTriggeringPrincipal) @@ -9615,6 +9621,7 @@ public: { return mDocShell->InternalLoad(mURI, mOriginalURI, mLoadReplace, + mIsFromProcessingFrameAttributes, mReferrer, mReferrerPolicy, mTriggeringPrincipal, mPrincipalToInherit, @@ -9635,6 +9642,7 @@ private: nsCOMPtr<nsIURI> mURI; nsCOMPtr<nsIURI> mOriginalURI; bool mLoadReplace; + bool mIsFromProcessingFrameAttributes; nsCOMPtr<nsIURI> mReferrer; uint32_t mReferrerPolicy; nsCOMPtr<nsIPrincipal> mTriggeringPrincipal; @@ -9703,6 +9711,7 @@ NS_IMETHODIMP nsDocShell::InternalLoad(nsIURI* aURI, nsIURI* aOriginalURI, bool aLoadReplace, + bool aIsFromProcessingFrameAttributes, nsIURI* aReferrer, uint32_t aReferrerPolicy, nsIPrincipal* aTriggeringPrincipal, @@ -10005,6 +10014,7 @@ nsDocShell::InternalLoad(nsIURI* aURI, INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER)); loadInfo->SetOriginalURI(aOriginalURI); loadInfo->SetLoadReplace(aLoadReplace); + loadInfo->SetIsFromProcessingFrameAttributes(aIsFromProcessingFrameAttributes); loadInfo->SetTriggeringPrincipal(aTriggeringPrincipal); loadInfo->SetInheritPrincipal( aFlags & INTERNAL_LOAD_FLAGS_INHERIT_PRINCIPAL); @@ -10053,6 +10063,7 @@ nsDocShell::InternalLoad(nsIURI* aURI, rv = targetDocShell->InternalLoad(aURI, aOriginalURI, aLoadReplace, + aIsFromProcessingFrameAttributes, aReferrer, aReferrerPolicy, aTriggeringPrincipal, @@ -10135,6 +10146,7 @@ nsDocShell::InternalLoad(nsIURI* aURI, // Do this asynchronously nsCOMPtr<nsIRunnable> ev = new InternalLoadEvent(this, aURI, aOriginalURI, aLoadReplace, + aIsFromProcessingFrameAttributes, aReferrer, aReferrerPolicy, aTriggeringPrincipal, principalToInherit, aFlags, aTypeHint, aPostData, aHeadersData, @@ -10661,7 +10673,8 @@ nsDocShell::InternalLoad(nsIURI* aURI, nsINetworkPredictor::PREDICT_LOAD, this, nullptr); nsCOMPtr<nsIRequest> req; - rv = DoURILoad(aURI, aOriginalURI, aLoadReplace, loadFromExternal, + rv = DoURILoad(aURI, aOriginalURI, aLoadReplace, + aIsFromProcessingFrameAttributes, loadFromExternal, (aFlags & INTERNAL_LOAD_FLAGS_FORCE_ALLOW_DATA_URI), aReferrer, !(aFlags & INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER), @@ -10743,6 +10756,7 @@ nsresult nsDocShell::DoURILoad(nsIURI* aURI, nsIURI* aOriginalURI, bool aLoadReplace, + bool aIsFromProcessingFrameAttributes, bool aLoadFromExternal, bool aForceAllowDataURI, nsIURI* aReferrerURI, @@ -10903,7 +10917,7 @@ nsDocShell::DoURILoad(nsIURI* aURI, securityFlags |= nsILoadInfo::SEC_SANDBOXED; } - nsCOMPtr<nsILoadInfo> loadInfo = + RefPtr<LoadInfo> loadInfo = (aContentPolicyType == nsIContentPolicy::TYPE_DOCUMENT) ? new LoadInfo(loadingWindow, aTriggeringPrincipal, topLevelLoadingContext, securityFlags) : @@ -10929,6 +10943,10 @@ nsDocShell::DoURILoad(nsIURI* aURI, return rv; } + if (aIsFromProcessingFrameAttributes) { + loadInfo->SetIsFromProcessingFrameAttributes(); + } + if (!isSrcdoc) { rv = NS_NewChannelInternal(getter_AddRefs(channel), aURI, @@ -12581,6 +12599,7 @@ nsDocShell::LoadHistoryEntry(nsISHEntry* aEntry, uint32_t aLoadType) rv = InternalLoad(uri, originalURI, loadReplace, + false, // Is from processing frame attributes referrerURI, referrerPolicy, triggeringPrincipal, @@ -14084,6 +14103,7 @@ nsDocShell::OnLinkClickSync(nsIContent* aContent, nsresult rv = InternalLoad(clonedURI, // New URI nullptr, // Original URI false, // LoadReplace + false, // From frame attributes referer, // Referer URI refererPolicy, // Referer policy triggeringPrincipal, diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h index f510a15b0..8de3995fc 100644 --- a/docshell/base/nsDocShell.h +++ b/docshell/base/nsDocShell.h @@ -371,6 +371,7 @@ protected: nsresult DoURILoad(nsIURI* aURI, nsIURI* aOriginalURI, bool aLoadReplace, + bool aIsFromProcessingFrameAttributes, bool aLoadFromExternal, bool aForceAllowDataURI, nsIURI* aReferrer, diff --git a/docshell/base/nsDocShellLoadInfo.cpp b/docshell/base/nsDocShellLoadInfo.cpp index b00e8e360..b1a990267 100644 --- a/docshell/base/nsDocShellLoadInfo.cpp +++ b/docshell/base/nsDocShellLoadInfo.cpp @@ -20,6 +20,7 @@ nsDocShellLoadInfo::nsDocShellLoadInfo() , mReferrerPolicy(mozilla::net::RP_Default) , mLoadType(nsIDocShellLoadInfo::loadNormal) , mIsSrcdocLoad(false) + , mIsFromProcessingFrameAttributes(false) { } @@ -310,3 +311,19 @@ nsDocShellLoadInfo::SetBaseURI(nsIURI* aBaseURI) mBaseURI = aBaseURI; return NS_OK; } + +NS_IMETHODIMP +nsDocShellLoadInfo::GetIsFromProcessingFrameAttributes(bool* aIsFromProcessingFrameAttributes) +{ + NS_ENSURE_ARG_POINTER(aIsFromProcessingFrameAttributes); + + *aIsFromProcessingFrameAttributes = mIsFromProcessingFrameAttributes; + return NS_OK; +} + +NS_IMETHODIMP +nsDocShellLoadInfo::SetIsFromProcessingFrameAttributes(bool aIsFromProcessingFrameAttributes) +{ + mIsFromProcessingFrameAttributes = aIsFromProcessingFrameAttributes; + return NS_OK; +} diff --git a/docshell/base/nsDocShellLoadInfo.h b/docshell/base/nsDocShellLoadInfo.h index f3ddcca1e..09479683b 100644 --- a/docshell/base/nsDocShellLoadInfo.h +++ b/docshell/base/nsDocShellLoadInfo.h @@ -49,6 +49,10 @@ protected: nsString mSrcdocData; nsCOMPtr<nsIDocShell> mSourceDocShell; nsCOMPtr<nsIURI> mBaseURI; + + // This will be true if this load is triggered by attribute changes. + // See nsILoadInfo.isFromProcessingFrameAttributes + bool mIsFromProcessingFrameAttributes; }; #endif /* nsDocShellLoadInfo_h__ */ diff --git a/docshell/base/nsIDocShell.idl b/docshell/base/nsIDocShell.idl index e34e6adfd..d205e5b0c 100644 --- a/docshell/base/nsIDocShell.idl +++ b/docshell/base/nsIDocShell.idl @@ -133,6 +133,10 @@ interface nsIDocShell : nsIDocShellTreeItem * @param aLoadReplace - If set LOAD_REPLACE flag will be set on the * channel. aOriginalURI is null, this argument is * ignored. + * @param aIsFromProcessingFrameAttributes + * - If this is a load triggered by changing frame + * attributes. + * See nsILoadInfo.isFromProcessingFrameAttributes * @param aReferrer - Referring URI * @param aReferrerPolicy - Referrer policy * @param aTriggeringPrincipal - A non-null principal that initiated that load. @@ -178,6 +182,7 @@ interface nsIDocShell : nsIDocShellTreeItem [noscript]void internalLoad(in nsIURI aURI, in nsIURI aOriginalURI, in boolean aLoadReplace, + in boolean aIsFromProcessingFrameAttributes, in nsIURI aReferrer, in unsigned long aReferrerPolicy, in nsIPrincipal aTriggeringPrincipal, diff --git a/docshell/base/nsIDocShellLoadInfo.idl b/docshell/base/nsIDocShellLoadInfo.idl index 8804f63a3..2f52ef0aa 100644 --- a/docshell/base/nsIDocShellLoadInfo.idl +++ b/docshell/base/nsIDocShellLoadInfo.idl @@ -128,4 +128,10 @@ interface nsIDocShellLoadInfo : nsISupports * URI as this information isn't embedded in the load's URI. */ attribute nsIURI baseURI; + + /** + * This will be true if this load is triggered by attribute changes. + * See nsILoadInfo.isFromProcessingFrameAttributes + */ + attribute boolean isFromProcessingFrameAttributes; }; diff --git a/dom/base/nsFrameLoader.cpp b/dom/base/nsFrameLoader.cpp index 23067becd..2804f2d4c 100644 --- a/dom/base/nsFrameLoader.cpp +++ b/dom/base/nsFrameLoader.cpp @@ -588,6 +588,9 @@ nsFrameLoader::ReallyStartLoadingInternal() flags = nsIWebNavigation::LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP | nsIWebNavigation::LOAD_FLAGS_DISALLOW_INHERIT_PRINCIPAL; } + + // Notify that this load resulted from attribute changes. + loadInfo->SetIsFromProcessingFrameAttributes(true); // Kick off the load... bool tmpState = mNeedsAsyncDestroy; diff --git a/ipc/glue/BackgroundUtils.cpp b/ipc/glue/BackgroundUtils.cpp index 44f988efd..6f7501f70 100644 --- a/ipc/glue/BackgroundUtils.cpp +++ b/ipc/glue/BackgroundUtils.cpp @@ -295,7 +295,8 @@ LoadInfoToLoadInfoArgs(nsILoadInfo *aLoadInfo, aLoadInfo->CorsUnsafeHeaders(), aLoadInfo->GetForcePreflight(), aLoadInfo->GetIsPreflight(), - aLoadInfo->GetLoadTriggeredFromExternal() + aLoadInfo->GetLoadTriggeredFromExternal(), + aLoadInfo->GetIsFromProcessingFrameAttributes() ); return NS_OK; @@ -347,7 +348,7 @@ LoadInfoArgsToLoadInfo(const OptionalLoadInfoArgs& aOptionalLoadInfoArgs, redirectChain.AppendElement(redirectedPrincipal.forget()); } - nsCOMPtr<nsILoadInfo> loadInfo = + RefPtr<mozilla::LoadInfo> loadInfo = new mozilla::LoadInfo(loadingPrincipal, triggeringPrincipal, principalToInherit, @@ -375,8 +376,12 @@ LoadInfoArgsToLoadInfo(const OptionalLoadInfoArgs& aOptionalLoadInfoArgs, loadInfoArgs.loadTriggeredFromExternal() ); - loadInfo.forget(outLoadInfo); - return NS_OK; + if (loadInfoArgs.isFromProcessingFrameAttributes()) { + loadInfo->SetIsFromProcessingFrameAttributes(); + } + + loadInfo.forget(outLoadInfo); + return NS_OK; } } // namespace ipc diff --git a/netwerk/base/LoadInfo.cpp b/netwerk/base/LoadInfo.cpp index ebe9d4703..d57f644df 100644 --- a/netwerk/base/LoadInfo.cpp +++ b/netwerk/base/LoadInfo.cpp @@ -67,6 +67,7 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal, , mForcePreflight(false) , mIsPreflight(false) , mLoadTriggeredFromExternal(false) + , mIsFromProcessingFrameAttributes(false) { MOZ_ASSERT(mLoadingPrincipal); MOZ_ASSERT(mTriggeringPrincipal); @@ -241,6 +242,7 @@ LoadInfo::LoadInfo(nsPIDOMWindowOuter* aOuterWindow, , mForcePreflight(false) , mIsPreflight(false) , mLoadTriggeredFromExternal(false) + , mIsFromProcessingFrameAttributes(false) { // Top-level loads are never third-party // Grab the information we can out of the window. @@ -304,6 +306,7 @@ LoadInfo::LoadInfo(const LoadInfo& rhs) , mForcePreflight(rhs.mForcePreflight) , mIsPreflight(rhs.mIsPreflight) , mLoadTriggeredFromExternal(rhs.mLoadTriggeredFromExternal) + , mIsFromProcessingFrameAttributes(rhs.mIsFromProcessingFrameAttributes) { } @@ -355,6 +358,7 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal, , mForcePreflight(aForcePreflight) , mIsPreflight(aIsPreflight) , mLoadTriggeredFromExternal(aLoadTriggeredFromExternal) + , mIsFromProcessingFrameAttributes(false) { // Only top level TYPE_DOCUMENT loads can have a null loadingPrincipal MOZ_ASSERT(mLoadingPrincipal || aContentPolicyType == nsIContentPolicy::TYPE_DOCUMENT); @@ -970,5 +974,19 @@ LoadInfo::GetIsTopLevelLoad(bool *aResult) return NS_OK; } +void +LoadInfo::SetIsFromProcessingFrameAttributes() +{ + mIsFromProcessingFrameAttributes = true; +} + +NS_IMETHODIMP +LoadInfo::GetIsFromProcessingFrameAttributes(bool *aIsFromProcessingFrameAttributes) +{ + MOZ_ASSERT(aIsFromProcessingFrameAttributes); + *aIsFromProcessingFrameAttributes = mIsFromProcessingFrameAttributes; + return NS_OK; +} + } // namespace net } // namespace mozilla diff --git a/netwerk/base/LoadInfo.h b/netwerk/base/LoadInfo.h index 2b1e8c9e8..a4ec25a9d 100644 --- a/netwerk/base/LoadInfo.h +++ b/netwerk/base/LoadInfo.h @@ -81,6 +81,7 @@ public: void SetIsPreflight(); void SetUpgradeInsecureRequests(); + void SetIsFromProcessingFrameAttributes(); private: // private constructor that is only allowed to be called from within @@ -157,6 +158,11 @@ private: bool mForcePreflight; bool mIsPreflight; bool mLoadTriggeredFromExternal; + + // Is true if this load was triggered by processing the attributes of the + // browsing context container. + // See nsILoadInfo.isFromProcessingFrameAttributes + bool mIsFromProcessingFrameAttributes; }; } // namespace net diff --git a/netwerk/base/nsILoadInfo.idl b/netwerk/base/nsILoadInfo.idl index bc609c317..fc1aadd93 100644 --- a/netwerk/base/nsILoadInfo.idl +++ b/netwerk/base/nsILoadInfo.idl @@ -740,4 +740,11 @@ interface nsILoadInfo : nsISupports * Note that the load for a sub-frame's document will return false here. */ [infallible] readonly attribute boolean isTopLevelLoad; + + /** + * This attribute will be true if this is a load triggered by + * https://html.spec.whatwg.org/multipage/iframe-embed-object.html#process-the-iframe-attributes + * or https://html.spec.whatwg.org/multipage/obsolete.html#process-the-frame-attributes + */ + [infallible] readonly attribute boolean isFromProcessingFrameAttributes; }; diff --git a/netwerk/ipc/NeckoChannelParams.ipdlh b/netwerk/ipc/NeckoChannelParams.ipdlh index 2633ef608..2896f427d 100644 --- a/netwerk/ipc/NeckoChannelParams.ipdlh +++ b/netwerk/ipc/NeckoChannelParams.ipdlh @@ -56,6 +56,7 @@ struct LoadInfoArgs bool forcePreflight; bool isPreflight; bool loadTriggeredFromExternal; + bool isFromProcessingFrameAttributes; }; /** diff --git a/netwerk/protocol/http/HttpBaseChannel.cpp b/netwerk/protocol/http/HttpBaseChannel.cpp index 03123ceb0..21b661c2b 100644 --- a/netwerk/protocol/http/HttpBaseChannel.cpp +++ b/netwerk/protocol/http/HttpBaseChannel.cpp @@ -3676,14 +3676,17 @@ HttpBaseChannel::GetPerformance() return nullptr; } - // We only add to the document's performance object if it has the same - // principal as the one triggering the load. This is to prevent navigations - // triggered _by_ the iframe from showing up in the parent document's - // performance entries if they have different origins. if (!mLoadInfo->TriggeringPrincipal()->Equals(loadingDocument->NodePrincipal())) { return nullptr; } + if (mLoadInfo->GetExternalContentPolicyType() == nsIContentPolicy::TYPE_SUBDOCUMENT && + !mLoadInfo->GetIsFromProcessingFrameAttributes()) { + // We only report loads caused by processing the attributes of the + // browsing context container. + return nullptr; + } + nsCOMPtr<nsPIDOMWindowInner> innerWindow = loadingDocument->GetInnerWindow(); if (!innerWindow) { return nullptr; |