Title: [293719] trunk
Revision
293719
Author
[email protected]
Date
2022-05-03 01:06:52 -0700 (Tue, 03 May 2022)

Log Message

ServiceWorkerRegistration update should fail if called from an installing service worker context
https://bugs.webkit.org/show_bug.cgi?id=239962

Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

* web-platform-tests/service-workers/service-worker/update-not-allowed.https-expected.txt:

Source/WebCore:

Implement step 4 of https://w3c.github.io/ServiceWorker/#service-worker-registration-update.
Covered by rebased test.

* workers/service/ServiceWorkerRegistration.cpp:
(WebCore::ServiceWorkerRegistration::update):

LayoutTests:

* TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (293718 => 293719)


--- trunk/LayoutTests/ChangeLog	2022-05-03 07:47:42 UTC (rev 293718)
+++ trunk/LayoutTests/ChangeLog	2022-05-03 08:06:52 UTC (rev 293719)
@@ -1,3 +1,12 @@
+2022-05-03  Youenn Fablet  <[email protected]>
+
+        ServiceWorkerRegistration update should fail if called from an installing service worker context
+        https://bugs.webkit.org/show_bug.cgi?id=239962
+
+        Reviewed by Chris Dumez.
+
+        * TestExpectations:
+
 2022-05-02  Robert Jenner  <[email protected]>
 
         [ Monterey wk1 GuardMalloc ] fast/borders/hidpi-3x-input-hairline-border.html is timing out

Modified: trunk/LayoutTests/TestExpectations (293718 => 293719)


--- trunk/LayoutTests/TestExpectations	2022-05-03 07:47:42 UTC (rev 293718)
+++ trunk/LayoutTests/TestExpectations	2022-05-03 08:06:52 UTC (rev 293719)
@@ -370,7 +370,6 @@
 webkit.org/b/201666 imported/w3c/web-platform-tests/service-workers/service-worker/fetch-canvas-tainting-video-with-range-request.https.html [ Skip ]
 
 # Newly imported service worker tests that are flaky.
-imported/w3c/web-platform-tests/service-workers/service-worker/update-not-allowed.https.html [ Pass Failure ]
 imported/w3c/web-platform-tests/service-workers/service-worker/performance-timeline.https.html [ Pass Failure ]
 
 # Failures due to bumping WPT tools repository.

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (293718 => 293719)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2022-05-03 07:47:42 UTC (rev 293718)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2022-05-03 08:06:52 UTC (rev 293719)
@@ -1,3 +1,12 @@
+2022-05-03  Youenn Fablet  <[email protected]>
+
+        ServiceWorkerRegistration update should fail if called from an installing service worker context
+        https://bugs.webkit.org/show_bug.cgi?id=239962
+
+        Reviewed by Chris Dumez.
+
+        * web-platform-tests/service-workers/service-worker/update-not-allowed.https-expected.txt:
+
 2022-05-02  Youenn Fablet  <[email protected]>
 
         URL.createObjectURL should not be exposed in service worker contexts

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/update-not-allowed.https-expected.txt (293718 => 293719)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/update-not-allowed.https-expected.txt	2022-05-03 07:47:42 UTC (rev 293718)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/update-not-allowed.https-expected.txt	2022-05-03 08:06:52 UTC (rev 293719)
@@ -1,5 +1,5 @@
 
 PASS ServiceWorkerRegistration.update() from client succeeds while installing service worker.
-FAIL ServiceWorkerRegistration.update() from installing service worker throws. assert_false: update() should have failed. expected false got true
+PASS ServiceWorkerRegistration.update() from installing service worker throws.
 PASS ServiceWorkerRegistration.update() from active service worker succeeds while installing service worker.
 

Modified: trunk/Source/WebCore/ChangeLog (293718 => 293719)


--- trunk/Source/WebCore/ChangeLog	2022-05-03 07:47:42 UTC (rev 293718)
+++ trunk/Source/WebCore/ChangeLog	2022-05-03 08:06:52 UTC (rev 293719)
@@ -1,3 +1,16 @@
+2022-05-03  Youenn Fablet  <[email protected]>
+
+        ServiceWorkerRegistration update should fail if called from an installing service worker context
+        https://bugs.webkit.org/show_bug.cgi?id=239962
+
+        Reviewed by Chris Dumez.
+
+        Implement step 4 of https://w3c.github.io/ServiceWorker/#service-worker-registration-update.
+        Covered by rebased test.
+
+        * workers/service/ServiceWorkerRegistration.cpp:
+        (WebCore::ServiceWorkerRegistration::update):
+
 2022-05-02  Youenn Fablet  <[email protected]>
 
         URL.createObjectURL should not be exposed in service worker contexts

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.cpp (293718 => 293719)


--- trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.cpp	2022-05-03 07:47:42 UTC (rev 293718)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.cpp	2022-05-03 08:06:52 UTC (rev 293719)
@@ -155,6 +155,11 @@
         return;
     }
 
+    if (auto* serviceWorkerGlobalScope = dynamicDowncast<ServiceWorkerGlobalScope>(scriptExecutionContext()); serviceWorkerGlobalScope && serviceWorkerGlobalScope->serviceWorker().state() == ServiceWorkerState::Installing) {
+        promise->reject(Exception(InvalidStateError, "service worker is installing"_s));
+        return;
+    }
+
     m_container->updateRegistration(m_registrationData.scopeURL, newestWorker->scriptURL(), newestWorker->workerType(), WTFMove(promise));
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to