Title: [226904] trunk
Revision
226904
Author
commit-qu...@webkit.org
Date
2018-01-12 11:43:35 -0800 (Fri, 12 Jan 2018)

Log Message

WebProcess should pass the registration identifier and not the worker identifier for fetch events
https://bugs.webkit.org/show_bug.cgi?id=181591

Patch by Youenn Fablet <you...@apple.com> on 2018-01-12
Reviewed by Chris Dumez.

Source/WebCore:

Test: http/wpt/service-workers/update-service-worker.https.html

Store service worker registration identifier in ResourceLoaderOptions instead of service worker identifier.

* loader/DocumentThreadableLoader.cpp:
(WebCore::DocumentThreadableLoader::DocumentThreadableLoader):
(WebCore::DocumentThreadableLoader::makeCrossOriginAccessRequest):
* loader/ResourceLoaderOptions.h:
* loader/WorkerThreadableLoader.cpp:
(WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge):
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::prepareFetch):
(WebCore::CachedResourceLoader::determineRevalidationPolicy const):
* loader/cache/CachedResourceRequest.cpp:
(WebCore::CachedResourceRequest::setSelectedServiceWorkerRegistrationIdentifierIfNeeded):
(WebCore::CachedResourceRequest::setNavigationServiceWorkerRegistrationData):
(WebCore::CachedResourceRequest::setSelectedServiceWorkerIdentifierIfNeeded): Deleted.
* loader/cache/CachedResourceRequest.h:
* workers/WorkerScriptLoader.cpp:
(WebCore::WorkerScriptLoader::loadSynchronously):
(WebCore::WorkerScriptLoader::loadAsynchronously):
* workers/service/server/SWServer.cpp:
(WebCore::SWServer::activeWorkerFromRegistrationID):
* workers/service/server/SWServer.h:

Source/WebKit:

Use service worker registration identifier to compute the active service worker identifier responsible to handle the fetch event.

* StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
(WebKit::WebSWServerConnection::startFetch):
* StorageProcess/ServiceWorker/WebSWServerConnection.h:
* StorageProcess/ServiceWorker/WebSWServerConnection.messages.in:
* WebProcess/Storage/ServiceWorkerClientFetch.cpp:
(WebKit::ServiceWorkerClientFetch::start):
* WebProcess/Storage/WebSWClientConnection.cpp:
(WebKit::WebSWClientConnection::startFetch):
* WebProcess/Storage/WebSWClientConnection.h:
* WebProcess/Storage/WebServiceWorkerProvider.cpp:
(WebKit::shouldHandleFetch):

LayoutTests:

* http/wpt/service-workers/resources/empty.html: Added.
* http/wpt/service-workers/update-service-worker.https-expected.txt: Added.
* http/wpt/service-workers/update-service-worker.https.html: Added.
* http/wpt/service-workers/update-worker.py: Added.
(main):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (226903 => 226904)


--- trunk/LayoutTests/ChangeLog	2018-01-12 19:21:00 UTC (rev 226903)
+++ trunk/LayoutTests/ChangeLog	2018-01-12 19:43:35 UTC (rev 226904)
@@ -1,3 +1,16 @@
+2018-01-12  Youenn Fablet  <you...@apple.com>
+
+        WebProcess should pass the registration identifier and not the worker identifier for fetch events
+        https://bugs.webkit.org/show_bug.cgi?id=181591
+
+        Reviewed by Chris Dumez.
+
+        * http/wpt/service-workers/resources/empty.html: Added.
+        * http/wpt/service-workers/update-service-worker.https-expected.txt: Added.
+        * http/wpt/service-workers/update-service-worker.https.html: Added.
+        * http/wpt/service-workers/update-worker.py: Added.
+        (main):
+
 2018-01-11  Simon Fraser  <simon.fra...@apple.com>
 
         fast/events/ios/rotation/layout-viewport-during-safari-type-rotation.html is flakey

