Bug 1487964 - Do not report resource-timing subdocument loads triggered by that subdocument r=bzbarsky

Differential Revision: https://phabricator.services.mozilla.com/D9503

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Valentin Gosu 2018-11-17 19:30:36 +00:00
parent c543b5295f
commit a80d7bf63e
13 changed files with 79 additions and 23 deletions

View File

@ -764,6 +764,7 @@ nsDocShell::LoadURI(nsDocShellLoadState* aLoadState)
resultPrincipalURI,
aLoadState->KeepResultPrincipalURIIfSet(),
aLoadState->LoadReplace(),
aLoadState->GetIsFromProcessingFrameAttributes(),
aLoadState->Referrer(),
aLoadState->ReferrerPolicy(),
aLoadState->TriggeringPrincipal(),
@ -4814,7 +4815,8 @@ nsDocShell::LoadErrorPage(nsIURI* aErrorURI, nsIURI* aFailedURI, nsIChannel* aFa
mLSHE->AbandonBFCacheEntry();
}
return InternalLoad(aErrorURI, nullptr, Nothing(), false, false, nullptr, RP_Unset,
return InternalLoad(aErrorURI, nullptr, Nothing(), false, false,
false, nullptr, RP_Unset,
nsContentUtils::GetSystemPrincipal(), nullptr,
INTERNAL_LOAD_FLAGS_NONE, EmptyString(),
VoidCString(), VoidString(), nullptr, nullptr,
@ -4914,6 +4916,7 @@ nsDocShell::Reload(uint32_t aReloadFlags)
emplacedResultPrincipalURI,
false,
loadReplace,
false, // IsFromProcessingFrameAttributes
referrerURI,
referrerPolicy,
triggeringPrincipal,
@ -9002,6 +9005,7 @@ public:
Maybe<nsCOMPtr<nsIURI>> const& aResultPrincipalURI,
bool aKeepResultPrincipalURIIfSet,
bool aLoadReplace,
bool aIsFromProcessingFrameAttributes,
nsIURI* aReferrer, uint32_t aReferrerPolicy,
nsIPrincipal* aTriggeringPrincipal,
nsIPrincipal* aPrincipalToInherit,
@ -9024,6 +9028,7 @@ public:
, mResultPrincipalURI(aResultPrincipalURI)
, mKeepResultPrincipalURIIfSet(aKeepResultPrincipalURIIfSet)
, mLoadReplace(aLoadReplace)
, mIsFromProcessingFrameAttributes(aIsFromProcessingFrameAttributes)
, mReferrer(aReferrer)
, mReferrerPolicy(aReferrerPolicy)
, mTriggeringPrincipal(aTriggeringPrincipal)
@ -9048,6 +9053,7 @@ public:
return mDocShell->InternalLoad(mURI, mOriginalURI, mResultPrincipalURI,
mKeepResultPrincipalURIIfSet,
mLoadReplace,
mIsFromProcessingFrameAttributes,
mReferrer,
mReferrerPolicy,
mTriggeringPrincipal, mPrincipalToInherit,
@ -9070,6 +9076,7 @@ private:
Maybe<nsCOMPtr<nsIURI>> mResultPrincipalURI;
bool mKeepResultPrincipalURIIfSet;
bool mLoadReplace;
bool mIsFromProcessingFrameAttributes;
nsCOMPtr<nsIURI> mReferrer;
uint32_t mReferrerPolicy;
nsCOMPtr<nsIPrincipal> mTriggeringPrincipal;
@ -9106,6 +9113,7 @@ nsDocShell::InternalLoad(nsIURI* aURI,
Maybe<nsCOMPtr<nsIURI>> const& aResultPrincipalURI,
bool aKeepResultPrincipalURIIfSet,
bool aLoadReplace,
bool aIsFromProcessingFrameAttributes,
nsIURI* aReferrer,
uint32_t aReferrerPolicy,
nsIPrincipal* aTriggeringPrincipal,
@ -9458,6 +9466,7 @@ nsDocShell::InternalLoad(nsIURI* aURI,
aResultPrincipalURI,
aKeepResultPrincipalURIIfSet,
aLoadReplace,
aIsFromProcessingFrameAttributes,
aReferrer,
aReferrerPolicy,
aTriggeringPrincipal,
@ -9556,7 +9565,8 @@ nsDocShell::InternalLoad(nsIURI* aURI,
nsCOMPtr<nsIRunnable> ev =
new InternalLoadEvent(this, aURI, aOriginalURI, aResultPrincipalURI,
aKeepResultPrincipalURIIfSet,
aLoadReplace, aReferrer, aReferrerPolicy,
aLoadReplace, aIsFromProcessingFrameAttributes,
aReferrer, aReferrerPolicy,
aTriggeringPrincipal, principalToInherit,
aFlags, aTypeHint, aPostData,
aHeadersData, aLoadType, aSHEntry, aFirstParty,
@ -10070,6 +10080,7 @@ nsDocShell::InternalLoad(nsIURI* aURI,
nsCOMPtr<nsIRequest> req;
rv = DoURILoad(aURI, aOriginalURI, aResultPrincipalURI,
aKeepResultPrincipalURIIfSet, aLoadReplace,
aIsFromProcessingFrameAttributes,
loadFromExternal,
(aFlags & INTERNAL_LOAD_FLAGS_FORCE_ALLOW_DATA_URI),
(aFlags & INTERNAL_LOAD_FLAGS_ORIGINAL_FRAME_SRC),
@ -10218,6 +10229,7 @@ nsDocShell::DoURILoad(nsIURI* aURI,
Maybe<nsCOMPtr<nsIURI>> const& aResultPrincipalURI,
bool aKeepResultPrincipalURIIfSet,
bool aLoadReplace,
bool aIsFromProcessingFrameAttributes,
bool aLoadFromExternal,
bool aForceAllowDataURI,
bool aOriginalFrameSrc,
@ -10393,7 +10405,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) :
@ -10439,6 +10451,10 @@ nsDocShell::DoURILoad(nsIURI* aURI,
rv = loadInfo->SetIsDocshellReload(mLoadType & LOAD_CMD_RELOAD);
NS_ENSURE_SUCCESS(rv, rv);
if (aIsFromProcessingFrameAttributes) {
loadInfo->SetIsFromProcessingFrameAttributes();
}
if (!isSrcdoc) {
rv = NS_NewChannelInternal(getter_AddRefs(channel),
aURI,
@ -12149,6 +12165,7 @@ nsDocShell::LoadHistoryEntry(nsISHEntry* aEntry, uint32_t aLoadType)
emplacedResultPrincipalURI,
false,
loadReplace,
false, // IsFromProcessingFrameAttributes
referrerURI,
referrerPolicy,
triggeringPrincipal,
@ -13341,6 +13358,7 @@ nsDocShell::OnLinkClickSync(nsIContent* aContent,
Nothing(), // Let the protocol handler assign it
false,
false, // LoadReplace
false, // IsFromProcessingFrameAttributes
referer, // Referer URI
refererPolicy, // Referer policy
triggeringPrincipal,

View File

@ -532,6 +532,7 @@ private: // member functions
mozilla::Maybe<nsCOMPtr<nsIURI>> const& aResultPrincipalURI,
bool aKeepResultPrincipalURIIfSet,
bool aLoadReplace,
bool aIsFromProcessingFrameAttributes,
bool aLoadFromExternal,
bool aForceAllowDataURI,
bool aOriginalFrameSrc,

View File

@ -30,6 +30,7 @@ nsDocShellLoadState::nsDocShellLoadState()
, mTypeHint(VoidCString())
, mFileName(VoidString())
, mDocShellInternalLoadFlags(0)
, mIsFromProcessingFrameAttributes(false)
{
}

View File

@ -165,6 +165,9 @@ public:
// information and origin attributes.
nsresult SetupTriggeringPrincipal(const mozilla::OriginAttributes& aOriginAttributes);
void SetIsFromProcessingFrameAttributes() { mIsFromProcessingFrameAttributes = true; }
bool GetIsFromProcessingFrameAttributes() { return mIsFromProcessingFrameAttributes; }
// When loading a document through nsDocShell::LoadURI(), a special set of
// flags needs to be set based on other values in nsDocShellLoadState. This
// function calculates those flags, before the LoadState is passed to
@ -288,6 +291,10 @@ protected:
// nsDocShell::InternalLoad, taken from the INTERNAL_LOAD consts in
// nsIDocShell.idl
uint32_t mDocShellInternalLoadFlags;
// This will be true if this load is triggered by attribute changes.
// See nsILoadInfo.isFromProcessingFrameAttributes
bool mIsFromProcessingFrameAttributes;
};
#endif /* nsDocShellLoadState_h__ */

View File

@ -137,6 +137,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 aTriggeringPrincipal - A non-null principal that initiated that load.
@ -184,6 +187,7 @@ interface nsIDocShell : nsIDocShellTreeItem
[const] in MaybeURI aResultPrincipalURI,
in bool aKeepResultPrincipalURIIfSet,
in boolean aLoadReplace,
in boolean aIsFromProcessingFrameAttributes,
in nsIURI aReferrer,
in unsigned long aReferrerPolicy,
in nsIPrincipal aTriggeringPrincipal,

View File

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

View File

@ -453,7 +453,8 @@ LoadInfoToLoadInfoArgs(nsILoadInfo *aLoadInfo,
aLoadInfo->GetLoadTriggeredFromExternal(),
aLoadInfo->GetServiceWorkerTaintingSynthesized(),
aLoadInfo->GetDocumentHasUserInteracted(),
aLoadInfo->GetDocumentHasLoaded()
aLoadInfo->GetDocumentHasLoaded(),
aLoadInfo->GetIsFromProcessingFrameAttributes()
);
return NS_OK;
@ -571,7 +572,7 @@ LoadInfoArgsToLoadInfo(const OptionalLoadInfoArgs& aOptionalLoadInfoArgs,
loadInfoArgs.controller().get_IPCServiceWorkerDescriptor()));
}
nsCOMPtr<nsILoadInfo> loadInfo =
RefPtr<mozilla::LoadInfo> loadInfo =
new mozilla::LoadInfo(loadingPrincipal,
triggeringPrincipal,
principalToInherit,
@ -619,6 +620,10 @@ LoadInfoArgsToLoadInfo(const OptionalLoadInfoArgs& aOptionalLoadInfoArgs,
loadInfoArgs.documentHasLoaded()
);
if (loadInfoArgs.isFromProcessingFrameAttributes()) {
loadInfo->SetIsFromProcessingFrameAttributes();
}
loadInfo.forget(outLoadInfo);
return NS_OK;
}

View File

@ -94,6 +94,7 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal,
, mIsTrackerBlocked(false)
, mDocumentHasUserInteracted(false)
, mDocumentHasLoaded(false)
, mIsFromProcessingFrameAttributes(false)
{
MOZ_ASSERT(mLoadingPrincipal);
MOZ_ASSERT(mTriggeringPrincipal);
@ -366,6 +367,7 @@ LoadInfo::LoadInfo(nsPIDOMWindowOuter* aOuterWindow,
, mIsTrackerBlocked(false)
, mDocumentHasUserInteracted(false)
, mDocumentHasLoaded(false)
, mIsFromProcessingFrameAttributes(false)
{
// Top-level loads are never third-party
// Grab the information we can out of the window.
@ -468,6 +470,7 @@ LoadInfo::LoadInfo(const LoadInfo& rhs)
, mIsTrackerBlocked(rhs.mIsTrackerBlocked)
, mDocumentHasUserInteracted(rhs.mDocumentHasUserInteracted)
, mDocumentHasLoaded(rhs.mDocumentHasLoaded)
, mIsFromProcessingFrameAttributes(rhs.mIsFromProcessingFrameAttributes)
{
}
@ -562,6 +565,7 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal,
, mIsTrackerBlocked(false)
, mDocumentHasUserInteracted(aDocumentHasUserInteracted)
, mDocumentHasLoaded(aDocumentHasLoaded)
, mIsFromProcessingFrameAttributes(false)
{
// Only top level TYPE_DOCUMENT loads can have a null loadingPrincipal
MOZ_ASSERT(mLoadingPrincipal || aContentPolicyType == nsIContentPolicy::TYPE_DOCUMENT);
@ -1450,6 +1454,20 @@ 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;
}
NS_IMETHODIMP
LoadInfo::GetResultPrincipalURI(nsIURI **aURI)
{

View File

@ -87,6 +87,7 @@ public:
void SetUpgradeInsecureRequests();
void SetBrowserUpgradeInsecureRequests();
void SetBrowserWouldUpgradeInsecureRequests();
void SetIsFromProcessingFrameAttributes();
private:
// private constructor that is only allowed to be called from within
@ -219,6 +220,11 @@ private:
bool mIsTrackerBlocked;
bool mDocumentHasUserInteracted;
bool mDocumentHasLoaded;
// Is true if this load was triggered by processing the attributes of the
// browsing context container.
// See nsILoadInfo.isFromProcessingFrameAttributes
bool mIsFromProcessingFrameAttributes;
};
} // namespace net

View File

@ -1068,4 +1068,11 @@ interface nsILoadInfo : nsISupports
* See bug 1500908.
*/
attribute nsICSPEventListener cspEventListener;
/**
* 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

@ -110,6 +110,7 @@ struct LoadInfoArgs
bool serviceWorkerTaintingSynthesized;
bool documentHasUserInteracted;
bool documentHasLoaded;
bool isFromProcessingFrameAttributes;
};
/**

View File

@ -4413,11 +4413,10 @@ HttpBaseChannel::GetPerformanceStorage()
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->GetExternalContentPolicyType() == nsIContentPolicy::TYPE_SUBDOCUMENT &&
!mLoadInfo->GetIsFromProcessingFrameAttributes()) {
// We only report loads caused by processing the attributes of the
// browsing context container.
return nullptr;
}

View File

@ -1,13 +0,0 @@
[resource_subframe_self_navigation.html]
[Subsequent <iframe> navigations don't appear in the resource-timing buffer.]
expected: FAIL
[Subsequent <frame> navigations don't appear in the resource-timing buffer.]
expected: FAIL
[Subsequent <embed> navigations don't appear in the resource-timing buffer.]
expected: FAIL
[Subsequent <object> navigations don't appear in the resource-timing buffer.]
expected: FAIL