diff --git a/dom/workers/ServiceWorkerManager.cpp b/dom/workers/ServiceWorkerManager.cpp index 6d5f00f2f0f7..4b037843b541 100644 --- a/dom/workers/ServiceWorkerManager.cpp +++ b/dom/workers/ServiceWorkerManager.cpp @@ -1304,9 +1304,16 @@ ServiceWorkerManager::WorkerIsIdle(ServiceWorkerInfo* aWorker) return; } - if (reg->GetActive() == aWorker) { - reg->TryToActivateAsync(); + if (reg->GetActive() != aWorker) { + return; } + + if (!reg->IsControllingDocuments() && reg->mPendingUninstall) { + RemoveRegistration(reg); + return; + } + + reg->TryToActivateAsync(); } already_AddRefed @@ -2001,7 +2008,7 @@ void ServiceWorkerManager::StopControllingADocument(ServiceWorkerRegistrationInfo* aRegistration) { aRegistration->StopControllingADocument(); - if (aRegistration->IsControllingDocuments()) { + if (aRegistration->IsControllingDocuments() || !aRegistration->IsIdle()) { return; } diff --git a/dom/workers/ServiceWorkerUnregisterJob.cpp b/dom/workers/ServiceWorkerUnregisterJob.cpp index cc19a6ec0264..b56d0b761eec 100644 --- a/dom/workers/ServiceWorkerUnregisterJob.cpp +++ b/dom/workers/ServiceWorkerUnregisterJob.cpp @@ -139,7 +139,7 @@ ServiceWorkerUnregisterJob::Unregister() InvokeResultCallbacks(NS_OK); // "If no service worker client is using registration..." - if (!registration->IsControllingDocuments()) { + if (!registration->IsControllingDocuments() && registration->IsIdle()) { // "Invoke [[Clear Registration]]..." swm->RemoveRegistration(registration); }