Added: trunk/LayoutTests/http/wpt/service-workers/resources/empty.html (0 => 226904)


--- trunk/LayoutTests/http/wpt/service-workers/resources/empty.html	                        (rev 0)
+++ trunk/LayoutTests/http/wpt/service-workers/resources/empty.html	2018-01-12 19:43:35 UTC (rev 226904)
@@ -0,0 +1,4 @@
+<html>
+<body>
+</body>
+</html>

Added: trunk/LayoutTests/http/wpt/service-workers/update-service-worker.https-expected.txt (0 => 226904)


--- trunk/LayoutTests/http/wpt/service-workers/update-service-worker.https-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/wpt/service-workers/update-service-worker.https-expected.txt	2018-01-12 19:43:35 UTC (rev 226904)
@@ -0,0 +1,4 @@
+
+PASS Setup worker 
+PASS Ensure all fetches are intercepted 
+

Added: trunk/LayoutTests/http/wpt/service-workers/update-service-worker.https.html (0 => 226904)


--- trunk/LayoutTests/http/wpt/service-workers/update-service-worker.https.html	                        (rev 0)
+++ trunk/LayoutTests/http/wpt/service-workers/update-service-worker.https.html	2018-01-12 19:43:35 UTC (rev 226904)
@@ -0,0 +1,46 @@
+<html>
+<head>
+<title>Service Worker update and interception</title>
+<script src=""
+<script src=""
+<script src=""
+</head>
+<body>
+<script>
+var registration;
+var iframe;
+promise_test(async (test) => {
+    registration = await navigator.serviceWorker.getRegistration("resources");
+    if (registration)
+        await registration.unregister();
+    registration = await navigator.serviceWorker.register("update-worker.py", { scope : "resources" });
+    activeWorker = registration.active;
+    if (activeWorker)
+        return;
+    activeWorker = registration.installing;
+    await new Promise(resolve => {
+        activeWorker.addEventListener('statechange', () => {
+            if (activeWorker.state === "activated")
+                resolve();
+        });
+    });
+}, "Setup worker");
+
+promise_test(async (test) => {
+    var promises = [];
+    for (var cptr = 0; cptr < 10; cptr++) {
+         if (registration.active) {
+            registration.update();
+            var iframe = await with_iframe("resources/empty.html");
+            await iframe.contentWindow.fetch("mouse").then(async (response) => {
+                if (await response.text() !== "cat")
+                    return Promise.reject("not cat");
+            });
+            iframe.remove();
+        }
+    }
+    await Promise.all(promises);
+}, "Ensure all fetches are intercepted");
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/http/wpt/service-workers/update-worker.py (0 => 226904)


--- trunk/LayoutTests/http/wpt/service-workers/update-worker.py	                        (rev 0)
+++ trunk/LayoutTests/http/wpt/service-workers/update-worker.py	2018-01-12 19:43:35 UTC (rev 226904)
@@ -0,0 +1,15 @@
+import time
+
+script = '''
+// Time stamp: %s
+// (This ensures the source text is *not* a byte-for-byte match with any
+// previously-fetched version of this script.)
+
+self.addEventListener("fetch", async (event) => {
+    if (event.request.url.indexOf("mouse") !== -1)
+        event.respondWith(new Response("cat"));
+});'''
+
+
+def main(request, response):
+  return [('Content-Type', 'application/_javascript_'), ('Cache-Control', 'np-cache, no-store')], script % time.time()

Modified: trunk/Source/WebCore/ChangeLog (226903 => 226904)


