Title: [224337] trunk
Revision
224337
Author
cdu...@apple.com
Date
2017-11-02 09:58:00 -0700 (Thu, 02 Nov 2017)

Log Message

[Service Workers] Add initial implementation for try Clear Registration / Clear Registration algorithms
https://bugs.webkit.org/show_bug.cgi?id=179151

Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

Rebbaseline several WPT tests now that registrations are actually removed.

* web-platform-tests/service-workers/service-worker/multi-globals/url-parsing.https-expected.txt:
* web-platform-tests/service-workers/service-worker/registration-basic.https-expected.txt:
* web-platform-tests/service-workers/service-worker/registration-scope.https-expected.txt:
* web-platform-tests/service-workers/service-worker/serviceworkerobject-scripturl.https-expected.txt:

Source/WebCore:

[Service Workers] Add initial implementation for try Clear Registration / Clear Registration algorithms:
- https://w3c.github.io/ServiceWorker/#try-clear-registration
- https://w3c.github.io/ServiceWorker/#clear-registration

* workers/service/server/SWServerJobQueue.cpp:
(WebCore::SWServerJobQueue::scriptFetchFinished):
(WebCore::SWServerJobQueue::runUnregisterJob):
(WebCore::SWServerJobQueue::tryClearRegistration):
(WebCore::SWServerJobQueue::clearRegistration):
* workers/service/server/SWServerJobQueue.h:

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (224336 => 224337)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2017-11-02 16:55:26 UTC (rev 224336)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2017-11-02 16:58:00 UTC (rev 224337)
@@ -1,3 +1,17 @@
+2017-11-02  Chris Dumez  <cdu...@apple.com>
+
+        [Service Workers] Add initial implementation for try Clear Registration / Clear Registration algorithms
+        https://bugs.webkit.org/show_bug.cgi?id=179151
+
+        Reviewed by Youenn Fablet.
+
+        Rebbaseline several WPT tests now that registrations are actually removed.
+
+        * web-platform-tests/service-workers/service-worker/multi-globals/url-parsing.https-expected.txt:
+        * web-platform-tests/service-workers/service-worker/registration-basic.https-expected.txt:
+        * web-platform-tests/service-workers/service-worker/registration-scope.https-expected.txt:
+        * web-platform-tests/service-workers/service-worker/serviceworkerobject-scripturl.https-expected.txt:
+
 2017-11-01  Chris Dumez  <cdu...@apple.com>
 
         Regression(r219659): Can no longer log into ifttt.com using Google account

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/multi-globals/url-parsing.https-expected.txt (224336 => 224337)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/multi-globals/url-parsing.https-expected.txt	2017-11-02 16:55:26 UTC (rev 224336)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/multi-globals/url-parsing.https-expected.txt	2017-11-02 16:58:00 UTC (rev 224337)
@@ -1,6 +1,6 @@
 
 
 PASS register should use the relevant global of the object it was called on to resolve the script URL and the default scope URL 
-FAIL register should use the relevant global of the object it was called on to resolve the script URL and the given scope URL assert_equals: the given scope URL should be parsed against the relevant global expected "https://localhost:9443/service-workers/service-worker/multi-globals/relevant/scope" but got "https://localhost:9443/service-workers/service-worker/multi-globals/relevant/"
+PASS register should use the relevant global of the object it was called on to resolve the script URL and the given scope URL 
 FAIL getRegistration should use the relevant global of the object it was called on to resolve the script URL assert_not_equals: the registration from the other frame should not be null got disallowed value null
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/registration-basic.https-expected.txt (224336 => 224337)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/registration-basic.https-expected.txt	2017-11-02 16:55:26 UTC (rev 224336)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/registration-basic.https-expected.txt	2017-11-02 16:58:00 UTC (rev 224337)
@@ -1,5 +1,5 @@
 
 PASS Registering normal scope 
