Bug 1184798 - Ensure workers loads are treated as non-subresource fetches. r=jdm

This commit is contained in:
Nikhil Marathe
2015-09-17 11:56:41 -07:00
parent f94097d339
commit b4a78c2657
15 changed files with 129 additions and 14 deletions

View File

@@ -13850,6 +13850,7 @@ nsDocShell::MaybeNotifyKeywordSearchLoading(const nsString& aProvider,
NS_IMETHODIMP
nsDocShell::ShouldPrepareForIntercept(nsIURI* aURI, bool aIsNavigate,
nsContentPolicyType aLoadContentType,
bool* aShouldIntercept)
{
*aShouldIntercept = false;
@@ -13902,7 +13903,7 @@ nsDocShell::ShouldPrepareForIntercept(nsIURI* aURI, bool aIsNavigate,
}
}
if (aIsNavigate) {
if (aIsNavigate || nsContentUtils::IsWorkerLoad(aLoadContentType)) {
OriginAttributes attrs(GetAppId(), GetIsInBrowserElement());
*aShouldIntercept = swm->IsAvailable(attrs, aURI);
return NS_OK;
@@ -13982,9 +13983,15 @@ nsDocShell::ChannelIntercepted(nsIInterceptedChannel* aChannel,
nsresult rv = aChannel->GetIsNavigation(&isNavigation);
NS_ENSURE_SUCCESS(rv, rv);
nsContentPolicyType loadType;
rv = aChannel->GetInternalContentPolicyType(&loadType);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> doc;
if (!isNavigation) {
bool isSubresourceLoad = !isNavigation &&
!nsContentUtils::IsWorkerLoad(loadType);
if (isSubresourceLoad) {
doc = GetDocument();
if (!doc) {
return NS_ERROR_NOT_AVAILABLE;
@@ -13997,7 +14004,7 @@ nsDocShell::ChannelIntercepted(nsIInterceptedChannel* aChannel,
ErrorResult error;
nsCOMPtr<nsIRunnable> runnable =
swm->PrepareFetchEvent(attrs, doc, aChannel, isReload, error);
swm->PrepareFetchEvent(attrs, doc, aChannel, isReload, isSubresourceLoad, error);
if (NS_WARN_IF(error.Failed())) {
return error.StealNSResult();
}