--- trunk/Source/WebCore/ChangeLog	2018-01-12 19:21:00 UTC (rev 226903)
+++ trunk/Source/WebCore/ChangeLog	2018-01-12 19:43:35 UTC (rev 226904)
@@ -1,3 +1,35 @@
+2018-01-12  Youenn Fablet  <you...@apple.com>
+
+        WebProcess should pass the registration identifier and not the worker identifier for fetch events
+        https://bugs.webkit.org/show_bug.cgi?id=181591
+
+        Reviewed by Chris Dumez.
+
+        Test: http/wpt/service-workers/update-service-worker.https.html
+
+        Store service worker registration identifier in ResourceLoaderOptions instead of service worker identifier.
+
+        * loader/DocumentThreadableLoader.cpp:
+        (WebCore::DocumentThreadableLoader::DocumentThreadableLoader):
+        (WebCore::DocumentThreadableLoader::makeCrossOriginAccessRequest):
+        * loader/ResourceLoaderOptions.h:
+        * loader/WorkerThreadableLoader.cpp:
+        (WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge):
+        * loader/cache/CachedResourceLoader.cpp:
+        (WebCore::CachedResourceLoader::prepareFetch):
+        (WebCore::CachedResourceLoader::determineRevalidationPolicy const):
+        * loader/cache/CachedResourceRequest.cpp:
+        (WebCore::CachedResourceRequest::setSelectedServiceWorkerRegistrationIdentifierIfNeeded):
+        (WebCore::CachedResourceRequest::setNavigationServiceWorkerRegistrationData):
+        (WebCore::CachedResourceRequest::setSelectedServiceWorkerIdentifierIfNeeded): Deleted.
+        * loader/cache/CachedResourceRequest.h:
+        * workers/WorkerScriptLoader.cpp:
+        (WebCore::WorkerScriptLoader::loadSynchronously):
+        (WebCore::WorkerScriptLoader::loadAsynchronously):
+        * workers/service/server/SWServer.cpp:
+        (WebCore::SWServer::activeWorkerFromRegistrationID):
+        * workers/service/server/SWServer.h:
+
 2018-01-12  Fujii Hironori  <hironori.fu...@sony.com>
 
         [Win][CMake] Remove all-in-one file for WebCore DerivedSources

Modified: trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp (226903 => 226904)


--- trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp	2018-01-12 19:21:00 UTC (rev 226903)
+++ trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp	2018-01-12 19:43:35 UTC (rev 226904)
@@ -120,7 +120,7 @@
         m_originalHeaders = request.httpHeaderFields();
 
 #if ENABLE(SERVICE_WORKER)
-    if (m_options.serviceWorkersMode == ServiceWorkersMode::All && m_async && (m_options.serviceWorkerIdentifier || document.activeServiceWorker()))
+    if (m_options.serviceWorkersMode == ServiceWorkersMode::All && m_async && (m_options.serviceWorkerRegistrationIdentifier || document.activeServiceWorker()))
         m_options.httpHeadersToKeep = httpHeadersToKeepFromCleaning(request.httpHeaderFields());
 #endif
 
