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, /* When adding new content types, please update nsContentBlocker,
* NS_CP_ContentTypeName, nsCSPContext, CSP_ContentTypeToDirective, * NS_CP_ContentTypeName, nsCSPContext, CSP_ContentTypeToDirective,
* DoContentSecurityChecks, all nsIContentPolicy implementations, the * DoContentSecurityChecks, IsContentPolicyTypeWhitelistedForFastBlock,
* static_assert in dom/cache/DBSchema.cpp, ChannelWrapper.webidl, * all nsIContentPolicy implementations, the static_assert in
* ChannelWrapper.cpp, nsPermissionManager.cpp, and other things that are not * dom/cache/DBSchema.cpp, ChannelWrapper.webidl, ChannelWrapper.cpp,
* listed here that are related to nsIContentPolicy. */ * 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(); 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 bool
nsHttpChannel::CheckFastBlocked() nsHttpChannel::CheckFastBlocked()
{ {
@ -616,7 +641,9 @@ nsHttpChannel::CheckFastBlocked()
return false; return false;
} }
if (!sIsFastBlockEnabled || !timestamp) { if (!sIsFastBlockEnabled ||
IsContentPolicyTypeWhitelistedForFastBlock(mLoadInfo) ||
!timestamp) {
return false; return false;
} }