1
0
mirror of https://github.com/roytam1/UXP.git synced 2026-05-26 13:58:49 +00:00

Do not report resource-timing subdocument loads triggered by that subdocument.

This commit is contained in:
wolfbeast
2018-12-14 12:50:01 +01:00
committed by Roy Tam
parent a959f4717e
commit 27d88fc505
13 changed files with 108 additions and 12 deletions
+24 -4
View File
@@ -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(&lt);
// 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,
+1
View File
@@ -371,6 +371,7 @@ protected:
nsresult DoURILoad(nsIURI* aURI,
nsIURI* aOriginalURI,
bool aLoadReplace,
bool aIsFromProcessingFrameAttributes,
bool aLoadFromExternal,
bool aForceAllowDataURI,
nsIURI* aReferrer,
+17
View File
@@ -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;
}
+4
View File
@@ -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__ */
+5
View File
@@ -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,
+6
View File
@@ -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;
};
+3
View File
@@ -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;
+9 -4
View File
@@ -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
+18
View File
@@ -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
+6
View File
@@ -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
+7
View File
@@ -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;
};
+1
View File
@@ -56,6 +56,7 @@ struct LoadInfoArgs
bool forcePreflight;
bool isPreflight;
bool loadTriggeredFromExternal;
bool isFromProcessingFrameAttributes;
};
/**
+7 -4
View File
@@ -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;