@@ -155,7 +155,7 @@
     else {
 #if ENABLE(SERVICE_WORKER)
         if (m_options.serviceWorkersMode == ServiceWorkersMode::All && m_async) {
-            if (m_options.serviceWorkerIdentifier || document().activeServiceWorker()) {
+            if (m_options.serviceWorkerRegistrationIdentifier || document().activeServiceWorker()) {
                 ASSERT(!m_bypassingPreflightForServiceWorkerRequest);
                 m_bypassingPreflightForServiceWorkerRequest = WTFMove(request);
                 m_options.serviceWorkersMode = ServiceWorkersMode::Only;

Modified: trunk/Source/WebCore/loader/ResourceLoaderOptions.h (226903 => 226904)


--- trunk/Source/WebCore/loader/ResourceLoaderOptions.h	2018-01-12 19:21:00 UTC (rev 226903)
+++ trunk/Source/WebCore/loader/ResourceLoaderOptions.h	2018-01-12 19:43:35 UTC (rev 226904)
@@ -32,7 +32,7 @@
 
 #include "FetchOptions.h"
 #include "HTTPHeaderNames.h"
-#include "ServiceWorkerIdentifier.h"
+#include "ServiceWorkerTypes.h"
 #include "StoredCredentialsPolicy.h"
 #include <wtf/HashSet.h>
 #include <wtf/Vector.h>
@@ -141,7 +141,7 @@
     InitiatorContext initiatorContext { InitiatorContext::Document };
     ServiceWorkersMode serviceWorkersMode { ServiceWorkersMode::All };
 #if ENABLE(SERVICE_WORKER)
-    std::optional<ServiceWorkerIdentifier> serviceWorkerIdentifier;
+    std::optional<ServiceWorkerRegistrationIdentifier> serviceWorkerRegistrationIdentifier;
     // WebKit loading code is adding some HTTP headers between the application and the time service worker intercepts the fetch.
     // We keep a list of these headers so that we only remove the ones that are set by the loading code and not by the application.
     // FIXME: Remove this when service worker fetch interception happens before the setting of these headers in the loading code.

Modified: trunk/Source/WebCore/loader/WorkerThreadableLoader.cpp (226903 => 226904)


--- trunk/Source/WebCore/loader/WorkerThreadableLoader.cpp	2018-01-12 19:21:00 UTC (rev 226903)
+++ trunk/Source/WebCore/loader/WorkerThreadableLoader.cpp	2018-01-12 19:43:35 UTC (rev 226904)
@@ -129,7 +129,7 @@
 #if ENABLE(SERVICE_WORKER)
     optionsCopy->options.serviceWorkersMode = globalScope.isServiceWorkerGlobalScope() ? ServiceWorkersMode::None : ServiceWorkersMode::All;
     if (auto* activeServiceWorker = globalScope.activeServiceWorker())
-        optionsCopy->options.serviceWorkerIdentifier = activeServiceWorker->identifier();
+        optionsCopy->options.serviceWorkerRegistrationIdentifier = activeServiceWorker->registrationIdentifier();
 #endif
 
     InspectorInstrumentation::willSendRequest(globalScope, m_workerRequestIdentifier, request);

Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp (226903 => 226904)


--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp	2018-01-12 19:21:00 UTC (rev 226903)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp	2018-01-12 19:43:35 UTC (rev 226904)
@@ -723,7 +723,7 @@
 #if ENABLE(SERVICE_WORKER)
         request.setClientIdentifierIfNeeded(document->identifier());
         if (auto* activeServiceWorker = document->activeServiceWorker())
-            request.setSelectedServiceWorkerIdentifierIfNeeded(activeServiceWorker->identifier());
+            request.setSelectedServiceWorkerRegistrationIdentifierIfNeeded(activeServiceWorker->registrationIdentifier());
 #endif
     }
 
@@ -1028,7 +1028,7 @@
 
 #if ENABLE(SERVICE_WORKER)
     // FIXME: We should validate/specify this behavior.
-    if (cachedResourceRequest.options().serviceWorkerIdentifier != existingResource->options().serviceWorkerIdentifier) {
+    if (cachedResourceRequest.options().serviceWorkerRegistrationIdentifier != existingResource->options().serviceWorkerRegistrationIdentifier) {
         LOG(ResourceLoading, "CachedResourceLoader::determineRevalidationPolicy reloading because selected service worker differs");
         return Reload;
     }

Modified: trunk/Source/WebCore/loader/cache/CachedResourceRequest.cpp (226903 => 226904)


--- trunk/Source/WebCore/loader/cache/CachedResourceRequest.cpp	2018-01-12 19:21:00 UTC (rev 226903)
+++ trunk/Source/WebCore/loader/cache/CachedResourceRequest.cpp	2018-01-12 19:43:35 UTC (rev 226904)
@@ -282,7 +282,7 @@
         m_options.clientIdentifier = clientIdentifier;
 }
 
-void CachedResourceRequest::setSelectedServiceWorkerIdentifierIfNeeded(ServiceWorkerIdentifier identifier)
+void CachedResourceRequest::setSelectedServiceWorkerRegistrationIdentifierIfNeeded(ServiceWorkerRegistrationIdentifier identifier)
 {
     if (isNonSubresourceRequest(m_options.destination))
         return;
@@ -291,10 +291,10 @@
 
     if (m_options.serviceWorkersMode == ServiceWorkersMode::None)
         return;
-    if (m_options.serviceWorkerIdentifier)
+    if (m_options.serviceWorkerRegistrationIdentifier)
         return;
 
-    m_options.serviceWorkerIdentifier = identifier;
+    m_options.serviceWorkerRegistrationIdentifier = identifier;
 }
 
 void CachedResourceRequest::setNavigationServiceWorkerRegistrationData(const std::optional<ServiceWorkerRegistrationData>& data)
@@ -303,7 +303,7 @@
         m_options.serviceWorkersMode = ServiceWorkersMode::None;
         return;
     }
-    m_options.serviceWorkerIdentifier = data->activeWorker->identifier;
+    m_options.serviceWorkerRegistrationIdentifier = data->identifier;
 }
 #endif
 

Modified: trunk/Source/WebCore/loader/cache/CachedResourceRequest.h (226903 => 226904)


--- trunk/Source/WebCore/loader/cache/CachedResourceRequest.h	2018-01-12 19:21:00 UTC (rev 226903)
+++ trunk/Source/WebCore/loader/cache/CachedResourceRequest.h	2018-01-12 19:43:35 UTC (rev 226904)
@@ -100,7 +100,7 @@
 
 #if ENABLE(SERVICE_WORKER)
     void setClientIdentifierIfNeeded(DocumentIdentifier);
-    void setSelectedServiceWorkerIdentifierIfNeeded(ServiceWorkerIdentifier);
+    void setSelectedServiceWorkerRegistrationIdentifierIfNeeded(ServiceWorkerRegistrationIdentifier);
     void setNavigationServiceWorkerRegistrationData(const std::optional<ServiceWorkerRegistrationData>&);
 #endif
 

Modified: trunk/Source/WebCore/workers/WorkerScriptLoader.cpp (226903 => 226904)


--- trunk/Source/WebCore/workers/WorkerScriptLoader.cpp	2018-01-12 19:21:00 UTC (rev 226903)
+++ trunk/Source/WebCore/workers/WorkerScriptLoader.cpp	2018-01-12 19:43:35 UTC (rev 226904)
@@ -68,7 +68,7 @@
 #if ENABLE(SERVICE_WORKER)
     options.serviceWorkersMode = workerGlobalScope.isServiceWorkerGlobalScope() ? ServiceWorkersMode::None : ServiceWorkersMode::All;
     if (auto* activeServiceWorker = workerGlobalScope.activeServiceWorker())
-        options.serviceWorkerIdentifier = activeServiceWorker->identifier();
+        options.serviceWorkerRegistrationIdentifier = activeServiceWorker->registrationIdentifier();
 #endif
     WorkerThreadableLoader::loadResourceSynchronously(workerGlobalScope, WTFMove(*request), *this, options);
 }
