Changeset 224453 in webkit


Ignore:
Timestamp:
Nov 3, 2017 7:12:06 PM (6 years ago)
Author:
Chris Dumez
Message:

Implement ServiceWorkerContainer.getRegistration
https://bugs.webkit.org/show_bug.cgi?id=179253

Patch by Youenn Fablet <youenn@apple.com> on 2017-11-03
Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

  • web-platform-tests/service-workers/service-worker/activation.https-expected.txt:
  • web-platform-tests/service-workers/service-worker/claim-affect-other-registration.https-expected.txt:
  • web-platform-tests/service-workers/service-worker/claim-with-redirect.https-expected.txt:
  • web-platform-tests/service-workers/service-worker/getregistration.https-expected.txt:
  • web-platform-tests/service-workers/service-worker/multi-globals/url-parsing.https-expected.txt:
  • web-platform-tests/service-workers/service-worker/navigate-window.https-expected.txt:
  • web-platform-tests/service-workers/service-worker/registration-iframe.https-expected.txt:
  • web-platform-tests/service-workers/service-worker/skip-waiting-without-using-registration.https-expected.txt:
  • web-platform-tests/service-workers/service-worker/synced-state.https-expected.txt:

Source/WebCore:

Test: http/tests/workers/service/service-worker-getRegistration.html

Added a map of ServiceWorkerRegistration in ServiceWorkerContainer.
Removing a similar map from SWClientConnection as it is more convenient to have this map per ScriptExecutionContext.

This map allows returning the same JS object for different getRegistration.
Delegating the actual matching to SWServer::Connection which is implemented on the StorageProcess through IPC.

  • workers/service/ServiceWorkerContainer.cpp:

(WebCore::ServiceWorkerContainer::getRegistration):
(WebCore::ServiceWorkerContainer::jobResolvedWithRegistration):
(WebCore::ServiceWorkerContainer::jobDidFinish):

  • workers/service/ServiceWorkerContainer.h:
  • workers/service/ServiceWorkerContainer.idl:
  • workers/service/ServiceWorkerRegistration.cpp:

(WebCore::ServiceWorkerRegistration::ServiceWorkerRegistration):
(WebCore::ServiceWorkerRegistration::~ServiceWorkerRegistration):

  • workers/service/ServiceWorkerRegistration.h:
  • workers/service/server/SWClientConnection.cpp:

(WebCore::SWClientConnection::updateRegistrationState):
(WebCore::SWClientConnection::addServiceWorkerRegistration): Deleted.
(WebCore::SWClientConnection::removeServiceWorkerRegistration): Deleted.

  • workers/service/server/SWClientConnection.h:

LayoutTests:

  • TestExpectations:
  • http/tests/workers/service/resources/service-worker-getRegistration-worker.js: Added.
  • http/tests/workers/service/resources/service-worker-getRegistration.js: Added.
  • http/tests/workers/service/service-worker-getRegistration-expected.txt: Added.
  • http/tests/workers/service/service-worker-getRegistration.html: Added.