-FAIL Registering scope with fragment assert_equals: A fragment should be removed from scope expected "https://localhost:9443/service-workers/service-worker/resources/registration/scope-with-fragment" but got "https://localhost:9443/service-workers/service-worker/resources/registration/normal"
+PASS Registering scope with fragment 
 PASS Registering same scope as the script directory 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/registration-scope.https-expected.txt (224336 => 224337)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/registration-scope.https-expected.txt	2017-11-02 16:55:26 UTC (rev 224336)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/registration-scope.https-expected.txt	2017-11-02 16:58:00 UTC (rev 224337)
@@ -2,9 +2,9 @@
 PASS Scope including URL-encoded slash 
 PASS Scope including URL-encoded backslash 
 PASS Scope including URL-encoded multibyte characters 
-FAIL Scope including non-escaped multibyte characters assert_equals: Non-URL-encoded multibyte characters should be available. expected "https://localhost:9443/service-workers/service-worker/resources/%EF%BD%93%EF%BD%83%EF%BD%8F%EF%BD%90%EF%BD%85/non-escaped-multibyte-character-scope" but got "https://localhost:9443/service-workers/service-worker/resources/%ef%bd%93%ef%bd%83%ef%bd%8f%ef%bd%90%ef%bd%85/escaped-multibyte-character-scope"
-FAIL Scope including self-reference assert_equals: Scope including self-reference should be normalized. expected "https://localhost:9443/service-workers/service-worker/resources/scope/self-reference-in-scope" but got "https://localhost:9443/service-workers/service-worker/resources/%ef%bd%93%ef%bd%83%ef%bd%8f%ef%bd%90%ef%bd%85/escaped-multibyte-character-scope"
-FAIL Scope including parent-reference assert_equals: Scope including parent-reference should be normalized. expected "https://localhost:9443/service-workers/service-worker/resources/scope/parent-reference-in-scope" but got "https://localhost:9443/service-workers/service-worker/resources/%ef%bd%93%ef%bd%83%ef%bd%8f%ef%bd%90%ef%bd%85/escaped-multibyte-character-scope"
-FAIL Scope including consecutive slashes assert_equals: Should successfully be registered. expected "https://localhost:9443/service-workers/service-worker/resources/scope////consecutive-slashes-in-scope" but got "https://localhost:9443/service-workers/service-worker/resources/%ef%bd%93%ef%bd%83%ef%bd%8f%ef%bd%90%ef%bd%85/escaped-multibyte-character-scope"
+PASS Scope including non-escaped multibyte characters 
+PASS Scope including self-reference 
+PASS Scope including parent-reference 
+PASS Scope including consecutive slashes 
 FAIL Scope URL is same-origin filesystem: URL assert_throws: Registering with the scope that has same-origin filesystem: URL should fail with SecurityError. function "function () { throw e }" threw object "TypeError: Scope URL provided to serviceWorker.register() must be either HTTP or HTTPS" that is not a DOMException SecurityError: property "code" is equal to undefined, expected 18
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/serviceworkerobject-scripturl.https-expected.txt (224336 => 224337)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/serviceworkerobject-scripturl.https-expected.txt	2017-11-02 16:55:26 UTC (rev 224336)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/serviceworkerobject-scripturl.https-expected.txt	2017-11-02 16:58:00 UTC (rev 224337)
@@ -1,5 +1,5 @@
 
 PASS Verify the scriptURL property: relative 
-PASS Verify the scriptURL property: with-fragment 
+FAIL Verify the scriptURL property: with-fragment assert_equals: Returned ServiceWorker object should have scriptURL expected "https://localhost:9443/service-workers/service-worker/resources/empty-worker.js" but got "https://localhost:9443/service-workers/service-worker/resources/empty-worker.js#ref"
 PASS Verify the scriptURL property: absolute 
 

Modified: trunk/Source/WebCore/ChangeLog (224336 => 224337)