@@ -98,7 +98,7 @@
 #if ENABLE(SERVICE_WORKER)
     options.serviceWorkersMode = m_client->isServiceWorkerClient() ? ServiceWorkersMode::None : ServiceWorkersMode::All;
     if (auto* activeServiceWorker = scriptExecutionContext.activeServiceWorker())
-        options.serviceWorkerIdentifier = activeServiceWorker->identifier();
+        options.serviceWorkerRegistrationIdentifier = activeServiceWorker->registrationIdentifier();
 #endif
     // During create, callbacks may happen which remove the last reference to this object.
     Ref<WorkerScriptLoader> protectedThis(*this);

Modified: trunk/Source/WebCore/workers/service/server/SWServer.cpp (226903 => 226904)


--- trunk/Source/WebCore/workers/service/server/SWServer.cpp	2018-01-12 19:21:00 UTC (rev 226903)
+++ trunk/Source/WebCore/workers/service/server/SWServer.cpp	2018-01-12 19:43:35 UTC (rev 226904)
@@ -101,6 +101,12 @@
     return iterator->value;
 }
 
+SWServerWorker* SWServer::activeWorkerFromRegistrationID(ServiceWorkerRegistrationIdentifier identifier)
+{
+    auto* registration = m_registrationsByID.get(identifier);
+    return registration ? registration->activeWorker() : nullptr;
+}
+
 SWServerRegistration* SWServer::getRegistration(const ServiceWorkerRegistrationKey& registrationKey)
 {
     return m_registrations.get(registrationKey);

Modified: trunk/Source/WebCore/workers/service/server/SWServer.h (226903 => 226904)


--- trunk/Source/WebCore/workers/service/server/SWServer.h	2018-01-12 19:21:00 UTC (rev 226903)
+++ trunk/Source/WebCore/workers/service/server/SWServer.h	2018-01-12 19:43:35 UTC (rev 226904)
@@ -148,6 +148,7 @@
 
     WEBCORE_EXPORT SWServerWorker* workerByID(ServiceWorkerIdentifier) const;
     WEBCORE_EXPORT std::optional<ServiceWorkerClientData> serviceWorkerClientByID(const ServiceWorkerClientIdentifier&) const;
+    WEBCORE_EXPORT SWServerWorker* activeWorkerFromRegistrationID(ServiceWorkerRegistrationIdentifier);
 
     WEBCORE_EXPORT void markAllWorkersAsTerminated();
     

Modified: trunk/Source/WebKit/ChangeLog (226903 => 226904)


--- trunk/Source/WebKit/ChangeLog	2018-01-12 19:21:00 UTC (rev 226903)
+++ trunk/Source/WebKit/ChangeLog	2018-01-12 19:43:35 UTC (rev 226904)
@@ -1,3 +1,24 @@
+2018-01-12  Youenn Fablet  <you...@apple.com>
+
+        WebProcess should pass the registration identifier and not the worker identifier for fetch events
+        https://bugs.webkit.org/show_bug.cgi?id=181591
+
+        Reviewed by Chris Dumez.
+
+        Use service worker registration identifier to compute the active service worker identifier responsible to handle the fetch event.
+
+        * StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
+        (WebKit::WebSWServerConnection::startFetch):
+        * StorageProcess/ServiceWorker/WebSWServerConnection.h:
+        * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in:
+        * WebProcess/Storage/ServiceWorkerClientFetch.cpp:
+        (WebKit::ServiceWorkerClientFetch::start):
+        * WebProcess/Storage/WebSWClientConnection.cpp:
+        (WebKit::WebSWClientConnection::startFetch):
+        * WebProcess/Storage/WebSWClientConnection.h:
+        * WebProcess/Storage/WebServiceWorkerProvider.cpp:
+        (WebKit::shouldHandleFetch):
+
 2018-01-12  Ryan Haddad  <ryanhad...@apple.com>
 
         Unreviewed, rolling out r226826.

Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp (226903 => 226904)


--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp	2018-01-12 19:21:00 UTC (rev 226903)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp	2018-01-12 19:43:35 UTC (rev 226904)
@@ -126,13 +126,14 @@
     send(Messages::WebSWClientConnection::UpdateWorkerState(worker, state));
 }
 
