Some SW Container and Registration tweaks.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Nov 2017 23:15:03 +0000 (23:15 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Nov 2017 23:15:03 +0000 (23:15 +0000)
https://bugs.webkit.org/show_bug.cgi?id=179450

Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

* web-platform-tests/service-workers/service-worker/claim-with-redirect.https-expected.txt:

Source/WebCore:

No new tests (Progression in an existing test).

* workers/service/ServiceWorkerContainer.cpp:
(WebCore::ServiceWorkerContainer::jobResolvedWithRegistration):
* workers/service/ServiceWorkerRegistration.cpp:
(WebCore::ServiceWorkerRegistration::ServiceWorkerRegistration):

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

LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/claim-with-redirect.https-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/workers/service/ServiceWorkerContainer.cpp
Source/WebCore/workers/service/ServiceWorkerRegistration.cpp

index f823949..c802000 100644 (file)
@@ -1,3 +1,12 @@
+2017-11-08  Brady Eidson  <beidson@apple.com>
+
+        Some SW Container and Registration tweaks.
+        https://bugs.webkit.org/show_bug.cgi?id=179450
+
+        Reviewed by Chris Dumez.
+
+        * web-platform-tests/service-workers/service-worker/claim-with-redirect.https-expected.txt:
+
 2017-11-08  Maciej Stachowiak  <mjs@apple.com>
 
         Switch encoding WPT test suite to updating via import-w3c-tests
index 40cd13f..1008013 100644 (file)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 27: Unhandled Promise Rejection: InvalidStateError: newestWorker is null
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: Cannot update a null/nonexistent service worker registration
   
 
 FAIL Claim works after redirection to another origin assert_equals: expected (string) "updated" but got (undefined) undefined
index d2fd1c1..029d428 100644 (file)
@@ -1,3 +1,17 @@
+2017-11-08  Brady Eidson  <beidson@apple.com>
+
+        Some SW Container and Registration tweaks.
+        https://bugs.webkit.org/show_bug.cgi?id=179450
+
+        Reviewed by Chris Dumez.
+
+        No new tests (Progression in an existing test).
+
+        * workers/service/ServiceWorkerContainer.cpp:
+        (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration):
+        * workers/service/ServiceWorkerRegistration.cpp:
+        (WebCore::ServiceWorkerRegistration::ServiceWorkerRegistration):
+
 2017-11-08  Antti Koivisto  <antti@apple.com>
 
         Move inlineElementContinuation function to RenderBoxModelObject and rename to inlineContinuation
index a99a3f5..1c7d14f 100644 (file)
@@ -345,19 +345,12 @@ void ServiceWorkerContainer::jobResolvedWithRegistration(ServiceWorkerJob& job,
         return;
     }
 
-    ASSERT(data.installingServiceWorkerIdentifier);
-    auto installingServiceWorkerIdentifier = *data.installingServiceWorkerIdentifier;
-
     RefPtr<ServiceWorkerRegistration> registration = m_registrations.get(data.key);
     if (!registration)
         registration = ServiceWorkerRegistration::create(*context, *this, WTFMove(data));
 
-    registration->updateStateFromServer(ServiceWorkerRegistrationState::Installing, installingServiceWorkerIdentifier);
-    ASSERT(registration->installing());
-    registration->installing()->updateWorkerState(ServiceWorkerState::Installing, ServiceWorker::DoNotFireStateChangeEvent);
-
     // FIXME: Implement proper selection of service workers.
-    context->setActiveServiceWorker(registration->installing());
+    context->setActiveServiceWorker(registration->getNewestWorker());
 
     LOG(ServiceWorker, "Container %p resolved job with registration %p", this, registration.get());
 
index a4a5556..d76b971 100644 (file)
@@ -44,6 +44,22 @@ ServiceWorkerRegistration::ServiceWorkerRegistration(ScriptExecutionContext& con
 {
     LOG(ServiceWorker, "Creating registration %p for registration key %s", this, m_registrationData.key.loggingString().utf8().data());
     suspendIfNeeded();
+
+    // FIXME: Reconcile worker state properly (see below)
+    if (m_registrationData.installingServiceWorkerIdentifier) {
+        m_installingWorker = ServiceWorker::create(context, *m_registrationData.installingServiceWorkerIdentifier, m_registrationData.scriptURL);
+        m_installingWorker->updateWorkerState(ServiceWorker::State::Installing);
+    }
+    if (m_registrationData.waitingServiceWorkerIdentifier) {
+        m_waitingWorker = ServiceWorker::create(context, *m_registrationData.waitingServiceWorkerIdentifier, m_registrationData.scriptURL);
+        // FIXME: Installed or Activating? This is why we have to have more data here...
+        m_waitingWorker->updateWorkerState(ServiceWorker::State::Installed);
+    }
+    if (m_registrationData.activeServiceWorkerIdentifier) {
+        m_activeWorker = ServiceWorker::create(context, *m_registrationData.activeServiceWorkerIdentifier, m_registrationData.scriptURL);
+        m_activeWorker->updateWorkerState(ServiceWorker::State::Activated);
+    }
+
     m_container->addRegistration(*this);
 }