Bug 1277803 - Part 4 : Make the NS_CompareLoadInfoAndLoadContext() skiping test if the request is the favicon loading from the XUL image. r=honzab

This commit is contained in:
Tim Huang
2016-10-12 17:32:08 +08:00
committed by Jonathan Hao
parent 0d65a0e22a
commit b35f331a1c
5 changed files with 38 additions and 9 deletions

View File

@@ -2664,18 +2664,33 @@ HttpBaseChannel::ShouldIntercept(nsIURI* aURI)
return shouldIntercept;
}
void HttpBaseChannel::CheckPrivateBrowsing()
#ifdef DEBUG
void HttpBaseChannel::AssertPrivateBrowsingId()
{
nsCOMPtr<nsILoadContext> loadContext;
NS_QueryNotificationCallbacks(this, loadContext);
// For addons it's possible that mLoadInfo is null.
if (mLoadInfo && loadContext) {
DocShellOriginAttributes docShellAttrs;
loadContext->GetOriginAttributes(docShellAttrs);
MOZ_ASSERT(mLoadInfo->GetOriginAttributes().mPrivateBrowsingId == docShellAttrs.mPrivateBrowsingId,
"PrivateBrowsingId values are not the same between LoadInfo and LoadContext.");
if (!mLoadInfo) {
return;
}
if (!loadContext) {
return;
}
// We skip testing of favicon loading here since it could be triggered by XUL image
// which uses SystemPrincipal. The SystemPrincpal doesn't have mPrivateBrowsingId.
if (nsContentUtils::IsSystemPrincipal(mLoadInfo->LoadingPrincipal()) &&
mLoadInfo->InternalContentPolicyType() == nsIContentPolicy::TYPE_INTERNAL_IMAGE_FAVICON) {
return;
}
DocShellOriginAttributes docShellAttrs;
loadContext->GetOriginAttributes(docShellAttrs);
MOZ_ASSERT(mLoadInfo->GetOriginAttributes().mPrivateBrowsingId == docShellAttrs.mPrivateBrowsingId,
"PrivateBrowsingId values are not the same between LoadInfo and LoadContext.");
}
#endif
//-----------------------------------------------------------------------------
// nsHttpChannel::nsITraceableChannel