-void WebSWServerConnection::startFetch(uint64_t fetchIdentifier, ServiceWorkerIdentifier serviceWorkerIdentifier, ResourceRequest&& request, FetchOptions&& options, IPC::FormDataReference&& formData, String&& referrer)
+void WebSWServerConnection::startFetch(uint64_t fetchIdentifier, ServiceWorkerRegistrationIdentifier serviceWorkerRegistrationIdentifier, ResourceRequest&& request, FetchOptions&& options, IPC::FormDataReference&& formData, String&& referrer)
 {
-    auto* worker = server().workerByID(serviceWorkerIdentifier);
+    auto* worker = server().activeWorkerFromRegistrationID(serviceWorkerRegistrationIdentifier);
     if (!worker) {
         m_contentConnection->send(Messages::ServiceWorkerClientFetch::DidNotHandle { }, fetchIdentifier);
         return;
     }
+    auto serviceWorkerIdentifier = worker->identifier();
 
     auto runServerWorkerAndStartFetch = [weakThis = makeWeakPtr(this), this, fetchIdentifier, serviceWorkerIdentifier, request = WTFMove(request), options = WTFMove(options), formData = WTFMove(formData), referrer = WTFMove(referrer)](bool success) mutable {
         if (!weakThis)
@@ -154,10 +155,12 @@
         });
     };
 
