Bug 1162088 - ServiceWorkerManager should use the principal+scope for the initialization of ServiceWorkers, r=nsm,ehsan

This commit is contained in:
Andrea Marchesini
2015-05-19 17:53:36 +01:00
parent 97dbd7c53c
commit 794ebddb76
9 changed files with 470 additions and 136 deletions

View File

@@ -13994,18 +13994,19 @@ nsDocShell::ShouldPrepareForIntercept(nsIURI* aURI, bool aIsNavigate,
return NS_OK;
}
nsCOMPtr<nsIDocument> doc = GetDocument();
if (!doc) {
return NS_ERROR_NOT_AVAILABLE;
}
nsCOMPtr<nsIServiceWorkerManager> swm = services::GetServiceWorkerManager();
if (!swm) {
return NS_OK;
}
if (aIsNavigate) {
return swm->IsAvailableForURI(aURI, aShouldIntercept);
}
nsCOMPtr<nsIDocument> doc = GetDocument();
if (!doc) {
return NS_ERROR_NOT_AVAILABLE;
nsCOMPtr<nsIPrincipal> principal = doc->NodePrincipal();
return swm->IsAvailableForURI(principal, aURI, aShouldIntercept);
}
return swm->IsControlled(doc, aShouldIntercept);
@@ -14024,13 +14025,9 @@ nsDocShell::ChannelIntercepted(nsIInterceptedChannel* aChannel)
nsresult rv = aChannel->GetIsNavigation(&isNavigation);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> doc;
if (!isNavigation) {
doc = GetDocument();
if (!doc) {
return NS_ERROR_NOT_AVAILABLE;
}
nsCOMPtr<nsIDocument> doc = GetDocument();
if (!doc) {
return NS_ERROR_NOT_AVAILABLE;
}
bool isReload = mLoadType & LOAD_CMD_RELOAD;