Clearing a registration should null out its workers before setting their state to...
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Feb 2018 17:33:53 +0000 (17:33 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Feb 2018 17:33:53 +0000 (17:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=182418
<rdar://problem/37142874>

Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

Rebaseline WPT test now that all checks are passing. I verified that this test is passing
in both Firefox and Chrome.

* web-platform-tests/service-workers/service-worker/activation.https-expected.txt:

Source/WebCore:

Clearing a registration should null out its workers before setting their state to "redundant".
This seems to match Firefox and Chrome.

No new tests, rebaselined existing test.

* workers/service/server/SWServerRegistration.cpp:
(WebCore::SWServerRegistration::clear):
(WebCore::clearRegistrationWorker): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@228015 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/activation.https-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/workers/service/server/SWServerRegistration.cpp

index 9a541be..ba52a97 100644 (file)
@@ -1,3 +1,16 @@
+2018-02-02  Chris Dumez  <cdumez@apple.com>
+
+        Clearing a registration should null out its workers before setting their state to "redundant"
+        https://bugs.webkit.org/show_bug.cgi?id=182418
+        <rdar://problem/37142874>
+
+        Reviewed by Youenn Fablet.
+
+        Rebaseline WPT test now that all checks are passing. I verified that this test is passing
+        in both Firefox and Chrome.
+
+        * web-platform-tests/service-workers/service-worker/activation.https-expected.txt:
+
 2018-02-02  Ms2ger  <Ms2ger@igalia.com>
 
         Update imagebitmap tests.
index 02387fc..55d784b 100644 (file)
@@ -3,5 +3,5 @@
 PASS loss of controllees triggers activation 
 PASS finishing a request triggers activation 
 PASS skipWaiting bypasses no controllee requirement 
-FAIL finishing a request triggers unregister assert_equals: expected null but got object "[object ServiceWorker]"
+PASS finishing a request triggers unregister 
 
index 755d56a..ba4685e 100644 (file)
@@ -1,3 +1,20 @@
+2018-02-02  Chris Dumez  <cdumez@apple.com>
+
+        Clearing a registration should null out its workers before setting their state to "redundant"
+        https://bugs.webkit.org/show_bug.cgi?id=182418
+        <rdar://problem/37142874>
+
+        Reviewed by Youenn Fablet.
+
+        Clearing a registration should null out its workers before setting their state to "redundant".
+        This seems to match Firefox and Chrome.
+
+        No new tests, rebaselined existing test.
+
+        * workers/service/server/SWServerRegistration.cpp:
+        (WebCore::SWServerRegistration::clear):
+        (WebCore::clearRegistrationWorker): Deleted.
+
 2018-02-02  Antoine Quint  <graouts@apple.com>
 
         [Modern Media Controls] Turn media/modern-media-controls/tracks-panel and media/modern-media-controls/tracks-support back on
index 3ae83cd..136ae20 100644 (file)
@@ -228,17 +228,6 @@ bool SWServerRegistration::tryClear()
 }
 
 // https://w3c.github.io/ServiceWorker/#clear-registration
-static void clearRegistrationWorker(SWServerRegistration& registration, SWServerWorker* worker, ServiceWorkerRegistrationState state)
-{
-    if (!worker)
-        return;
-
-    worker->terminate();
-    registration.updateWorkerState(*worker, ServiceWorkerState::Redundant);
-    registration.updateRegistrationState(state, nullptr);
-}
-
-// https://w3c.github.io/ServiceWorker/#clear-registration
 void SWServerRegistration::clear()
 {
     if (m_preInstallationWorker) {
@@ -247,9 +236,28 @@ void SWServerRegistration::clear()
         m_preInstallationWorker = nullptr;
     }
 
-    clearRegistrationWorker(*this, installingWorker(), ServiceWorkerRegistrationState::Installing);
-    clearRegistrationWorker(*this, waitingWorker(), ServiceWorkerRegistrationState::Waiting);
-    clearRegistrationWorker(*this, activeWorker(), ServiceWorkerRegistrationState::Active);
+    RefPtr<SWServerWorker> installingWorker = this->installingWorker();
+    if (installingWorker) {
+        installingWorker->terminate();
+        updateRegistrationState(ServiceWorkerRegistrationState::Installing, nullptr);
+    }
+    RefPtr<SWServerWorker> waitingWorker = this->waitingWorker();
+    if (waitingWorker) {
+        waitingWorker->terminate();
+        updateRegistrationState(ServiceWorkerRegistrationState::Waiting, nullptr);
+    }
+    RefPtr<SWServerWorker> activeWorker = this->activeWorker();
+    if (activeWorker) {
+        activeWorker->terminate();
+        updateRegistrationState(ServiceWorkerRegistrationState::Active, nullptr);
+    }
+
+    if (installingWorker)
+        updateWorkerState(*installingWorker, ServiceWorkerState::Redundant);
+    if (waitingWorker)
+        updateWorkerState(*waitingWorker, ServiceWorkerState::Redundant);
+    if (activeWorker)
+        updateWorkerState(*activeWorker, ServiceWorkerState::Redundant);
 
     // Remove scope to registration map[scopeString].
     m_server.removeRegistration(key());