From 16a0a6ed9c679a0142b3d5af3876598074b44a00 Mon Sep 17 00:00:00 2001 From: "Carsten \"Tomcat\" Book" Date: Tue, 17 Feb 2015 09:35:58 +0100 Subject: [PATCH] Backed out changeset 4ed31c8b45c6 (bug 1041340) for causing multiple timeouts on different platforms in service worker tests on a CLOSED TREE --- dom/workers/ServiceWorkerManager.cpp | 41 ++++--------------- dom/workers/ServiceWorkerManager.h | 7 +--- .../test_installation_simple.html | 3 +- 3 files changed, 12 insertions(+), 39 deletions(-) diff --git a/dom/workers/ServiceWorkerManager.cpp b/dom/workers/ServiceWorkerManager.cpp index 4f5682d251d..991f9ee35c8 100644 --- a/dom/workers/ServiceWorkerManager.cpp +++ b/dom/workers/ServiceWorkerManager.cpp @@ -1930,6 +1930,10 @@ void ServiceWorkerManager::MaybeStartControlling(nsIDocument* aDoc) { AssertIsOnMainThread(); + if (!Preferences::GetBool("dom.serviceWorkers.enabled")) { + return; + } + nsRefPtr registration = GetServiceWorkerRegistrationInfo(aDoc); if (registration) { @@ -1941,35 +1945,14 @@ ServiceWorkerManager::MaybeStartControlling(nsIDocument* aDoc) } } -class ServiceWorkerActivateAfterUnloadingJob MOZ_FINAL : public ServiceWorkerJob -{ - nsRefPtr mRegistration; -public: - ServiceWorkerActivateAfterUnloadingJob(ServiceWorkerJobQueue* aQueue, - ServiceWorkerRegistrationInfo* aReg) - : ServiceWorkerJob(aQueue) - , mRegistration(aReg) - { } - - void - Start() - { - if (mRegistration->mPendingUninstall) { - mRegistration->Clear(); - nsRefPtr swm = ServiceWorkerManager::GetInstance(); - swm->RemoveRegistration(mRegistration); - } else { - mRegistration->TryToActivate(); - } - - Done(NS_OK); - } -}; - void ServiceWorkerManager::MaybeStopControlling(nsIDocument* aDoc) { MOZ_ASSERT(aDoc); + if (!Preferences::GetBool("dom.serviceWorkers.enabled")) { + return; + } + nsRefPtr registration; mControlledDocuments.Remove(aDoc, getter_AddRefs(registration)); // A document which was uncontrolled does not maintain that state itself, so @@ -1977,14 +1960,6 @@ ServiceWorkerManager::MaybeStopControlling(nsIDocument* aDoc) // associated registration. So this check is required. if (registration) { registration->StopControllingADocument(); - if (!registration->IsControllingDocuments()) { - ServiceWorkerJobQueue* queue = GetOrCreateJobQueue(registration->mScope); - // The remaining tasks touch registration->mPendingUninstall, so queue - // them up in a job. - nsRefPtr job = - new ServiceWorkerActivateAfterUnloadingJob(queue, registration); - queue->Append(job); - } } } diff --git a/dom/workers/ServiceWorkerManager.h b/dom/workers/ServiceWorkerManager.h index 01bb5ff528e..00fbd179978 100644 --- a/dom/workers/ServiceWorkerManager.h +++ b/dom/workers/ServiceWorkerManager.h @@ -290,13 +290,12 @@ class ServiceWorkerManager MOZ_FINAL , public nsIIPCBackgroundChildCreateCallback { friend class ActivationRunnable; + friend class ServiceWorkerRegistrationInfo; + friend class ServiceWorkerRegisterJob; friend class GetReadyPromiseRunnable; friend class GetRegistrationsRunnable; friend class GetRegistrationRunnable; friend class QueueFireUpdateFoundRunnable; - friend class ServiceWorkerActivateAfterUnloadingJob; - friend class ServiceWorkerRegisterJob; - friend class ServiceWorkerRegistrationInfo; friend class ServiceWorkerUnregisterJob; public: @@ -350,8 +349,6 @@ public: void RemoveRegistration(ServiceWorkerRegistrationInfo* aRegistration) { - MOZ_ASSERT(aRegistration); - MOZ_ASSERT(!aRegistration->IsControllingDocuments()); MOZ_ASSERT(mServiceWorkerRegistrationInfos.Contains(aRegistration->mScope)); ServiceWorkerManager::RemoveScope(mOrderedScopes, aRegistration->mScope); mServiceWorkerRegistrationInfos.Remove(aRegistration->mScope); diff --git a/dom/workers/test/serviceworkers/test_installation_simple.html b/dom/workers/test/serviceworkers/test_installation_simple.html index 42de8b905e9..c0fc0ef3483 100644 --- a/dom/workers/test/serviceworkers/test_installation_simple.html +++ b/dom/workers/test/serviceworkers/test_installation_simple.html @@ -140,7 +140,8 @@ window.onmessage = null; // We have to make frame navigate away, otherwise it will call // MaybeStopControlling() when this document is unloaded. At that point - // the pref has been disabled, so the ServiceWorkerManager is not available. + // the pref has been disabled, and so MaybeStopControlling() will just + // return since it is currently gated. frame.setAttribute("src", new URL("about:blank").href); resolve(); } else if (e.data.type == "check") {