mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1113631 - Remove registration when installation failure occurs. Fixes spec issue #547. r=baku
This commit is contained in:
parent
ea81aa3901
commit
b42d453262
@ -532,8 +532,7 @@ public:
|
||||
{
|
||||
MOZ_ASSERT(mCallback);
|
||||
mCallback->UpdateFailed(aError);
|
||||
mCallback = nullptr;
|
||||
Done(NS_ERROR_DOM_JS_EXCEPTION);
|
||||
FailCommon(NS_ERROR_DOM_JS_EXCEPTION);
|
||||
}
|
||||
|
||||
// Public so our error handling code can continue with a successful worker.
|
||||
@ -661,16 +660,39 @@ private:
|
||||
mCallback = nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
FailCommon(nsresult aRv)
|
||||
{
|
||||
mCallback = nullptr;
|
||||
MaybeRemoveRegistration();
|
||||
// Ensures that the job can't do anything useful from this point on.
|
||||
mRegistration = nullptr;
|
||||
Done(aRv);
|
||||
}
|
||||
|
||||
// This MUST only be called when the job is still performing actions related
|
||||
// to registration or update. After the spec resolves the update promise, use
|
||||
// Done() with the failure code instead.
|
||||
void
|
||||
Fail(nsresult rv)
|
||||
Fail(nsresult aRv)
|
||||
{
|
||||
MOZ_ASSERT(mCallback);
|
||||
mCallback->UpdateFailed(rv);
|
||||
mCallback = nullptr;
|
||||
Done(rv);
|
||||
mCallback->UpdateFailed(aRv);
|
||||
FailCommon(aRv);
|
||||
}
|
||||
|
||||
void
|
||||
MaybeRemoveRegistration()
|
||||
{
|
||||
MOZ_ASSERT(mRegistration);
|
||||
nsRefPtr<ServiceWorkerInfo> newest = mRegistration->Newest();
|
||||
if (!newest) {
|
||||
nsRefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
|
||||
nsRefPtr<ServiceWorkerManager::ServiceWorkerDomainInfo> domainInfo =
|
||||
swm->GetDomainInfo(mRegistration->mScope);
|
||||
MOZ_ASSERT(domainInfo);
|
||||
domainInfo->RemoveRegistration(mRegistration);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -693,6 +715,7 @@ private:
|
||||
mRegistration->mInstallingWorker = nullptr;
|
||||
swm->InvalidateServiceWorkerRegistrationWorker(mRegistration,
|
||||
WhichServiceWorker::INSTALLING_WORKER);
|
||||
MaybeRemoveRegistration();
|
||||
return Done(NS_ERROR_DOM_ABORT_ERR);
|
||||
}
|
||||
|
||||
|
@ -106,6 +106,10 @@
|
||||
var p = navigator.serviceWorker.register("parse_error_worker.js", { scope: "parse_error/" });
|
||||
return p.then(function(wr) {
|
||||
ok(false, "Registration should fail with parse error");
|
||||
return navigator.serviceWorker.getRegistration("parse_error/").then(function(swr) {
|
||||
// See https://github.com/slightlyoff/ServiceWorker/issues/547
|
||||
is(swr, undefined, "A failed registration for a scope with no prior controllers should clear itself");
|
||||
});
|
||||
}, function(e) {
|
||||
info("NSM " + e.name);
|
||||
ok(e instanceof Error, "Registration should fail with parse error");
|
||||
|
Loading…
Reference in New Issue
Block a user