Title: [224955] trunk/Source/WebCore
Revision
224955
Author
[email protected]
Date
2017-11-16 18:32:12 -0800 (Thu, 16 Nov 2017)

Log Message

Make sure service workers get terminated between tests
https://bugs.webkit.org/show_bug.cgi?id=179774

Reviewed by Alex Christensen.

Make sure service workers get terminated between tests. Previously, we
would merely clear all registrations and job queues but it would not
cause the registrations' service workers to get terminated.

* workers/service/context/ServiceWorkerThread.cpp:
(WebCore::ServiceWorkerThread::updateExtendedEventsSet):
* workers/service/server/SWServer.cpp:
(WebCore::SWServer::clearAll):
* workers/service/server/SWServerJobQueue.cpp:
(WebCore::SWServerJobQueue::scriptFetchFinished):
(WebCore::SWServerJobQueue::scriptContextFailedToStart):
(WebCore::SWServerJobQueue::didFinishInstall):
(WebCore::SWServerJobQueue::tryClearRegistration):
(WebCore::SWServerJobQueue::clearRegistration):
* workers/service/server/SWServerJobQueue.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (224954 => 224955)


--- trunk/Source/WebCore/ChangeLog	2017-11-17 02:29:04 UTC (rev 224954)
+++ trunk/Source/WebCore/ChangeLog	2017-11-17 02:32:12 UTC (rev 224955)
@@ -1,3 +1,26 @@
+2017-11-16  Chris Dumez  <[email protected]>
+
+        Make sure service workers get terminated between tests
+        https://bugs.webkit.org/show_bug.cgi?id=179774
+
+        Reviewed by Alex Christensen.
+
+        Make sure service workers get terminated between tests. Previously, we
+        would merely clear all registrations and job queues but it would not
+        cause the registrations' service workers to get terminated.
+
+        * workers/service/context/ServiceWorkerThread.cpp:
+        (WebCore::ServiceWorkerThread::updateExtendedEventsSet):
+        * workers/service/server/SWServer.cpp:
+        (WebCore::SWServer::clearAll):
+        * workers/service/server/SWServerJobQueue.cpp:
+        (WebCore::SWServerJobQueue::scriptFetchFinished):
+        (WebCore::SWServerJobQueue::scriptContextFailedToStart):
+        (WebCore::SWServerJobQueue::didFinishInstall):
+        (WebCore::SWServerJobQueue::tryClearRegistration):
+        (WebCore::SWServerJobQueue::clearRegistration):
+        * workers/service/server/SWServerJobQueue.h:
+
 2017-11-16  Youenn Fablet  <[email protected]>
 
         FetchLoader should unregister its blob URL

Modified: trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp (224954 => 224955)


--- trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp	2017-11-17 02:29:04 UTC (rev 224954)
+++ trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp	2017-11-17 02:32:12 UTC (rev 224955)
@@ -175,6 +175,9 @@
         newEvent->whenAllExtendLifetimePromisesAreSettled([this](auto&&) {
             updateExtendedEventsSet();
         });
+        // Clear out the event's target as it is the WorkerGlobalScope and we do not want to keep it
+        // alive unnecessarily.
+        newEvent->setTarget(nullptr);
     }
 
     bool hasPendingEvents = this->hasPendingEvents();

Modified: trunk/Source/WebCore/workers/service/server/SWServer.cpp (224954 => 224955)


--- trunk/Source/WebCore/workers/service/server/SWServer.cpp	2017-11-17 02:29:04 UTC (rev 224954)
+++ trunk/Source/WebCore/workers/service/server/SWServer.cpp	2017-11-17 02:32:12 UTC (rev 224955)
@@ -130,9 +130,9 @@
 void SWServer::clearAll()
 {
     m_jobQueues.clear();
-    m_registrations.clear();
+    while (!m_registrations.isEmpty())
+        SWServerJobQueue::clearRegistration(*this, *m_registrations.begin()->value);
     m_originStore->clearAll();
-    // FIXME: We should probably ask service workers to terminate.
 }
 
 void SWServer::clear(const SecurityOrigin& origin)

