Bug 1482129 - Exempt stylesheets, fonts and images when canceling loading of slow HTTP requests of tracking resources; r=valentin

This commit is contained in:
Ehsan Akhgari 2018-08-09 11:56:45 -04:00
parent e76d5d449a
commit 7d314b5011
2 changed files with 33 additions and 5 deletions

View File

@ -348,10 +348,11 @@ interface nsIContentPolicy : nsISupports
/* When adding new content types, please update nsContentBlocker,
* NS_CP_ContentTypeName, nsCSPContext, CSP_ContentTypeToDirective,
* DoContentSecurityChecks, all nsIContentPolicy implementations, the
* static_assert in dom/cache/DBSchema.cpp, ChannelWrapper.webidl,
* ChannelWrapper.cpp, nsPermissionManager.cpp, and other things that are not
* listed here that are related to nsIContentPolicy. */
* DoContentSecurityChecks, IsContentPolicyTypeWhitelistedForFastBlock,
* all nsIContentPolicy implementations, the static_assert in
* dom/cache/DBSchema.cpp, ChannelWrapper.webidl, ChannelWrapper.cpp,
* nsPermissionManager.cpp, and other things that are not listed here
* that are related to nsIContentPolicy. */
//////////////////////////////////////////////////////////////////////

View File

@ -596,6 +596,31 @@ nsHttpChannel::Connect()
return ConnectOnTailUnblock();
}
static bool
IsContentPolicyTypeWhitelistedForFastBlock(nsILoadInfo* aLoadInfo)
{
nsContentPolicyType type = aLoadInfo ?
aLoadInfo->GetExternalContentPolicyType() :
nsIContentPolicy::TYPE_OTHER;
switch (type) {
// images
case nsIContentPolicy::TYPE_IMAGE:
case nsIContentPolicy::TYPE_IMAGESET:
case nsIContentPolicy::TYPE_INTERNAL_IMAGE:
case nsIContentPolicy::TYPE_INTERNAL_IMAGE_PRELOAD:
case nsIContentPolicy::TYPE_INTERNAL_IMAGE_FAVICON:
// fonts
case nsIContentPolicy::TYPE_FONT:
// stylesheets
case nsIContentPolicy::TYPE_STYLESHEET:
case nsIContentPolicy::TYPE_INTERNAL_STYLESHEET:
case nsIContentPolicy::TYPE_INTERNAL_STYLESHEET_PRELOAD:
return true;
default:
return false;
}
}
bool
nsHttpChannel::CheckFastBlocked()
{
@ -616,7 +641,9 @@ nsHttpChannel::CheckFastBlocked()
return false;
}
if (!sIsFastBlockEnabled || !timestamp) {
if (!sIsFastBlockEnabled ||
IsContentPolicyTypeWhitelistedForFastBlock(mLoadInfo) ||
!timestamp) {
return false;
}