Bug 1133541 - ServiceWorkerManger::GetRegistrations should use the principal to match the registration objects, r=nsm

This commit is contained in:
Andrea Marchesini 2015-02-16 21:59:53 +01:00
parent f75620d1f9
commit 7a550002db

View File

@ -1201,8 +1201,33 @@ public:
nsTArray<nsRefPtr<ServiceWorkerRegistration>> array;
bool isNullPrincipal = true;
nsresult rv = aPrincipal->GetIsNullPrincipal(&isNullPrincipal);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
if (nsContentUtils::IsSystemPrincipal(principal) || isNullPrincipal) {
mPromise->MaybeResolve(array);
return NS_OK;
}
for (uint32_t i = 0; i < swm->mOrderedScopes.Length(); ++i) {
NS_ConvertUTF8toUTF16 scope(swm->mOrderedScopes[i]);
nsCOMPtr<nsIURI> scopeURI;
nsresult rv = NS_NewURI(getter_AddRefs(scopeURI), scope, nullptr, nullptr);
if (NS_WARN_IF(NS_FAILED(rv))) {
mPromise->MaybeReject(rv);
break;
}
rv = principal->CheckMayLoad(scopeURI, true /* report */,
false /* allowIfInheritsPrincipal */);
if (NS_WARN_IF(NS_FAILED(rv))) {
continue;
}
nsRefPtr<ServiceWorkerRegistration> swr =
new ServiceWorkerRegistration(mWindow, scope);