--- trunk/Source/WebCore/ChangeLog	2017-11-02 16:55:26 UTC (rev 224336)
+++ trunk/Source/WebCore/ChangeLog	2017-11-02 16:58:00 UTC (rev 224337)
@@ -1,3 +1,21 @@
+2017-11-02  Chris Dumez  <cdu...@apple.com>
+
+        [Service Workers] Add initial implementation for try Clear Registration / Clear Registration algorithms
+        https://bugs.webkit.org/show_bug.cgi?id=179151
+
+        Reviewed by Youenn Fablet.
+
+        [Service Workers] Add initial implementation for try Clear Registration / Clear Registration algorithms:
+        - https://w3c.github.io/ServiceWorker/#try-clear-registration
+        - https://w3c.github.io/ServiceWorker/#clear-registration
+
+        * workers/service/server/SWServerJobQueue.cpp:
+        (WebCore::SWServerJobQueue::scriptFetchFinished):
+        (WebCore::SWServerJobQueue::runUnregisterJob):
+        (WebCore::SWServerJobQueue::tryClearRegistration):
+        (WebCore::SWServerJobQueue::clearRegistration):
+        * workers/service/server/SWServerJobQueue.h:
+
 2017-11-02  Antti Koivisto  <an...@apple.com>
 
         Clear Node renderer pointer when destroying RenderObject

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


--- trunk/Source/WebCore/workers/service/server/SWServerJobQueue.cpp	2017-11-02 16:55:26 UTC (rev 224336)
+++ trunk/Source/WebCore/workers/service/server/SWServerJobQueue.cpp	2017-11-02 16:58:00 UTC (rev 224337)
@@ -69,11 +69,15 @@
 {
     ASSERT(m_currentJob && m_currentJob->identifier() == result.jobIdentifier);
 
+    auto* registration = m_server.getRegistration(m_registrationKey);
+    ASSERT(registration);
+
     if (!result.scriptError.isNull()) {
         rejectCurrentJob(ExceptionData { UnknownError, makeString("Script URL ", m_currentJob->scriptURL.string(), " fetch resulted in error: ", result.scriptError.localizedDescription()) });
 
         // If newestWorker is null, invoke Clear Registration algorithm passing this registration as its argument.
-        // FIXME: We don't have "clear registration" yet.
+        if (!registration->getNewestWorker())
+            clearRegistration(*registration);
 
         return;
     }
@@ -178,9 +182,27 @@
     // Invoke Resolve Job Promise with job and true.
     resolveCurrentUnregistrationJob(true);
 
-    // FIXME: Invoke Try Clear Registration with registration.
+    // Invoke Try Clear Registration with registration.
+    tryClearRegistration(*registration);
 }
 
+// https://w3c.github.io/ServiceWorker/#try-clear-registration-algorithm
+void SWServerJobQueue::tryClearRegistration(SWServerRegistration& registration)
+{
+    // FIXME: Make sure that the registration has no service worker client.
+
+    // FIXME: The specification has more complex logic here.
+    if (!registration.getNewestWorker())
+        clearRegistration(registration);
+}
+
+// https://w3c.github.io/ServiceWorker/#clear-registration
+void SWServerJobQueue::clearRegistration(SWServerRegistration& registration)
+{
+    // FIXME: Update / terminate the registration's service workers.
+    m_server.removeRegistration(registration.key());
+}
+
 void SWServerJobQueue::runUpdateJob(const ServiceWorkerJobData& job)
 {
     auto* registration = m_server.getRegistration(m_registrationKey);

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


--- trunk/Source/WebCore/workers/service/server/SWServerJobQueue.h	2017-11-02 16:55:26 UTC (rev 224336)
+++ trunk/Source/WebCore/workers/service/server/SWServerJobQueue.h	2017-11-02 16:58:00 UTC (rev 224337)
@@ -58,6 +58,9 @@
     void runUnregisterJob(const ServiceWorkerJobData&);
     void runUpdateJob(const ServiceWorkerJobData&);
 
+    void tryClearRegistration(SWServerRegistration&);
+    void clearRegistration(SWServerRegistration&);
+
     Deque<ServiceWorkerJobData> m_jobQueue;
     std::unique_ptr<ServiceWorkerJobData> m_currentJob;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to