зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1336364 P5 Disable service worker getRegistrations() if storage is disallowed for a window. r=asuth
This commit is contained in:
Родитель
2e6f616841
Коммит
3e50d90115
|
@ -1080,14 +1080,19 @@ ServiceWorkerManager::GetRegistrations(mozIDOMWindow* aWindow,
|
|||
}
|
||||
|
||||
auto* window = nsPIDOMWindowInner::From(aWindow);
|
||||
nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
|
||||
if (NS_WARN_IF(!doc)) {
|
||||
return NS_ERROR_DOM_INVALID_STATE_ERR;
|
||||
|
||||
// Don't allow a service worker to access service worker registrations
|
||||
// from a window with storage disabled. If these windows can access
|
||||
// the registration it increases the chance they can bypass the storage
|
||||
// block via postMessage(), etc.
|
||||
auto storageAllowed = nsContentUtils::StorageAllowedForWindow(window);
|
||||
if (storageAllowed != nsContentUtils::StorageAccess::eAllow) {
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
}
|
||||
|
||||
// Don't allow service workers to register when the *document* is chrome for
|
||||
// now.
|
||||
MOZ_ASSERT(!nsContentUtils::IsSystemPrincipal(doc->NodePrincipal()));
|
||||
MOZ_ASSERT(!nsContentUtils::IsSystemPrincipal(window->GetExtantDoc()->NodePrincipal()));
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> sgo = do_QueryInterface(window);
|
||||
ErrorResult result;
|
||||
|
@ -1193,14 +1198,19 @@ ServiceWorkerManager::GetRegistration(mozIDOMWindow* aWindow,
|
|||
}
|
||||
|
||||
auto* window = nsPIDOMWindowInner::From(aWindow);
|
||||
nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
|
||||
if (NS_WARN_IF(!doc)) {
|
||||
return NS_ERROR_DOM_INVALID_STATE_ERR;
|
||||
|
||||
// Don't allow a service worker to access service worker registrations
|
||||
// from a window with storage disabled. If these windows can access
|
||||
// the registration it increases the chance they can bypass the storage
|
||||
// block via postMessage(), etc.
|
||||
auto storageAllowed = nsContentUtils::StorageAllowedForWindow(window);
|
||||
if (storageAllowed != nsContentUtils::StorageAccess::eAllow) {
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
}
|
||||
|
||||
// Don't allow service workers to register when the *document* is chrome for
|
||||
// now.
|
||||
MOZ_ASSERT(!nsContentUtils::IsSystemPrincipal(doc->NodePrincipal()));
|
||||
MOZ_ASSERT(!nsContentUtils::IsSystemPrincipal(window->GetExtantDoc()->NodePrincipal()));
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> sgo = do_QueryInterface(window);
|
||||
ErrorResult result;
|
||||
|
|
|
@ -166,6 +166,15 @@ function testShouldNotIntercept(policy, done) {
|
|||
next: function() {
|
||||
iframe.src = thirdPartyOrigin + basePath + "unregister.html";
|
||||
}
|
||||
}, {
|
||||
status: "getregistrationfailed",
|
||||
next: function() {
|
||||
SpecialPowers.pushPrefEnv({"set": [
|
||||
["network.cookie.cookieBehavior", COOKIE_BEHAVIOR_ACCEPT],
|
||||
]}, function() {
|
||||
iframe.src = thirdPartyOrigin + basePath + "unregister.html";
|
||||
});
|
||||
}
|
||||
}, {
|
||||
status: "unregistrationdone",
|
||||
next: function() {
|
||||
|
|
|
@ -7,5 +7,7 @@
|
|||
registration.unregister().then(() => {
|
||||
window.parent.postMessage({status: "unregistrationdone"}, "*");
|
||||
});
|
||||
}).catch(function(e) {
|
||||
window.parent.postMessage({status: "getregistrationfailed"}, "*");
|
||||
});
|
||||
</script>
|
||||
|
|
Загрузка…
Ссылка в новой задаче