-    if (worker->state() == ServiceWorkerState::Activating)
+    if (worker->state() == ServiceWorkerState::Activating) {
         worker->whenActivated(WTFMove(runServerWorkerAndStartFetch));
-    else
-        runServerWorkerAndStartFetch(true);
+        return;
+    }
+    ASSERT(worker->state() == ServiceWorkerState::Activated);
+    runServerWorkerAndStartFetch(true);
 }
 
 void WebSWServerConnection::postMessageToServiceWorker(ServiceWorkerIdentifier destinationIdentifier, IPC::DataReference&& message, const ServiceWorkerOrClientIdentifier& sourceIdentifier)

Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h (226903 => 226904)


--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h	2018-01-12 19:21:00 UTC (rev 226903)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h	2018-01-12 19:43:35 UTC (rev 226904)
@@ -83,7 +83,7 @@
     void notifyClientsOfControllerChange(const HashSet<WebCore::DocumentIdentifier>& contextIdentifiers, const WebCore::ServiceWorkerData& newController);
     void registrationReady(uint64_t registrationReadyRequestIdentifier, WebCore::ServiceWorkerRegistrationData&&) final;
 
-    void startFetch(uint64_t fetchIdentifier, WebCore::ServiceWorkerIdentifier, WebCore::ResourceRequest&&, WebCore::FetchOptions&&, IPC::FormDataReference&&, String&& referrer);
+    void startFetch(uint64_t fetchIdentifier, WebCore::ServiceWorkerRegistrationIdentifier, WebCore::ResourceRequest&&, WebCore::FetchOptions&&, IPC::FormDataReference&&, String&& referrer);
 
     void postMessageToServiceWorker(WebCore::ServiceWorkerIdentifier destination, IPC::DataReference&& message, const WebCore::ServiceWorkerOrClientIdentifier& source);
 

Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in (226903 => 226904)


--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in	2018-01-12 19:21:00 UTC (rev 226903)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in	2018-01-12 19:43:35 UTC (rev 226904)
@@ -29,7 +29,7 @@
     AddServiceWorkerRegistrationInServer(WebCore::ServiceWorkerRegistrationIdentifier identifier)
     RemoveServiceWorkerRegistrationInServer(WebCore::ServiceWorkerRegistrationIdentifier identifier)
 
-    StartFetch(uint64_t identifier, WebCore::ServiceWorkerIdentifier serviceWorkerIdentifier, WebCore::ResourceRequest request, struct WebCore::FetchOptions options, IPC::FormDataReference requestBody, String referrer)
+    StartFetch(uint64_t identifier, WebCore::ServiceWorkerRegistrationIdentifier serviceWorkerRegistrationIdentifier, WebCore::ResourceRequest request, struct WebCore::FetchOptions options, IPC::FormDataReference requestBody, String referrer)
 
     PostMessageToServiceWorker(WebCore::ServiceWorkerIdentifier destination, IPC::DataReference message, WebCore::ServiceWorkerOrClientIdentifier source)
 

Modified: trunk/Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.cpp (226903 => 226904)