Location:
trunk
Files:
4 added
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r224439 r224453  
     12017-11-03  Youenn Fablet  <youenn@apple.com>
     2
     3        Implement ServiceWorkerContainer.getRegistration
     4        https://bugs.webkit.org/show_bug.cgi?id=179253
     5
     6        Reviewed by Chris Dumez.
     7
     8        * TestExpectations:
     9        * http/tests/workers/service/resources/service-worker-getRegistration-worker.js: Added.
     10        * http/tests/workers/service/resources/service-worker-getRegistration.js: Added.
     11        * http/tests/workers/service/service-worker-getRegistration-expected.txt: Added.
     12        * http/tests/workers/service/service-worker-getRegistration.html: Added.
     13
    1142017-11-03  Youenn Fablet  <youenn@apple.com>
    215
  • trunk/LayoutTests/TestExpectations

    r224429 r224453  
    173173imported/w3c/web-platform-tests/service-workers/service-worker/update-after-oneday.https.html [ Skip ]
    174174imported/w3c/web-platform-tests/fetch/api/abort/general-serviceworker.https.html [ Skip ]
     175imported/w3c/web-platform-tests/service-workers/service-worker/skip-waiting-without-using-registration.https.html [ Skip ]
    175176
    176177imported/w3c/web-platform-tests/service-workers/service-worker/fetch-cors-xhr.https.html [ Pass Failure ]
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r224408 r224453  
     12017-11-03  Youenn Fablet  <youenn@apple.com>
     2
     3        Implement ServiceWorkerContainer.getRegistration
     4        https://bugs.webkit.org/show_bug.cgi?id=179253
     5
     6        Reviewed by Chris Dumez.
     7
     8        * web-platform-tests/service-workers/service-worker/activation.https-expected.txt:
     9        * web-platform-tests/service-workers/service-worker/claim-affect-other-registration.https-expected.txt:
     10        * web-platform-tests/service-workers/service-worker/claim-with-redirect.https-expected.txt:
     11        * web-platform-tests/service-workers/service-worker/getregistration.https-expected.txt:
     12        * web-platform-tests/service-workers/service-worker/multi-globals/url-parsing.https-expected.txt:
     13        * web-platform-tests/service-workers/service-worker/navigate-window.https-expected.txt:
     14        * web-platform-tests/service-workers/service-worker/registration-iframe.https-expected.txt:
     15        * web-platform-tests/service-workers/service-worker/skip-waiting-without-using-registration.https-expected.txt:
     16        * web-platform-tests/service-workers/service-worker/synced-state.https-expected.txt:
     17
    1182017-11-03  Youenn Fablet  <youenn@apple.com>
    219
  • trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/activation.https-expected.txt

    r224132 r224453  
    11
    2 FAIL loss of controllees triggers activation promise_test: Unhandled rejection with value: object "TypeError: null is not an object (evaluating 'document.body.appendChild')"
    3 FAIL finishing a request triggers activation promise_test: Unhandled rejection with value: object "TypeError: null is not an object (evaluating 'document.body.appendChild')"
    4 FAIL skipWaiting bypasses no controllee requirement promise_test: Unhandled rejection with value: object "TypeError: null is not an object (evaluating 'document.body.appendChild')"
    5 FAIL finishing a request triggers unregister promise_test: Unhandled rejection with value: object "TypeError: null is not an object (evaluating 'document.body.appendChild')"
    62
     3FAIL loss of controllees triggers activation assert_not_equals: got disallowed value null
     4FAIL finishing a request triggers activation assert_not_equals: got disallowed value null
     5FAIL skipWaiting bypasses no controllee requirement assert_not_equals: got disallowed value null
     6FAIL finishing a request triggers unregister assert_not_equals: got disallowed value null
     7
  • trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/claim-affect-other-registration.https-expected.txt

    r224218 r224453  
    11
    22
    3 FAIL claim() should affect the originally controlling registration. promise_test: Unhandled rejection with value: object "TypeError: null is not an object (evaluating 'r.active')"
     3FAIL claim() should affect the originally controlling registration. assert_equals: Should be the same registration expected object "[object ServiceWorkerRegistration]" but got object "[object ServiceWorkerRegistration]"
    44
  • trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/claim-with-redirect.https-expected.txt

    r224132 r224453  
    1 CONSOLE MESSAGE: line 27: Unhandled Promise Rejection: TypeError: null is not an object (evaluating 'r.update')
     1CONSOLE MESSAGE: line 27: Unhandled Promise Rejection: NotSupportedError: ServiceWorkerRegistration::update not yet implemented
    22 
    33
  • trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/getregistration.https-expected.txt

    r224132 r224453  
    11
    2 FAIL getRegistration assert_unreached: unexpected rejection: assert_equals: getRegistration should resolve with undefined expected (undefined) undefined but got (object) null Reached unreachable code
    3 FAIL Register then getRegistration assert_unreached: unexpected rejection: assert_equals: getRegistration should resolve to the same registration object expected object "[object ServiceWorkerRegistration]" but got null Reached unreachable code
    4 FAIL Register then getRegistration with a URL having a fragment assert_unreached: unexpected rejection: assert_equals: getRegistration should resolve to the same registration object expected object "[object ServiceWorkerRegistration]" but got null Reached unreachable code
    5 FAIL getRegistration with a cross origin URL assert_unreached: unexpected rejection: assert_unreached: getRegistration with an out of origin URL should fail Reached unreachable code Reached unreachable code
    6 FAIL Register then Unregister then getRegistration assert_unreached: unexpected rejection: assert_equals: getRegistration should resolve with undefined expected (undefined) undefined but got (object) null Reached unreachable code
     2PASS getRegistration
     3PASS Register then getRegistration
     4PASS Register then getRegistration with a URL having a fragment
     5PASS getRegistration with a cross origin URL
     6PASS Register then Unregister then getRegistration
    77
  • trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/multi-globals/url-parsing.https-expected.txt

    r224337 r224453  
    33PASS register should use the relevant global of the object it was called on to resolve the script URL and the default scope URL
    44PASS register should use the relevant global of the object it was called on to resolve the script URL and the given scope URL
    5 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
     5PASS getRegistration should use the relevant global of the object it was called on to resolve the script URL
    66
  • trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/navigate-window.https-expected.txt

    r224218 r224453  
    11
    2 FAIL Clients.matchAll() should not show an old window as controlled after it navigates. assert_unreached: unexpected rejection: null is not an object (evaluating 'reg.active') Reached unreachable code
    3 FAIL Clients.matchAll() should not show an old window after it navigates. assert_unreached: unexpected rejection: null is not an object (evaluating 'reg.active') Reached unreachable code
     2FAIL Clients.matchAll() should not show an old window as controlled after it navigates. assert_unreached: unexpected rejection: null is not an object (evaluating 'sw.postMessage') Reached unreachable code
     3FAIL Clients.matchAll() should not show an old window after it navigates. assert_unreached: unexpected rejection: null is not an object (evaluating 'sw.postMessage') Reached unreachable code
    44
  • trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/registration-iframe.https-expected.txt

    r224132 r224453  
    11
    2 FAIL register method should use the "relevant global object" to parse its scriptURL and scope - normal case assert_unreached: unexpected rejection: null is not an object (evaluating 'document.body.appendChild') Reached unreachable code
    3 FAIL register method should use the "relevant global object" to parse its scriptURL and scope - error case assert_unreached: unexpected rejection: undefined is not an object (evaluating 'frame.remove') Reached unreachable code
    4 FAIL A scope url should start with the given script url assert_unreached: unexpected rejection: assert_equals: The scope set to a non-subdirectory of the scriptURL should reject with SecurityError expected "SecurityError" but got "TypeError" Reached unreachable code
    52
     3PASS register method should use the "relevant global object" to parse its scriptURL and scope - normal case
     4FAIL register method should use the "relevant global object" to parse its scriptURL and scope - error case assert_unreached: unexpected rejection: assert_unreached: register() should reject Reached unreachable code Reached unreachable code
     5FAIL A scope url should start with the given script url assert_unreached: unexpected rejection: assert_unreached: register() should reject Reached unreachable code Reached unreachable code
     6
  • trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/skip-waiting-without-using-registration.https-expected.txt

    r224132 r224453  
    11
    2 FAIL Test skipWaiting while a client is not being controlled promise_test: Unhandled rejection with value: object "TypeError: null is not an object (evaluating 'document.body.appendChild')"
     2Harness Error (TIMEOUT), message = null
    33
     4PASS Test skipWaiting while a client is not being controlled
     5TIMEOUT skipWaiting Test timed out
     6
  • trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/synced-state.https-expected.txt

    r224218 r224453  
    11
    2 FAIL worker objects for the same entity have the same state assert_equals: getRegistration should return the same object expected object "[object ServiceWorkerRegistration]" but got null
     2PASS worker objects for the same entity have the same state
    33
  • trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/unregister-then-register.https-expected.txt

    r224218 r224453  
    33PASS Unregister then register resolves to a new value
    44FAIL Unregister then register resolves to the original value if the registration is in use. assert_unreached: unexpected rejection: assert_equals: new registration should resolve to the same registration expected object "[object ServiceWorkerRegistration]" but got object "[object ServiceWorkerRegistration]" Reached unreachable code
    5 FAIL Reloading the last controlled iframe after unregistration should ensure the deletion of the registration assert_unreached: unexpected rejection: assert_equals: getRegistration should return undefined after unregistration expected (undefined) undefined but got (object) null Reached unreachable code
     5PASS Reloading the last controlled iframe after unregistration should ensure the deletion of the registration
    66FAIL Unregister then register does not affect existing controllee assert_unreached: unexpected rejection: assert_equals: installing version is null expected null but got object "[object ServiceWorker]" Reached unreachable code
    77FAIL Unregister then register resurrects the registration assert_unreached: unexpected rejection: assert_not_equals: document should have a controller got disallowed value null Reached unreachable code
  • trunk/Source/WebCore/ChangeLog

    r224452 r224453  
     12017-11-03  Youenn Fablet  <youenn@apple.com>
     2
     3        Implement ServiceWorkerContainer.getRegistration
     4        https://bugs.webkit.org/show_bug.cgi?id=179253
     5
     6        Reviewed by Chris Dumez.
     7
     8        Test: http/tests/workers/service/service-worker-getRegistration.html
     9
     10        Added a map of ServiceWorkerRegistration in ServiceWorkerContainer.
     11        Removing a similar map from SWClientConnection as it is more convenient to have this map per ScriptExecutionContext.
     12
     13        This map allows returning the same JS object for different getRegistration.
     14        Delegating the actual matching to SWServer::Connection which is implemented on the StorageProcess through IPC.
     15
     16        * workers/service/ServiceWorkerContainer.cpp:
     17        (WebCore::ServiceWorkerContainer::getRegistration):
     18        (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration):
     19        (WebCore::ServiceWorkerContainer::jobDidFinish):
     20        * workers/service/ServiceWorkerContainer.h:
     21        * workers/service/ServiceWorkerContainer.idl:
     22        * workers/service/ServiceWorkerRegistration.cpp:
     23        (WebCore::ServiceWorkerRegistration::ServiceWorkerRegistration):
     24        (WebCore::ServiceWorkerRegistration::~ServiceWorkerRegistration):
     25        * workers/service/ServiceWorkerRegistration.h:
     26        * workers/service/server/SWClientConnection.cpp:
     27        (WebCore::SWClientConnection::updateRegistrationState):
     28        (WebCore::SWClientConnection::addServiceWorkerRegistration): Deleted.
     29        (WebCore::SWClientConnection::removeServiceWorkerRegistration): Deleted.
     30        * workers/service/server/SWClientConnection.h:
     31
    1322017-11-03  Chris Dumez  <cdumez@apple.com>
    233
  • trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp

    r224403 r224453  
    177177}
    178178
    179 void ServiceWorkerContainer::getRegistration(const String&, RegistrationPromise&& promise)
    180 {
    181     // FIXME: Implement getRegistration algorithm, for now pretend there is no registration.
    182     // https://bugs.webkit.org/show_bug.cgi?id=178882
    183     promise.resolve(nullptr);
     179void ServiceWorkerContainer::getRegistration(const String& clientURL, Ref<DeferredPromise>&& promise)
     180{
     181    auto* context = scriptExecutionContext();
     182    if (!context) {
     183        ASSERT_NOT_REACHED();
     184        promise->reject(Exception { InvalidStateError });
     185        return;
     186    }
     187
     188    URL parsedURL = context->completeURL(clientURL);
     189    if (!protocolHostAndPortAreEqual(parsedURL, context->url())) {
     190        promise->reject(Exception { SecurityError, ASCIILiteral("Origin of clientURL is not client's origin") });
     191        return;
     192    }
     193
     194    if (!m_swConnection)
     195        m_swConnection = &ServiceWorkerProvider::singleton().serviceWorkerConnectionForSession(context->sessionID());
     196
     197    return m_swConnection->matchRegistration(context->topOrigin(), parsedURL, [promise = WTFMove(promise), protectingThis = makePendingActivity(*this), this] (auto&& result) mutable {
     198        if (m_isStopped)
     199            return;
     200
     201        if (!result) {
     202            promise->resolve();
     203            return;
     204        }
     205
     206        RefPtr<ServiceWorkerRegistration> registration = m_registrations.get(result->key);
     207        if (!registration) {
     208            auto& context = *scriptExecutionContext();
     209            auto worker = ServiceWorker::create(context, *result->activeServiceWorkerIdentifier, result->scriptURL);
     210            registration = ServiceWorkerRegistration::create(context, *this, WTFMove(result.value()), WTFMove(worker));
     211        }
     212        promise->resolve<IDLInterface<ServiceWorkerRegistration>>(registration.releaseNonNull());
     213    });
     214}
     215
     216void ServiceWorkerContainer::updateRegistration(const ServiceWorkerRegistrationKey& key, ServiceWorkerRegistrationState state, const std::optional<ServiceWorkerIdentifier>& serviceWorkerIdentifier)
     217{
     218    if (auto* registration = m_registrations.get(key))
     219        registration->updateStateFromServer(state, serviceWorkerIdentifier);
    184220}
    185221
     
    252288
    253289    activeServiceWorker->setState(ServiceWorker::State::Installing);
    254    
    255     ASSERT(m_swConnection);
    256     auto registration = ServiceWorkerRegistration::create(*context, *m_swConnection, WTFMove(data), *activeServiceWorker);
    257 
    258     job.promise().resolve<IDLInterface<ServiceWorkerRegistration>>(registration.get());
     290
     291    auto registration = ServiceWorkerRegistration::create(*context, *this, WTFMove(data), *activeServiceWorker);
     292
     293    job.promise().resolve<IDLInterface<ServiceWorkerRegistration>>(registration);
    259294
    260295    // Use a microtask because we need to make sure this is executed after the promise above is resolved.
     
    313348{
    314349    auto taken = m_jobMap.take(job.data().identifier());
    315     ASSERT_UNUSED(taken, !taken || taken.get() == &job);
     350    ASSERT_UNUSED(taken, !taken || taken->ptr() == &job);
    316351}
    317352
     
    329364bool ServiceWorkerContainer::canSuspendForDocumentSuspension() const
    330365{
    331     return true;
     366    return !hasPendingActivity();
    332367}
    333368
  • trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h

    r224218 r224453  
    6363    void removeRegistration(const URL& scopeURL, Ref<DeferredPromise>&&);
    6464
    65     using RegistrationPromise = DOMPromiseDeferred<IDLNullable<IDLInterface<ServiceWorkerRegistration>>>;
    66     void getRegistration(const String& clientURL, RegistrationPromise&&);
     65    void getRegistration(const String& clientURL, Ref<DeferredPromise>&&);
     66    void updateRegistration(const ServiceWorkerRegistrationKey&, ServiceWorkerRegistrationState, const std::optional<ServiceWorkerIdentifier>&);
    6767
    6868    using RegistrationsPromise = DOMPromiseDeferred<IDLSequence<IDLInterface<ServiceWorkerRegistration>>>;
    6969    void getRegistrations(RegistrationsPromise&&);
     70
     71    void addRegistration(ServiceWorkerRegistration& registration) { m_registrations.add(registration.data().key, &registration); }
     72    void removeRegistration(ServiceWorkerRegistration& registration)  { m_registrations.remove(registration.data().key); }
    7073
    7174    void startMessages();
     
    9497    void refEventTarget() final;
    9598    void derefEventTarget() final;
     99    void stop() final { m_isStopped = true; }
    96100
    97101    ReadyPromise m_readyPromise;
     
    100104
    101105    RefPtr<SWClientConnection> m_swConnection;
    102     HashMap<uint64_t, RefPtr<ServiceWorkerJob>> m_jobMap;
     106    HashMap<uint64_t, Ref<ServiceWorkerJob>> m_jobMap;
     107
     108    bool m_isStopped { false };
     109    HashMap<ServiceWorkerRegistrationKey, ServiceWorkerRegistration*> m_registrations;
    103110
    104111#ifndef NDEBUG
  • trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.cpp

    r224403 r224453  
    3737namespace WebCore {
    3838
    39 ServiceWorkerRegistration::ServiceWorkerRegistration(ScriptExecutionContext& context, SWClientConnection& connection, ServiceWorkerRegistrationData&& registrationData, Ref<ServiceWorker>&& serviceWorker)
     39ServiceWorkerRegistration::ServiceWorkerRegistration(ScriptExecutionContext& context, Ref<ServiceWorkerContainer>&& container, ServiceWorkerRegistrationData&& registrationData, Ref<ServiceWorker>&& serviceWorker)
    4040    : ActiveDOMObject(&context)
    4141    , m_registrationData(WTFMove(registrationData))
    4242    , m_serviceWorker(WTFMove(serviceWorker))
    43     , m_connection(connection)
     43    , m_container(WTFMove(container))
    4444{
    4545    suspendIfNeeded();
    46 
    47     m_connection->addServiceWorkerRegistration(*this);
     46    m_container->addRegistration(*this);
    4847}
    4948
    5049ServiceWorkerRegistration::~ServiceWorkerRegistration()
    5150{
    52     m_connection->removeServiceWorkerRegistration(*this);
     51    m_container->removeRegistration(*this);
    5352}
    5453
  • trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.h

    r224403 r224453  
    3939class ScriptExecutionContext;
    4040class ServiceWorker;
     41class ServiceWorkerContainer;
    4142
    4243class ServiceWorkerRegistration final : public RefCounted<ServiceWorkerRegistration>, public EventTargetWithInlineData, public ActiveDOMObject, public ThreadSafeIdentified<ServiceWorkerRegistration> {
     
    6768
    6869private:
    69     ServiceWorkerRegistration(ScriptExecutionContext&, SWClientConnection&, ServiceWorkerRegistrationData&&, Ref<ServiceWorker>&&);
     70    ServiceWorkerRegistration(ScriptExecutionContext&, Ref<ServiceWorkerContainer>&&, ServiceWorkerRegistrationData&&, Ref<ServiceWorker>&&);
    7071
    7172    EventTargetInterface eventTargetInterface() const final;
     
    7980    ServiceWorkerRegistrationData m_registrationData;
    8081    Ref<ServiceWorker> m_serviceWorker;
    81     Ref<SWClientConnection> m_connection;
     82    Ref<ServiceWorkerContainer> m_container;
    8283};
    8384
  • trunk/Source/WebCore/workers/service/server/SWClientConnection.cpp

    r224403 r224453  
    6565}
    6666
    67 void SWClientConnection::addServiceWorkerRegistration(ServiceWorkerRegistration& registration)
    68 {
    69     auto result = m_registrations.ensure(registration.data().key, [] {
    70         return std::make_unique<HashSet<ServiceWorkerRegistration*>>();
    71     });
    72 
    73     ASSERT(!result.iterator->value->contains(&registration));
    74     result.iterator->value->add(&registration);
    75    
    76     addServiceWorkerRegistrationInServer(registration.data().key, registration.identifier());
    77 }
    78 
    79 void SWClientConnection::removeServiceWorkerRegistration(ServiceWorkerRegistration& registration)
    80 {
    81     auto iterator = m_registrations.find(registration.data().key);
    82 
    83     ASSERT(iterator != m_registrations.end());
    84     ASSERT(iterator->value && iterator->value->contains(&registration));
    85     iterator->value->remove(&registration);
    86 
    87     if (iterator->value->isEmpty())
    88         m_registrations.remove(iterator);
    89 
    90     removeServiceWorkerRegistrationInServer(registration.data().key, registration.identifier());
    91 }
    92    
    9367void SWClientConnection::jobRejectedInServer(uint64_t jobIdentifier, const ExceptionData& exceptionData)
    9468{
     
    167141void SWClientConnection::updateRegistrationState(const ServiceWorkerRegistrationKey& key, ServiceWorkerRegistrationState state, std::optional<ServiceWorkerIdentifier> serviceWorkerIdentifier)
    168142{
    169     auto* registrations = m_registrations.get(key);
    170     if (!registrations)
    171         return;
    172    
    173     for (auto& registration : *registrations)
    174         registration->updateStateFromServer(state, serviceWorkerIdentifier);
     143    // FIXME: We should iterate over all service worker clients, not only documents.
     144    for (auto& document : Document::allDocuments()) {
     145        if (auto* container = document->serviceWorkerContainer())
     146            container->updateRegistration(key, state, serviceWorkerIdentifier);
     147    }
    175148}
    176149
  • trunk/Source/WebCore/workers/service/server/SWClientConnection.h

    r224408 r224453  
    5454    void finishedFetchingScript(ServiceWorkerJob&, const String&);
    5555    void failedFetchingScript(ServiceWorkerJob&, const ResourceError&);
    56     void addServiceWorkerRegistration(ServiceWorkerRegistration&);
    57     void removeServiceWorkerRegistration(ServiceWorkerRegistration&);
    5856
    5957    virtual void postMessageToServiceWorkerGlobalScope(ServiceWorkerIdentifier destinationIdentifier, Ref<SerializedScriptValue>&&, ScriptExecutionContext& source) = 0;
     
    7876
    7977    HashMap<uint64_t, RefPtr<ServiceWorkerJob>> m_scheduledJobs;
    80     HashMap<ServiceWorkerRegistrationKey, std::unique_ptr<HashSet<ServiceWorkerRegistration*>>> m_registrations;
    8178};
    8279
Note: See TracChangeset for help on using the changeset viewer.