diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 456d014c1..58fdff12d 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -1275,6 +1275,7 @@ nsDocShell::LoadURI(nsIURI* aURI, nsCOMPtr referrer; nsCOMPtr originalURI; bool loadReplace = false; + bool isFromProcessingFrameAttributes = false; nsCOMPtr postStream; nsCOMPtr headersStream; nsCOMPtr owner; @@ -1303,6 +1304,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 @@ -1558,6 +1560,7 @@ nsDocShell::LoadURI(nsIURI* aURI, return InternalLoad(aURI, originalURI, loadReplace, + isFromProcessingFrameAttributes, referrer, referrerPolicy, owner, @@ -5252,7 +5255,7 @@ 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, + return InternalLoad(errorPageURI, nullptr, false, false, nullptr, mozilla::net::RP_Default, nullptr, INTERNAL_LOAD_FLAGS_INHERIT_OWNER, nullptr, nullptr, NullString(), nullptr, nullptr, LOAD_ERROR_PAGE, @@ -5334,6 +5337,7 @@ nsDocShell::Reload(uint32_t aReloadFlags) rv = InternalLoad(currentURI, originalURI, loadReplace, + false, // IsFromProcessingFrameAttributes referrerURI, referrerPolicy, principal, @@ -9412,6 +9416,7 @@ class InternalLoadEvent : public nsRunnable public: InternalLoadEvent(nsDocShell* aDocShell, nsIURI* aURI, nsIURI* aOriginalURI, bool aLoadReplace, + bool aIsFromProcessingFrameAttributes, nsIURI* aReferrer, uint32_t aReferrerPolicy, nsISupports* aOwner, uint32_t aFlags, const char* aTypeHint, nsIInputStream* aPostData, @@ -9424,6 +9429,7 @@ public: , mURI(aURI) , mOriginalURI(aOriginalURI) , mLoadReplace(aLoadReplace) + , mIsFromProcessingFrameAttributes(aIsFromProcessingFrameAttributes) , mReferrer(aReferrer) , mReferrerPolicy(aReferrerPolicy) , mOwner(aOwner) @@ -9447,6 +9453,7 @@ public: { return mDocShell->InternalLoad(mURI, mOriginalURI, mLoadReplace, + mIsFromProcessingFrameAttributes, mReferrer, mReferrerPolicy, mOwner, mFlags, @@ -9467,6 +9474,7 @@ private: nsCOMPtr mURI; nsCOMPtr mOriginalURI; bool mLoadReplace; + bool mIsFromProcessingFrameAttributes; nsCOMPtr mReferrer; uint32_t mReferrerPolicy; nsCOMPtr mOwner; @@ -9513,6 +9521,7 @@ NS_IMETHODIMP nsDocShell::InternalLoad(nsIURI* aURI, nsIURI* aOriginalURI, bool aLoadReplace, + bool aIsFromProcessingFrameAttributes, nsIURI* aReferrer, uint32_t aReferrerPolicy, nsISupports* aOwner, @@ -9782,6 +9791,7 @@ nsDocShell::InternalLoad(nsIURI* aURI, INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER)); loadInfo->SetOriginalURI(aOriginalURI); loadInfo->SetLoadReplace(aLoadReplace); + loadInfo->SetIsFromProcessingFrameAttributes(aIsFromProcessingFrameAttributes); loadInfo->SetOwner(loadingPrincipal); // SetTriggeringPrincipal loadInfo->SetInheritOwner( /* SetInheritPrincipal _INHERIT_PRINCIPAL */ !!(aFlags & INTERNAL_LOAD_FLAGS_INHERIT_OWNER)); @@ -9831,6 +9841,7 @@ nsDocShell::InternalLoad(nsIURI* aURI, rv = targetDocShell->InternalLoad(aURI, aOriginalURI, aLoadReplace, + aIsFromProcessingFrameAttributes, aReferrer, aReferrerPolicy, owner, @@ -9912,6 +9923,7 @@ nsDocShell::InternalLoad(nsIURI* aURI, // Do this asynchronously nsCOMPtr ev = new InternalLoadEvent(this, aURI, aOriginalURI, aLoadReplace, + aIsFromProcessingFrameAttributes, aReferrer, aReferrerPolicy, aOwner, aFlags, aTypeHint, aPostData, aHeadersData, aLoadType, aSHEntry, aFirstParty, aSrcdoc, @@ -10392,7 +10404,9 @@ nsDocShell::InternalLoad(nsIURI* aURI, nsINetworkPredictor::PREDICT_LOAD, this, nullptr); nsCOMPtr req; - rv = DoURILoad(aURI, aOriginalURI, aLoadReplace, aReferrer, + rv = DoURILoad(aURI, aOriginalURI, aLoadReplace, + aIsFromProcessingFrameAttributes, + aReferrer, !(aFlags & INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER), aReferrerPolicy, owner, aTypeHint, aFileName, aPostData, aHeadersData, @@ -10471,6 +10485,7 @@ nsresult nsDocShell::DoURILoad(nsIURI* aURI, nsIURI* aOriginalURI, bool aLoadReplace, + bool aIsFromProcessingFrameAttributes, nsIURI* aReferrerURI, bool aSendReferrer, uint32_t aReferrerPolicy, @@ -10620,6 +10635,14 @@ nsDocShell::DoURILoad(nsIURI* aURI, securityFlags |= nsILoadInfo::SEC_SANDBOXED; } +#if(0) + // XXX: bug 1487964 has this code, but we have no nsILoadInfo set up yet. + // Do we need it? + if (aIsFromProcessingFrameAttributes) { + loadInfo->SetIsFromProcessingFrameAttributes(); + } +#endif + if (!isSrcdoc) { rv = NS_NewChannelInternal(getter_AddRefs(channel), aURI, @@ -12184,6 +12207,7 @@ nsDocShell::LoadHistoryEntry(nsISHEntry* aEntry, uint32_t aLoadType) rv = InternalLoad(uri, originalURI, loadReplace, + false, // IsFromProcessingFrameAttributes referrerURI, referrerPolicy, owner, @@ -13646,6 +13670,7 @@ nsDocShell::OnLinkClickSync(nsIContent* aContent, nsresult rv = InternalLoad(clonedURI, // New URI nullptr, // Original URI false, // LoadReplace + false, // IsFromProcessingFrameAttributes referer, // Referer URI refererPolicy, // Referer policy aContent->NodePrincipal(), // Owner is our node's diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h index 6deb6947b..cbe121120 100644 --- a/docshell/base/nsDocShell.h +++ b/docshell/base/nsDocShell.h @@ -353,6 +353,7 @@ protected: nsresult DoURILoad(nsIURI* aURI, nsIURI* aOriginalURI, bool aLoadReplace, + bool aIsFromProcessingFrameAttributes, nsIURI* aReferrer, bool aSendReferrer, uint32_t aReferrerPolicy, diff --git a/docshell/base/nsDocShellLoadInfo.cpp b/docshell/base/nsDocShellLoadInfo.cpp index 0dac1cfc1..bac2649bf 100644 --- a/docshell/base/nsDocShellLoadInfo.cpp +++ b/docshell/base/nsDocShellLoadInfo.cpp @@ -19,6 +19,7 @@ nsDocShellLoadInfo::nsDocShellLoadInfo() , mReferrerPolicy(mozilla::net::RP_Default) , mLoadType(nsIDocShellLoadInfo::loadNormal) , mIsSrcdocLoad(false) + , mIsFromProcessingFrameAttributes(false) { } @@ -298,3 +299,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 105a53d43..bc945001e 100644 --- a/docshell/base/nsDocShellLoadInfo.h +++ b/docshell/base/nsDocShellLoadInfo.h @@ -48,6 +48,10 @@ protected: nsString mSrcdocData; nsCOMPtr mSourceDocShell; nsCOMPtr 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 7a0524063..a3b3cdfd0 100644 --- a/docshell/base/nsIDocShell.idl +++ b/docshell/base/nsIDocShell.idl @@ -126,6 +126,9 @@ 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 aOwner - Owner (security principal) @@ -154,6 +157,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 nsISupports aOwner, diff --git a/docshell/base/nsIDocShellLoadInfo.idl b/docshell/base/nsIDocShellLoadInfo.idl index 89337152d..d18c1b29b 100644 --- a/docshell/base/nsIDocShellLoadInfo.idl +++ b/docshell/base/nsIDocShellLoadInfo.idl @@ -120,4 +120,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 21c111fc6..f3f85c36f 100644 --- a/dom/base/nsFrameLoader.cpp +++ b/dom/base/nsFrameLoader.cpp @@ -427,6 +427,8 @@ nsFrameLoader::ReallyStartLoadingInternal() nsIWebNavigation::LOAD_FLAGS_DISALLOW_INHERIT_OWNER; } + loadInfo->SetIsFromProcessingFrameAttributes(true); + // Kick off the load... bool tmpState = mNeedsAsyncDestroy; mNeedsAsyncDestroy = true; diff --git a/ipc/glue/BackgroundUtils.cpp b/ipc/glue/BackgroundUtils.cpp index 07149753a..146b13cb5 100644 --- a/ipc/glue/BackgroundUtils.cpp +++ b/ipc/glue/BackgroundUtils.cpp @@ -255,7 +255,9 @@ LoadInfoToLoadInfoArgs(nsILoadInfo *aLoadInfo, redirectChain, aLoadInfo->CorsUnsafeHeaders(), aLoadInfo->GetForcePreflight(), - aLoadInfo->GetIsPreflight()); + aLoadInfo->GetIsPreflight(), + aLoadInfo->GetIsFromProcessingFrameAttributes() + ); return NS_OK; } @@ -296,7 +298,7 @@ LoadInfoArgsToLoadInfo(const OptionalLoadInfoArgs& aOptionalLoadInfoArgs, redirectChain.AppendElement(redirectedPrincipal.forget()); } - nsCOMPtr loadInfo = + RefPtr loadInfo = new mozilla::LoadInfo(requestingPrincipal, triggeringPrincipal, loadInfoArgs.securityFlags(), @@ -316,6 +318,10 @@ LoadInfoArgsToLoadInfo(const OptionalLoadInfoArgs& aOptionalLoadInfoArgs, loadInfoArgs.forcePreflight(), loadInfoArgs.isPreflight()); + if (loadInfoArgs.isFromProcessingFrameAttributes()) { + loadInfo->SetIsFromProcessingFrameAttributes(); + } + loadInfo.forget(outLoadInfo); return NS_OK; } diff --git a/netwerk/base/LoadInfo.cpp b/netwerk/base/LoadInfo.cpp index 50e93aa06..d91a61982 100644 --- a/netwerk/base/LoadInfo.cpp +++ b/netwerk/base/LoadInfo.cpp @@ -43,6 +43,7 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal, , mIsThirdPartyContext(false) , mForcePreflight(false) , mIsPreflight(false) + , mIsFromProcessingFrameAttributes(false) { MOZ_ASSERT(mLoadingPrincipal); MOZ_ASSERT(mTriggeringPrincipal); @@ -134,6 +135,7 @@ LoadInfo::LoadInfo(const LoadInfo& rhs) , mCorsUnsafeHeaders(rhs.mCorsUnsafeHeaders) , mForcePreflight(rhs.mForcePreflight) , mIsPreflight(rhs.mIsPreflight) + , mIsFromProcessingFrameAttributes(rhs.mIsFromProcessingFrameAttributes) { } @@ -171,6 +173,7 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal, , mCorsUnsafeHeaders(aCorsUnsafeHeaders) , mForcePreflight(aForcePreflight) , mIsPreflight(aIsPreflight) + , mIsFromProcessingFrameAttributes(false) { MOZ_ASSERT(mLoadingPrincipal); MOZ_ASSERT(mTriggeringPrincipal); @@ -587,4 +590,18 @@ LoadInfo::MaybeIncreaseTainting(uint32_t aTainting) return NS_OK; } +void +LoadInfo::SetIsFromProcessingFrameAttributes() +{ + mIsFromProcessingFrameAttributes = true; +} + +NS_IMETHODIMP +LoadInfo::GetIsFromProcessingFrameAttributes(bool *aIsFromProcessingFrameAttributes) +{ + MOZ_ASSERT(aIsFromProcessingFrameAttributes); + *aIsFromProcessingFrameAttributes = mIsFromProcessingFrameAttributes; + return NS_OK; +} + } // namespace mozilla diff --git a/netwerk/base/LoadInfo.h b/netwerk/base/LoadInfo.h index 99de84a2f..9daa3a7b3 100644 --- a/netwerk/base/LoadInfo.h +++ b/netwerk/base/LoadInfo.h @@ -68,6 +68,8 @@ public: void SetIsPreflight(); + void SetIsFromProcessingFrameAttributes(); + private: // private constructor that is only allowed to be called from within // HttpChannelParent and FTPChannelParent declared as friends undeneath. @@ -128,6 +130,11 @@ private: nsTArray mCorsUnsafeHeaders; bool mForcePreflight; bool mIsPreflight; + + // Is true if this load was triggered by processing the attributes of the + // browsing context container. + // See nsILoadInfo.isFromProcessingFrameAttributes + bool mIsFromProcessingFrameAttributes; }; } // namespace mozilla diff --git a/netwerk/base/nsILoadInfo.idl b/netwerk/base/nsILoadInfo.idl index 6360d367a..0edb57ed7 100644 --- a/netwerk/base/nsILoadInfo.idl +++ b/netwerk/base/nsILoadInfo.idl @@ -528,4 +528,11 @@ interface nsILoadInfo : nsISupports MOZ_ALWAYS_TRUE(NS_SUCCEEDED(MaybeIncreaseTainting(tainting))); } %} + + /** + * 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 9afdf73d2..abad41380 100644 --- a/netwerk/ipc/NeckoChannelParams.ipdlh +++ b/netwerk/ipc/NeckoChannelParams.ipdlh @@ -45,6 +45,7 @@ struct LoadInfoArgs nsCString[] corsUnsafeHeaders; bool forcePreflight; bool isPreflight; + bool isFromProcessingFrameAttributes; }; /** diff --git a/netwerk/protocol/http/HttpBaseChannel.cpp b/netwerk/protocol/http/HttpBaseChannel.cpp index 7bdb1f4a7..dd4dc6e29 100644 --- a/netwerk/protocol/http/HttpBaseChannel.cpp +++ b/netwerk/protocol/http/HttpBaseChannel.cpp @@ -3072,14 +3072,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 innerWindow = loadingDocument->GetInnerWindow(); if (!innerWindow) { return nullptr;