--- trunk/Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.cpp	2018-01-12 19:21:00 UTC (rev 226903)
+++ trunk/Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.cpp	2018-01-12 19:43:35 UTC (rev 226904)
@@ -72,7 +72,7 @@
     cleanHTTPRequestHeadersForAccessControl(request, options.httpHeadersToKeep);
 
     ASSERT(options.serviceWorkersMode != ServiceWorkersMode::None);
-    m_connection->startFetch(m_loader->identifier(), options.serviceWorkerIdentifier.value(), request, options, referrer);
+    m_connection->startFetch(m_loader->identifier(), options.serviceWorkerRegistrationIdentifier.value(), request, options, referrer);
 }
 
 // https://fetch.spec.whatwg.org/#http-fetch step 3.3

Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp (226903 => 226904)


--- trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp	2018-01-12 19:21:00 UTC (rev 226903)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp	2018-01-12 19:43:35 UTC (rev 226904)
@@ -192,9 +192,9 @@
     });
 }
 
-void WebSWClientConnection::startFetch(uint64_t fetchIdentifier, WebCore::ServiceWorkerIdentifier serviceWorkerIdentifier, const WebCore::ResourceRequest& request, const WebCore::FetchOptions& options, const String& referrer)
+void WebSWClientConnection::startFetch(uint64_t fetchIdentifier, WebCore::ServiceWorkerRegistrationIdentifier serviceWorkerRegistrationIdentifier, const WebCore::ResourceRequest& request, const WebCore::FetchOptions& options, const String& referrer)
 {
-    send(Messages::WebSWServerConnection::StartFetch { fetchIdentifier, serviceWorkerIdentifier, request, options, IPC::FormDataReference { request.httpBody() }, referrer });
+    send(Messages::WebSWServerConnection::StartFetch { fetchIdentifier, serviceWorkerRegistrationIdentifier, request, options, IPC::FormDataReference { request.httpBody() }, referrer });
 }
 
 void WebSWClientConnection::postMessageToServiceWorkerClient(DocumentIdentifier destinationContextIdentifier, const IPC::DataReference& message, ServiceWorkerData&& source, const String& sourceOrigin)

Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h (226903 => 226904)


--- trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h	2018-01-12 19:21:00 UTC (rev 226903)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h	2018-01-12 19:43:35 UTC (rev 226904)
@@ -60,7 +60,7 @@
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
 
     bool mayHaveServiceWorkerRegisteredForOrigin(const WebCore::SecurityOrigin&) const final;
-    void startFetch(uint64_t fetchIdentifier, WebCore::ServiceWorkerIdentifier, const WebCore::ResourceRequest&, const WebCore::FetchOptions&, const String& referrer);
+    void startFetch(uint64_t fetchIdentifier, WebCore::ServiceWorkerRegistrationIdentifier, const WebCore::ResourceRequest&, const WebCore::FetchOptions&, const String& referrer);
 
     void postMessageToServiceWorkerClient(WebCore::DocumentIdentifier destinationContextIdentifier, const IPC::DataReference& message, WebCore::ServiceWorkerData&& source, const String& sourceOrigin);
 

Modified: trunk/Source/WebKit/WebProcess/Storage/WebServiceWorkerProvider.cpp (226903 => 226904)


--- trunk/Source/WebKit/WebProcess/Storage/WebServiceWorkerProvider.cpp	2018-01-12 19:21:00 UTC (rev 226903)
+++ trunk/Source/WebKit/WebProcess/Storage/WebServiceWorkerProvider.cpp	2018-01-12 19:43:35 UTC (rev 226904)
@@ -67,7 +67,7 @@
     if (isPotentialNavigationOrSubresourceRequest(options.destination))
         return false;
 
-    return !!options.serviceWorkerIdentifier;
+    return !!options.serviceWorkerRegistrationIdentifier;
 }
 
 void WebServiceWorkerProvider::handleFetch(ResourceLoader& loader, CachedResource* resource, PAL::SessionID sessionID, bool shouldClearReferrerOnHTTPSToHTTPRedirect, ServiceWorkerClientFetch::Callback&& callback)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to