LayoutTest http/tests/workers/service/registration-clear-redundant-worker.html is...
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Nov 2017 02:31:43 +0000 (02:31 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Nov 2017 02:31:43 +0000 (02:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=179778

Reviewed by Youenn Fablet.

As per the specification [1], when clearing a registration, the registration's workers are first
marked as redundant *before* the registration's worker is set to null.

The test was waiting for the service worker's state to become redundant and then checking in a
setTimeout(0) that the registration's worker became null. However, a setTimeout(0) is racy here.
To address the issue, we now use setInterval() and wait until the worker becomes null.

[1] https://w3c.github.io/ServiceWorker/#clear-registration-algorithm

* TestExpectations:
* http/tests/workers/service/registration-clear-redundant-worker.html:

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

LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/http/tests/workers/service/registration-clear-redundant-worker.html

index f1102fc..6cacb8e 100644 (file)
@@ -1,3 +1,22 @@
+2017-11-29  Chris Dumez  <cdumez@apple.com>
+
+        LayoutTest http/tests/workers/service/registration-clear-redundant-worker.html is a flaky failure
+        https://bugs.webkit.org/show_bug.cgi?id=179778
+
+        Reviewed by Youenn Fablet.
+
+        As per the specification [1], when clearing a registration, the registration's workers are first
+        marked as redundant *before* the registration's worker is set to null.
+
+        The test was waiting for the service worker's state to become redundant and then checking in a
+        setTimeout(0) that the registration's worker became null. However, a setTimeout(0) is racy here.
+        To address the issue, we now use setInterval() and wait until the worker becomes null.
+
+        [1] https://w3c.github.io/ServiceWorker/#clear-registration-algorithm
+
+        * TestExpectations:
+        * http/tests/workers/service/registration-clear-redundant-worker.html:
+
 2017-11-29  Youenn Fablet  <youenn@apple.com>
 
         ServiceWorkerClient objects should be reused if there is already one existing with the same identifier
index f57e6ee..10b7628 100644 (file)
@@ -183,7 +183,6 @@ imported/w3c/web-platform-tests/service-workers/service-worker/update-recovery.h
 imported/w3c/web-platform-tests/service-workers/service-worker/websocket-in-service-worker.https.html [ Skip ]
 imported/w3c/web-platform-tests/service-workers/service-worker/client-navigate.https.html [ Skip ]
 
-webkit.org/b/179778 http/tests/workers/service/registration-clear-redundant-worker.html [ Pass Failure ]
 http/tests/workers/service/service-worker-cache-api.https.html [ Pass Failure ]
 webkit.org/b/179137 imported/w3c/web-platform-tests/service-workers/cache-storage/serviceworker/cache-match.https.html [ Pass Failure ]
 imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event.https.html [ Pass Failure ]
index 72bc519..e47532a 100644 (file)
@@ -15,21 +15,22 @@ navigator.serviceWorker.register("resources/resources/empty-worker.js", { }).the
         }).then(function() {
             waitForState(worker, "redundant").then(function() {
                 log("PASS: Worker became redundant after unregistering");
-                setTimeout(function() {
-                    if (registration.installing)
-                        log("FAIL: registration.installing should be null");
-                    else
-                        log("PASS: registration.installing is null");
+                if (registration.installing)
+                    log("FAIL: registration.installing should be null");
+                else
+                    log("PASS: registration.installing is null");
 
-                    if (registration.waiting)
-                        log("FAIL: registration.waiting should be null");
-                    else
-                        log("PASS: registration.waiting is null");
+                if (registration.waiting)
+                    log("FAIL: registration.waiting should be null");
+                else
+                    log("PASS: registration.waiting is null");
 
+                handle = setInterval(function() {
                     if (registration.active)
-                        log("FAIL: registration.active should be null");
-                    else
-                        log("PASS: registration.active is null");
+                        return;
+
+                    log("PASS: registration.active is null");
+                    clearInterval(handle);
 
                     finishSWTest();
                 }, 0);