Modified: trunk/Source/WebCore/workers/service/server/SWServerJobQueue.cpp (224954 => 224955)


--- trunk/Source/WebCore/workers/service/server/SWServerJobQueue.cpp	2017-11-17 02:29:04 UTC (rev 224954)
+++ trunk/Source/WebCore/workers/service/server/SWServerJobQueue.cpp	2017-11-17 02:32:12 UTC (rev 224955)
@@ -73,7 +73,7 @@
 
         // If newestWorker is null, invoke Clear Registration algorithm passing registration as its argument.
         if (!newestWorker)
-            clearRegistration(*registration);
+            clearRegistration(m_server, *registration);
 
         // Invoke Finish Job with job and abort these steps.
         finishCurrentJob();
@@ -102,7 +102,7 @@
 
     // If newestWorker is null, invoke Clear Registration algorithm passing registration as its argument.
     if (!registration->getNewestWorker())
-        clearRegistration(*registration);
+        clearRegistration(m_server, *registration);
 
     // Invoke Finish Job with job and abort these steps.
     finishCurrentJob();
@@ -166,7 +166,7 @@
 
         // If newestWorker is null, invoke Clear Registration algorithm passing registration as its argument.
         if (!registration->getNewestWorker())
-            clearRegistration(*registration);
+            clearRegistration(m_server, *registration);
         // Invoke Finish Job with job and abort these steps.
         finishCurrentJob();
         return;
@@ -349,7 +349,7 @@
     if (registration.activeWorker() && registration.activeWorker()->hasPendingEvents())
         return;
 
-    clearRegistration(registration);
+    clearRegistration(m_server, registration);
 }
 
 // https://w3c.github.io/ServiceWorker/#clear-registration
@@ -364,7 +364,7 @@
 }
 
 // https://w3c.github.io/ServiceWorker/#clear-registration
-void SWServerJobQueue::clearRegistration(SWServerRegistration& registration)
+void SWServerJobQueue::clearRegistration(SWServer& server, SWServerRegistration& registration)
 {
     clearRegistrationWorker(registration, registration.installingWorker(), ServiceWorkerRegistrationState::Installing);
     clearRegistrationWorker(registration, registration.waitingWorker(), ServiceWorkerRegistrationState::Waiting);
@@ -371,7 +371,7 @@
     clearRegistrationWorker(registration, registration.activeWorker(), ServiceWorkerRegistrationState::Active);
 
     // Remove scope to registration map[scopeString].
-    m_server.removeRegistration(registration.key());
+    server.removeRegistration(registration.key());
 }
 
 // https://w3c.github.io/ServiceWorker/#update-algorithm

Modified: trunk/Source/WebCore/workers/service/server/SWServerJobQueue.h (224954 => 224955)


--- trunk/Source/WebCore/workers/service/server/SWServerJobQueue.h	2017-11-17 02:29:04 UTC (rev 224954)
+++ trunk/Source/WebCore/workers/service/server/SWServerJobQueue.h	2017-11-17 02:32:12 UTC (rev 224955)
@@ -54,6 +54,8 @@
     static void didFinishActivation(SWServerRegistration&, ServiceWorkerIdentifier);
     void didResolveRegistrationPromise();
 
+    static void clearRegistration(SWServer&, SWServerRegistration&);
+
 private:
     void jobTimerFired();
     void runNextJobSynchronously();
@@ -65,7 +67,6 @@
     void runUpdateJob(const ServiceWorkerJobData&);
 
     void tryClearRegistration(SWServerRegistration&);
-    void clearRegistration(SWServerRegistration&);
     void install(SWServerRegistration&, ServiceWorkerIdentifier);
     static void tryActivate(SWServer&, SWServerRegistration&);
     static void activate(SWServer&, SWServerRegistration&);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to