зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1253738 P1 Require an explicit principal when looking up a service worker registration. r=baku
This commit is contained in:
Родитель
f7971123a2
Коммит
7ebbd928f1
|
@ -14196,7 +14196,9 @@ nsDocShell::ShouldPrepareForIntercept(nsIURI* aURI, bool aIsNonSubresourceReques
|
|||
if (aIsNonSubresourceRequest) {
|
||||
PrincipalOriginAttributes attrs;
|
||||
attrs.InheritFromDocShellToDoc(mOriginAttributes, aURI);
|
||||
*aShouldIntercept = swm->IsAvailable(attrs, aURI);
|
||||
nsCOMPtr<nsIPrincipal> principal =
|
||||
BasePrincipal::CreateCodebasePrincipal(aURI, attrs);
|
||||
*aShouldIntercept = swm->IsAvailable(principal, aURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -2411,8 +2411,10 @@ ServiceWorkerManager::GetActiveWorkerInfoForScope(const PrincipalOriginAttribute
|
|||
if (NS_FAILED(rv)) {
|
||||
return nullptr;
|
||||
}
|
||||
nsCOMPtr<nsIPrincipal> principal =
|
||||
BasePrincipal::CreateCodebasePrincipal(scopeURI, aOriginAttributes);
|
||||
RefPtr<ServiceWorkerRegistrationInfo> registration =
|
||||
GetServiceWorkerRegistrationInfo(aOriginAttributes, scopeURI);
|
||||
GetServiceWorkerRegistrationInfo(principal, scopeURI);
|
||||
if (!registration) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -3115,17 +3117,6 @@ ServiceWorkerManager::GetServiceWorkerRegistrationInfo(nsIPrincipal* aPrincipal,
|
|||
return GetServiceWorkerRegistrationInfo(originAttributesSuffix, aURI);
|
||||
}
|
||||
|
||||
already_AddRefed<ServiceWorkerRegistrationInfo>
|
||||
ServiceWorkerManager::GetServiceWorkerRegistrationInfo(const PrincipalOriginAttributes& aOriginAttributes,
|
||||
nsIURI* aURI)
|
||||
{
|
||||
MOZ_ASSERT(aURI);
|
||||
|
||||
nsAutoCString originAttributesSuffix;
|
||||
aOriginAttributes.CreateSuffix(originAttributesSuffix);
|
||||
return GetServiceWorkerRegistrationInfo(originAttributesSuffix, aURI);
|
||||
}
|
||||
|
||||
already_AddRefed<ServiceWorkerRegistrationInfo>
|
||||
ServiceWorkerManager::GetServiceWorkerRegistrationInfo(const nsACString& aScopeKey,
|
||||
nsIURI* aURI)
|
||||
|
@ -3683,8 +3674,12 @@ ServiceWorkerManager::DispatchFetchEvent(const PrincipalOriginAttributes& aOrigi
|
|||
return;
|
||||
}
|
||||
|
||||
// non-subresource request means the URI contains the principal
|
||||
nsCOMPtr<nsIPrincipal> principal =
|
||||
BasePrincipal::CreateCodebasePrincipal(uri, aOriginAttributes);
|
||||
|
||||
RefPtr<ServiceWorkerRegistrationInfo> registration =
|
||||
GetServiceWorkerRegistrationInfo(aOriginAttributes, uri);
|
||||
GetServiceWorkerRegistrationInfo(principal, uri);
|
||||
if (!registration) {
|
||||
NS_WARNING("No registration found when dispatching the fetch event");
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
|
@ -3726,13 +3721,14 @@ ServiceWorkerManager::DispatchFetchEvent(const PrincipalOriginAttributes& aOrigi
|
|||
}
|
||||
|
||||
bool
|
||||
ServiceWorkerManager::IsAvailable(const PrincipalOriginAttributes& aOriginAttributes,
|
||||
ServiceWorkerManager::IsAvailable(nsIPrincipal* aPrincipal,
|
||||
nsIURI* aURI)
|
||||
{
|
||||
MOZ_ASSERT(aPrincipal);
|
||||
MOZ_ASSERT(aURI);
|
||||
|
||||
RefPtr<ServiceWorkerRegistrationInfo> registration =
|
||||
GetServiceWorkerRegistrationInfo(aOriginAttributes, aURI);
|
||||
GetServiceWorkerRegistrationInfo(aPrincipal, aURI);
|
||||
return registration && registration->mActiveWorker;
|
||||
}
|
||||
|
||||
|
|
|
@ -374,7 +374,7 @@ public:
|
|||
nsClassHashtable<nsCStringHashKey, InterceptionList> mNavigationInterceptions;
|
||||
|
||||
bool
|
||||
IsAvailable(const PrincipalOriginAttributes& aOriginAttributes, nsIURI* aURI);
|
||||
IsAvailable(nsIPrincipal* aPrincipal, nsIURI* aURI);
|
||||
|
||||
bool
|
||||
IsControlled(nsIDocument* aDocument, ErrorResult& aRv);
|
||||
|
@ -573,10 +573,6 @@ private:
|
|||
already_AddRefed<ServiceWorkerRegistrationInfo>
|
||||
GetServiceWorkerRegistrationInfo(nsIPrincipal* aPrincipal, nsIURI* aURI);
|
||||
|
||||
already_AddRefed<ServiceWorkerRegistrationInfo>
|
||||
GetServiceWorkerRegistrationInfo(const PrincipalOriginAttributes& aOriginAttributes,
|
||||
nsIURI* aURI);
|
||||
|
||||
already_AddRefed<ServiceWorkerRegistrationInfo>
|
||||
GetServiceWorkerRegistrationInfo(const nsACString& aScopeKey,
|
||||
nsIURI* aURI);
|
||||
|
|
Загрузка…
Ссылка в новой задаче