This commit is contained in:
Cameron Kaiser 2018-11-27 06:49:28 -08:00
parent 6db6f6ac23
commit 8126d332a5
13 changed files with 108 additions and 8 deletions

View File

@ -1275,6 +1275,7 @@ nsDocShell::LoadURI(nsIURI* aURI,
nsCOMPtr<nsIURI> referrer; nsCOMPtr<nsIURI> referrer;
nsCOMPtr<nsIURI> originalURI; nsCOMPtr<nsIURI> originalURI;
bool loadReplace = false; bool loadReplace = false;
bool isFromProcessingFrameAttributes = false;
nsCOMPtr<nsIInputStream> postStream; nsCOMPtr<nsIInputStream> postStream;
nsCOMPtr<nsIInputStream> headersStream; nsCOMPtr<nsIInputStream> headersStream;
nsCOMPtr<nsISupports> owner; nsCOMPtr<nsISupports> owner;
@ -1303,6 +1304,7 @@ nsDocShell::LoadURI(nsIURI* aURI,
aLoadInfo->GetReferrer(getter_AddRefs(referrer)); aLoadInfo->GetReferrer(getter_AddRefs(referrer));
aLoadInfo->GetOriginalURI(getter_AddRefs(originalURI)); aLoadInfo->GetOriginalURI(getter_AddRefs(originalURI));
aLoadInfo->GetLoadReplace(&loadReplace); aLoadInfo->GetLoadReplace(&loadReplace);
aLoadInfo->GetIsFromProcessingFrameAttributes(&isFromProcessingFrameAttributes);
nsDocShellInfoLoadType lt = nsIDocShellLoadInfo::loadNormal; nsDocShellInfoLoadType lt = nsIDocShellLoadInfo::loadNormal;
aLoadInfo->GetLoadType(&lt); aLoadInfo->GetLoadType(&lt);
// Get the appropriate loadType from nsIDocShellLoadInfo type // Get the appropriate loadType from nsIDocShellLoadInfo type
@ -1558,6 +1560,7 @@ nsDocShell::LoadURI(nsIURI* aURI,
return InternalLoad(aURI, return InternalLoad(aURI,
originalURI, originalURI,
loadReplace, loadReplace,
isFromProcessingFrameAttributes,
referrer, referrer,
referrerPolicy, referrerPolicy,
owner, owner,
@ -5252,7 +5255,7 @@ nsDocShell::LoadErrorPage(nsIURI* aURI, const char16_t* aURL,
rv = NS_NewURI(getter_AddRefs(errorPageURI), errorPageUrl); rv = NS_NewURI(getter_AddRefs(errorPageURI), errorPageUrl);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
return InternalLoad(errorPageURI, nullptr, false, nullptr, return InternalLoad(errorPageURI, nullptr, false, false, nullptr,
mozilla::net::RP_Default, mozilla::net::RP_Default,
nullptr, INTERNAL_LOAD_FLAGS_INHERIT_OWNER, nullptr, nullptr, INTERNAL_LOAD_FLAGS_INHERIT_OWNER, nullptr,
nullptr, NullString(), nullptr, nullptr, LOAD_ERROR_PAGE, nullptr, NullString(), nullptr, nullptr, LOAD_ERROR_PAGE,
@ -5334,6 +5337,7 @@ nsDocShell::Reload(uint32_t aReloadFlags)
rv = InternalLoad(currentURI, rv = InternalLoad(currentURI,
originalURI, originalURI,
loadReplace, loadReplace,
false, // IsFromProcessingFrameAttributes
referrerURI, referrerURI,
referrerPolicy, referrerPolicy,
principal, principal,
@ -9412,6 +9416,7 @@ class InternalLoadEvent : public nsRunnable
public: public:
InternalLoadEvent(nsDocShell* aDocShell, nsIURI* aURI, InternalLoadEvent(nsDocShell* aDocShell, nsIURI* aURI,
nsIURI* aOriginalURI, bool aLoadReplace, nsIURI* aOriginalURI, bool aLoadReplace,
bool aIsFromProcessingFrameAttributes,
nsIURI* aReferrer, uint32_t aReferrerPolicy, nsIURI* aReferrer, uint32_t aReferrerPolicy,
nsISupports* aOwner, uint32_t aFlags, nsISupports* aOwner, uint32_t aFlags,
const char* aTypeHint, nsIInputStream* aPostData, const char* aTypeHint, nsIInputStream* aPostData,
@ -9424,6 +9429,7 @@ public:
, mURI(aURI) , mURI(aURI)
, mOriginalURI(aOriginalURI) , mOriginalURI(aOriginalURI)
, mLoadReplace(aLoadReplace) , mLoadReplace(aLoadReplace)
, mIsFromProcessingFrameAttributes(aIsFromProcessingFrameAttributes)
, mReferrer(aReferrer) , mReferrer(aReferrer)
, mReferrerPolicy(aReferrerPolicy) , mReferrerPolicy(aReferrerPolicy)
, mOwner(aOwner) , mOwner(aOwner)
@ -9447,6 +9453,7 @@ public:
{ {
return mDocShell->InternalLoad(mURI, mOriginalURI, return mDocShell->InternalLoad(mURI, mOriginalURI,
mLoadReplace, mLoadReplace,
mIsFromProcessingFrameAttributes,
mReferrer, mReferrer,
mReferrerPolicy, mReferrerPolicy,
mOwner, mFlags, mOwner, mFlags,
@ -9467,6 +9474,7 @@ private:
nsCOMPtr<nsIURI> mURI; nsCOMPtr<nsIURI> mURI;
nsCOMPtr<nsIURI> mOriginalURI; nsCOMPtr<nsIURI> mOriginalURI;
bool mLoadReplace; bool mLoadReplace;
bool mIsFromProcessingFrameAttributes;
nsCOMPtr<nsIURI> mReferrer; nsCOMPtr<nsIURI> mReferrer;
uint32_t mReferrerPolicy; uint32_t mReferrerPolicy;
nsCOMPtr<nsISupports> mOwner; nsCOMPtr<nsISupports> mOwner;
@ -9513,6 +9521,7 @@ NS_IMETHODIMP
nsDocShell::InternalLoad(nsIURI* aURI, nsDocShell::InternalLoad(nsIURI* aURI,
nsIURI* aOriginalURI, nsIURI* aOriginalURI,
bool aLoadReplace, bool aLoadReplace,
bool aIsFromProcessingFrameAttributes,
nsIURI* aReferrer, nsIURI* aReferrer,
uint32_t aReferrerPolicy, uint32_t aReferrerPolicy,
nsISupports* aOwner, nsISupports* aOwner,
@ -9782,6 +9791,7 @@ nsDocShell::InternalLoad(nsIURI* aURI,
INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER)); INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER));
loadInfo->SetOriginalURI(aOriginalURI); loadInfo->SetOriginalURI(aOriginalURI);
loadInfo->SetLoadReplace(aLoadReplace); loadInfo->SetLoadReplace(aLoadReplace);
loadInfo->SetIsFromProcessingFrameAttributes(aIsFromProcessingFrameAttributes);
loadInfo->SetOwner(loadingPrincipal); // SetTriggeringPrincipal loadInfo->SetOwner(loadingPrincipal); // SetTriggeringPrincipal
loadInfo->SetInheritOwner( /* SetInheritPrincipal _INHERIT_PRINCIPAL */ loadInfo->SetInheritOwner( /* SetInheritPrincipal _INHERIT_PRINCIPAL */
!!(aFlags & INTERNAL_LOAD_FLAGS_INHERIT_OWNER)); !!(aFlags & INTERNAL_LOAD_FLAGS_INHERIT_OWNER));
@ -9831,6 +9841,7 @@ nsDocShell::InternalLoad(nsIURI* aURI,
rv = targetDocShell->InternalLoad(aURI, rv = targetDocShell->InternalLoad(aURI,
aOriginalURI, aOriginalURI,
aLoadReplace, aLoadReplace,
aIsFromProcessingFrameAttributes,
aReferrer, aReferrer,
aReferrerPolicy, aReferrerPolicy,
owner, owner,
@ -9912,6 +9923,7 @@ nsDocShell::InternalLoad(nsIURI* aURI,
// Do this asynchronously // Do this asynchronously
nsCOMPtr<nsIRunnable> ev = nsCOMPtr<nsIRunnable> ev =
new InternalLoadEvent(this, aURI, aOriginalURI, aLoadReplace, new InternalLoadEvent(this, aURI, aOriginalURI, aLoadReplace,
aIsFromProcessingFrameAttributes,
aReferrer, aReferrerPolicy, aOwner, aFlags, aReferrer, aReferrerPolicy, aOwner, aFlags,
aTypeHint, aPostData, aHeadersData, aTypeHint, aPostData, aHeadersData,
aLoadType, aSHEntry, aFirstParty, aSrcdoc, aLoadType, aSHEntry, aFirstParty, aSrcdoc,
@ -10392,7 +10404,9 @@ nsDocShell::InternalLoad(nsIURI* aURI,
nsINetworkPredictor::PREDICT_LOAD, this, nullptr); nsINetworkPredictor::PREDICT_LOAD, this, nullptr);
nsCOMPtr<nsIRequest> req; nsCOMPtr<nsIRequest> req;
rv = DoURILoad(aURI, aOriginalURI, aLoadReplace, aReferrer, rv = DoURILoad(aURI, aOriginalURI, aLoadReplace,
aIsFromProcessingFrameAttributes,
aReferrer,
!(aFlags & INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER), !(aFlags & INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER),
aReferrerPolicy, aReferrerPolicy,
owner, aTypeHint, aFileName, aPostData, aHeadersData, owner, aTypeHint, aFileName, aPostData, aHeadersData,
@ -10471,6 +10485,7 @@ nsresult
nsDocShell::DoURILoad(nsIURI* aURI, nsDocShell::DoURILoad(nsIURI* aURI,
nsIURI* aOriginalURI, nsIURI* aOriginalURI,
bool aLoadReplace, bool aLoadReplace,
bool aIsFromProcessingFrameAttributes,
nsIURI* aReferrerURI, nsIURI* aReferrerURI,
bool aSendReferrer, bool aSendReferrer,
uint32_t aReferrerPolicy, uint32_t aReferrerPolicy,
@ -10620,6 +10635,14 @@ nsDocShell::DoURILoad(nsIURI* aURI,
securityFlags |= nsILoadInfo::SEC_SANDBOXED; 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) { if (!isSrcdoc) {
rv = NS_NewChannelInternal(getter_AddRefs(channel), rv = NS_NewChannelInternal(getter_AddRefs(channel),
aURI, aURI,
@ -12184,6 +12207,7 @@ nsDocShell::LoadHistoryEntry(nsISHEntry* aEntry, uint32_t aLoadType)
rv = InternalLoad(uri, rv = InternalLoad(uri,
originalURI, originalURI,
loadReplace, loadReplace,
false, // IsFromProcessingFrameAttributes
referrerURI, referrerURI,
referrerPolicy, referrerPolicy,
owner, owner,
@ -13646,6 +13670,7 @@ nsDocShell::OnLinkClickSync(nsIContent* aContent,
nsresult rv = InternalLoad(clonedURI, // New URI nsresult rv = InternalLoad(clonedURI, // New URI
nullptr, // Original URI nullptr, // Original URI
false, // LoadReplace false, // LoadReplace
false, // IsFromProcessingFrameAttributes
referer, // Referer URI referer, // Referer URI
refererPolicy, // Referer policy refererPolicy, // Referer policy
aContent->NodePrincipal(), // Owner is our node's aContent->NodePrincipal(), // Owner is our node's

View File

@ -353,6 +353,7 @@ protected:
nsresult DoURILoad(nsIURI* aURI, nsresult DoURILoad(nsIURI* aURI,
nsIURI* aOriginalURI, nsIURI* aOriginalURI,
bool aLoadReplace, bool aLoadReplace,
bool aIsFromProcessingFrameAttributes,
nsIURI* aReferrer, nsIURI* aReferrer,
bool aSendReferrer, bool aSendReferrer,
uint32_t aReferrerPolicy, uint32_t aReferrerPolicy,

View File

@ -19,6 +19,7 @@ nsDocShellLoadInfo::nsDocShellLoadInfo()
, mReferrerPolicy(mozilla::net::RP_Default) , mReferrerPolicy(mozilla::net::RP_Default)
, mLoadType(nsIDocShellLoadInfo::loadNormal) , mLoadType(nsIDocShellLoadInfo::loadNormal)
, mIsSrcdocLoad(false) , mIsSrcdocLoad(false)
, mIsFromProcessingFrameAttributes(false)
{ {
} }
@ -298,3 +299,19 @@ nsDocShellLoadInfo::SetBaseURI(nsIURI* aBaseURI)
mBaseURI = aBaseURI; mBaseURI = aBaseURI;
return NS_OK; 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;
}

View File

@ -48,6 +48,10 @@ protected:
nsString mSrcdocData; nsString mSrcdocData;
nsCOMPtr<nsIDocShell> mSourceDocShell; nsCOMPtr<nsIDocShell> mSourceDocShell;
nsCOMPtr<nsIURI> mBaseURI; nsCOMPtr<nsIURI> mBaseURI;
// This will be true if this load is triggered by attribute changes.
// See nsILoadInfo.isFromProcessingFrameAttributes
bool mIsFromProcessingFrameAttributes;
}; };
#endif /* nsDocShellLoadInfo_h__ */ #endif /* nsDocShellLoadInfo_h__ */

View File

@ -126,6 +126,9 @@ interface nsIDocShell : nsIDocShellTreeItem
* @param aLoadReplace - If set LOAD_REPLACE flag will be set on the * @param aLoadReplace - If set LOAD_REPLACE flag will be set on the
* channel. aOriginalURI is null, this argument is * channel. aOriginalURI is null, this argument is
* ignored. * ignored.
* @param aIsFromProcessingFrameAttributes
* - If this is a load triggered by changing frame attributes.
* See nsILoadInfo.isFromProcessingFrameAttributes
* @param aReferrer - Referring URI * @param aReferrer - Referring URI
* @param aReferrerPolicy - Referrer policy * @param aReferrerPolicy - Referrer policy
* @param aOwner - Owner (security principal) * @param aOwner - Owner (security principal)
@ -154,6 +157,7 @@ interface nsIDocShell : nsIDocShellTreeItem
[noscript]void internalLoad(in nsIURI aURI, [noscript]void internalLoad(in nsIURI aURI,
in nsIURI aOriginalURI, in nsIURI aOriginalURI,
in boolean aLoadReplace, in boolean aLoadReplace,
in boolean aIsFromProcessingFrameAttributes,
in nsIURI aReferrer, in nsIURI aReferrer,
in unsigned long aReferrerPolicy, in unsigned long aReferrerPolicy,
in nsISupports aOwner, in nsISupports aOwner,

View File

@ -120,4 +120,10 @@ interface nsIDocShellLoadInfo : nsISupports
* URI as this information isn't embedded in the load's URI. * URI as this information isn't embedded in the load's URI.
*/ */
attribute nsIURI baseURI; attribute nsIURI baseURI;
/**
* This will be true if this load is triggered by attribute changes.
* See nsILoadInfo.isFromProcessingFrameAttributes
*/
attribute boolean isFromProcessingFrameAttributes;
}; };

View File

@ -427,6 +427,8 @@ nsFrameLoader::ReallyStartLoadingInternal()
nsIWebNavigation::LOAD_FLAGS_DISALLOW_INHERIT_OWNER; nsIWebNavigation::LOAD_FLAGS_DISALLOW_INHERIT_OWNER;
} }
loadInfo->SetIsFromProcessingFrameAttributes(true);
// Kick off the load... // Kick off the load...
bool tmpState = mNeedsAsyncDestroy; bool tmpState = mNeedsAsyncDestroy;
mNeedsAsyncDestroy = true; mNeedsAsyncDestroy = true;

View File

@ -255,7 +255,9 @@ LoadInfoToLoadInfoArgs(nsILoadInfo *aLoadInfo,
redirectChain, redirectChain,
aLoadInfo->CorsUnsafeHeaders(), aLoadInfo->CorsUnsafeHeaders(),
aLoadInfo->GetForcePreflight(), aLoadInfo->GetForcePreflight(),
aLoadInfo->GetIsPreflight()); aLoadInfo->GetIsPreflight(),
aLoadInfo->GetIsFromProcessingFrameAttributes()
);
return NS_OK; return NS_OK;
} }
@ -296,7 +298,7 @@ LoadInfoArgsToLoadInfo(const OptionalLoadInfoArgs& aOptionalLoadInfoArgs,
redirectChain.AppendElement(redirectedPrincipal.forget()); redirectChain.AppendElement(redirectedPrincipal.forget());
} }
nsCOMPtr<nsILoadInfo> loadInfo = RefPtr<mozilla::LoadInfo> loadInfo =
new mozilla::LoadInfo(requestingPrincipal, new mozilla::LoadInfo(requestingPrincipal,
triggeringPrincipal, triggeringPrincipal,
loadInfoArgs.securityFlags(), loadInfoArgs.securityFlags(),
@ -316,6 +318,10 @@ LoadInfoArgsToLoadInfo(const OptionalLoadInfoArgs& aOptionalLoadInfoArgs,
loadInfoArgs.forcePreflight(), loadInfoArgs.forcePreflight(),
loadInfoArgs.isPreflight()); loadInfoArgs.isPreflight());
if (loadInfoArgs.isFromProcessingFrameAttributes()) {
loadInfo->SetIsFromProcessingFrameAttributes();
}
loadInfo.forget(outLoadInfo); loadInfo.forget(outLoadInfo);
return NS_OK; return NS_OK;
} }

View File

@ -43,6 +43,7 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal,
, mIsThirdPartyContext(false) , mIsThirdPartyContext(false)
, mForcePreflight(false) , mForcePreflight(false)
, mIsPreflight(false) , mIsPreflight(false)
, mIsFromProcessingFrameAttributes(false)
{ {
MOZ_ASSERT(mLoadingPrincipal); MOZ_ASSERT(mLoadingPrincipal);
MOZ_ASSERT(mTriggeringPrincipal); MOZ_ASSERT(mTriggeringPrincipal);
@ -134,6 +135,7 @@ LoadInfo::LoadInfo(const LoadInfo& rhs)
, mCorsUnsafeHeaders(rhs.mCorsUnsafeHeaders) , mCorsUnsafeHeaders(rhs.mCorsUnsafeHeaders)
, mForcePreflight(rhs.mForcePreflight) , mForcePreflight(rhs.mForcePreflight)
, mIsPreflight(rhs.mIsPreflight) , mIsPreflight(rhs.mIsPreflight)
, mIsFromProcessingFrameAttributes(rhs.mIsFromProcessingFrameAttributes)
{ {
} }
@ -171,6 +173,7 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal,
, mCorsUnsafeHeaders(aCorsUnsafeHeaders) , mCorsUnsafeHeaders(aCorsUnsafeHeaders)
, mForcePreflight(aForcePreflight) , mForcePreflight(aForcePreflight)
, mIsPreflight(aIsPreflight) , mIsPreflight(aIsPreflight)
, mIsFromProcessingFrameAttributes(false)
{ {
MOZ_ASSERT(mLoadingPrincipal); MOZ_ASSERT(mLoadingPrincipal);
MOZ_ASSERT(mTriggeringPrincipal); MOZ_ASSERT(mTriggeringPrincipal);
@ -587,4 +590,18 @@ LoadInfo::MaybeIncreaseTainting(uint32_t aTainting)
return NS_OK; return NS_OK;
} }
void
LoadInfo::SetIsFromProcessingFrameAttributes()
{
mIsFromProcessingFrameAttributes = true;
}
NS_IMETHODIMP
LoadInfo::GetIsFromProcessingFrameAttributes(bool *aIsFromProcessingFrameAttributes)
{
MOZ_ASSERT(aIsFromProcessingFrameAttributes);
*aIsFromProcessingFrameAttributes = mIsFromProcessingFrameAttributes;
return NS_OK;
}
} // namespace mozilla } // namespace mozilla

View File

@ -68,6 +68,8 @@ public:
void SetIsPreflight(); void SetIsPreflight();
void SetIsFromProcessingFrameAttributes();
private: private:
// private constructor that is only allowed to be called from within // private constructor that is only allowed to be called from within
// HttpChannelParent and FTPChannelParent declared as friends undeneath. // HttpChannelParent and FTPChannelParent declared as friends undeneath.
@ -128,6 +130,11 @@ private:
nsTArray<nsCString> mCorsUnsafeHeaders; nsTArray<nsCString> mCorsUnsafeHeaders;
bool mForcePreflight; bool mForcePreflight;
bool mIsPreflight; 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 } // namespace mozilla

View File

@ -528,4 +528,11 @@ interface nsILoadInfo : nsISupports
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(MaybeIncreaseTainting(tainting))); 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;
}; };

View File

@ -45,6 +45,7 @@ struct LoadInfoArgs
nsCString[] corsUnsafeHeaders; nsCString[] corsUnsafeHeaders;
bool forcePreflight; bool forcePreflight;
bool isPreflight; bool isPreflight;
bool isFromProcessingFrameAttributes;
}; };
/** /**

View File

@ -3072,14 +3072,17 @@ HttpBaseChannel::GetPerformance()
return nullptr; 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())) { if (!mLoadInfo->TriggeringPrincipal()->Equals(loadingDocument->NodePrincipal())) {
return nullptr; 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<nsPIDOMWindow> innerWindow = loadingDocument->GetInnerWindow(); nsCOMPtr<nsPIDOMWindow> innerWindow = loadingDocument->GetInnerWindow();
if (!innerWindow) { if (!innerWindow) {
return nullptr; return nullptr;