Changeset 224337 in webkit


Ignore:
Timestamp:
Nov 2, 2017 9:58:00 AM (6 years ago)
Author:
Chris Dumez
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:

  • workers/service/server/SWServerJobQueue.cpp:

(WebCore::SWServerJobQueue::scriptFetchFinished):
(WebCore::SWServerJobQueue::runUnregisterJob):
(WebCore::SWServerJobQueue::tryClearRegistration):
(WebCore::SWServerJobQueue::clearRegistration):

  • workers/service/server/SWServerJobQueue.h:
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r224287 r224337  
     12017-11-02  Chris Dumez  <cdumez@apple.com>
     2
     3        [Service Workers] Add initial implementation for try Clear Registration / Clear Registration algorithms
     4        https://bugs.webkit.org/show_bug.cgi?id=179151
     5
     6        Reviewed by Youenn Fablet.
     7
     8        Rebbaseline several WPT tests now that registrations are actually removed.
     9
     10        * web-platform-tests/service-workers/service-worker/multi-globals/url-parsing.https-expected.txt:
     11        * web-platform-tests/service-workers/service-worker/registration-basic.https-expected.txt:
     12        * web-platform-tests/service-workers/service-worker/registration-scope.https-expected.txt:
     13        * web-platform-tests/service-workers/service-worker/serviceworkerobject-scripturl.https-expected.txt:
     14
    1152017-11-01  Chris Dumez  <cdumez@apple.com>
    216
  • trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/multi-globals/url-parsing.https-expected.txt

    r224218 r224337  
    22
    33PASS register should use the relevant global of the object it was called on to resolve the script URL and the default scope URL
    4 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/"
     4PASS register should use the relevant global of the object it was called on to resolve the script URL and the given scope URL
    55FAIL 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
    66
  • trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/registration-basic.https-expected.txt

    r224132 r224337  
    11
    22PASS Registering normal scope
    3 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"
     3PASS Registering scope with fragment
    44PASS Registering same scope as the script directory
    55
  • trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/registration-scope.https-expected.txt

    r224132 r224337  
    33PASS Scope including URL-encoded backslash
    44PASS Scope including URL-encoded multibyte characters
    5 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"
    6 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"
    7 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"
    8 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"
     5PASS Scope including non-escaped multibyte characters
     6PASS Scope including self-reference
     7PASS Scope including parent-reference
     8PASS Scope including consecutive slashes
    99FAIL 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
    1010
  • trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/serviceworkerobject-scripturl.https-expected.txt

    r224218 r224337  
    11
    22PASS Verify the scriptURL property: relative
    3 PASS Verify the scriptURL property: with-fragment
     3FAIL 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"
    44PASS Verify the scriptURL property: absolute
    55
  • trunk/Source/WebCore/ChangeLog

    r224336 r224337  
     12017-11-02  Chris Dumez  <cdumez@apple.com>
     2
     3        [Service Workers] Add initial implementation for try Clear Registration / Clear Registration algorithms
     4        https://bugs.webkit.org/show_bug.cgi?id=179151
     5
     6        Reviewed by Youenn Fablet.
     7
     8        [Service Workers] Add initial implementation for try Clear Registration / Clear Registration algorithms:
     9        - https://w3c.github.io/ServiceWorker/#try-clear-registration
     10        - https://w3c.github.io/ServiceWorker/#clear-registration
     11
     12        * workers/service/server/SWServerJobQueue.cpp:
     13        (WebCore::SWServerJobQueue::scriptFetchFinished):
     14        (WebCore::SWServerJobQueue::runUnregisterJob):
     15        (WebCore::SWServerJobQueue::tryClearRegistration):
     16        (WebCore::SWServerJobQueue::clearRegistration):
     17        * workers/service/server/SWServerJobQueue.h:
     18
    1192017-11-02  Antti Koivisto  <antti@apple.com>
    220
  • trunk/Source/WebCore/workers/service/server/SWServerJobQueue.cpp

    r224306 r224337  
    7070    ASSERT(m_currentJob && m_currentJob->identifier() == result.jobIdentifier);
    7171
     72    auto* registration = m_server.getRegistration(m_registrationKey);
     73    ASSERT(registration);
     74
    7275    if (!result.scriptError.isNull()) {
    7376        rejectCurrentJob(ExceptionData { UnknownError, makeString("Script URL ", m_currentJob->scriptURL.string(), " fetch resulted in error: ", result.scriptError.localizedDescription()) });
    7477
    7578        // If newestWorker is null, invoke Clear Registration algorithm passing this registration as its argument.
    76         // FIXME: We don't have "clear registration" yet.
     79        if (!registration->getNewestWorker())
     80            clearRegistration(*registration);
    7781
    7882        return;
     
    179183    resolveCurrentUnregistrationJob(true);
    180184
    181     // FIXME: Invoke Try Clear Registration with registration.
     185    // Invoke Try Clear Registration with registration.
     186    tryClearRegistration(*registration);
     187}
     188
     189// https://w3c.github.io/ServiceWorker/#try-clear-registration-algorithm
     190void SWServerJobQueue::tryClearRegistration(SWServerRegistration& registration)
     191{
     192    // FIXME: Make sure that the registration has no service worker client.
     193
     194    // FIXME: The specification has more complex logic here.
     195    if (!registration.getNewestWorker())
     196        clearRegistration(registration);
     197}
     198
     199// https://w3c.github.io/ServiceWorker/#clear-registration
     200void SWServerJobQueue::clearRegistration(SWServerRegistration& registration)
     201{
     202    // FIXME: Update / terminate the registration's service workers.
     203    m_server.removeRegistration(registration.key());
    182204}
    183205
  • trunk/Source/WebCore/workers/service/server/SWServerJobQueue.h

    r224306 r224337  
    5959    void runUpdateJob(const ServiceWorkerJobData&);
    6060
     61    void tryClearRegistration(SWServerRegistration&);
     62    void clearRegistration(SWServerRegistration&);
     63
    6164    Deque<ServiceWorkerJobData> m_jobQueue;
    6265    std::unique_ptr<ServiceWorkerJobData> m_currentJob;
Note: See TracChangeset for help on using the changeset viewer.