Diff
Modified: trunk/LayoutTests/ChangeLog (224701 => 224702)
--- trunk/LayoutTests/ChangeLog 2017-11-10 20:11:14 UTC (rev 224701)
+++ trunk/LayoutTests/ChangeLog 2017-11-10 20:30:58 UTC (rev 224702)
@@ -1,3 +1,16 @@
+2017-11-10 Chris Dumez <[email protected]>
+
+ [Service Workers] Implement "Try Activate" / "Activate" algorithms
+ https://bugs.webkit.org/show_bug.cgi?id=179436
+
+ Reviewed by Brady Eidson.
+
+ Add layout test coverage.
+
+ * http/tests/workers/service/basic-activate-event-expected.txt: Added.
+ * http/tests/workers/service/basic-activate-event.html: Added.
+ * http/tests/workers/service/resources/basic-activate-event-worker.js: Added.
+
2017-11-10 Maciej Stachowiak <[email protected]>
Remove TEC decoders that duplicate ICU decoders
Added: trunk/LayoutTests/http/tests/workers/service/basic-activate-event-expected.txt (0 => 224702)
--- trunk/LayoutTests/http/tests/workers/service/basic-activate-event-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/basic-activate-event-expected.txt 2017-11-10 20:30:58 UTC (rev 224702)
@@ -0,0 +1,2 @@
+PASS: service worker received activate event and resolved the extend lifetime promise
+
Added: trunk/LayoutTests/http/tests/workers/service/basic-activate-event.html (0 => 224702)
--- trunk/LayoutTests/http/tests/workers/service/basic-activate-event.html (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/basic-activate-event.html 2017-11-10 20:30:58 UTC (rev 224702)
@@ -0,0 +1,26 @@
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script>
+navigator.serviceWorker.addEventListener("message", function(event) {
+ if (event.data)
+ log("PASS: service worker received activate event and resolved the extend lifetime promise");
+ else
+ log("FAIL: service worker did not receive activate event or did not resolve the extend lifetime promise");
+
+ finishSWTest();
+});
+
+navigator.serviceWorker.register("resources/basic-activate-event-worker.js", { }).then(function(registration) {
+ waitForState(registration.installing, "activated").then(function() {
+ registration.active.postMessage("CheckResolvedExtendLifetimePromise");
+ });
+}, function() {
+ log("FAIL: Failed to register the service worker");
+ finishSWTest();
+});
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/http/tests/workers/service/resources/basic-activate-event-worker.js (0 => 224702)
--- trunk/LayoutTests/http/tests/workers/service/resources/basic-activate-event-worker.js (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/resources/basic-activate-event-worker.js 2017-11-10 20:30:58 UTC (rev 224702)
@@ -0,0 +1,17 @@
+let resolvedExtendLifetimePromise = false;
+
+self.addEventListener("install", (event) => {
+ self.addEventListener("activate", (event) => {
+ event.waitUntil(new Promise((resolve, reject) => {
+ setTimeout(() => {
+ resolvedExtendLifetimePromise = true;
+ resolve();
+ }, 50);
+ }));
+ });
+});
+
+self.addEventListener("message", (event) => {
+ event.source.postMessage(resolvedExtendLifetimePromise);
+});
+
Modified: trunk/Source/WebCore/ChangeLog (224701 => 224702)
--- trunk/Source/WebCore/ChangeLog 2017-11-10 20:11:14 UTC (rev 224701)
+++ trunk/Source/WebCore/ChangeLog 2017-11-10 20:30:58 UTC (rev 224702)
@@ -1,3 +1,34 @@
+2017-11-10 Chris Dumez <[email protected]>
+
+ [Service Workers] Implement "Try Activate" / "Activate" algorithms
+ https://bugs.webkit.org/show_bug.cgi?id=179436
+
+ Reviewed by Brady Eidson.
+
+ Implement proper "Try Activate" / "Activate" algorithms as per:
+ - https://w3c.github.io/ServiceWorker/#try-activate-algorithm
+ - https://w3c.github.io/ServiceWorker/#activation-algorithm
+
+ Test: http/tests/workers/service/basic-activate-event.html
+
+ * workers/service/context/SWContextManager.cpp:
+ (WebCore::SWContextManager::fireActivateEvent):
+ * workers/service/context/SWContextManager.h:
+ * workers/service/context/ServiceWorkerThread.cpp:
+ (WebCore::ServiceWorkerThread::fireActivateEvent):
+ * workers/service/context/ServiceWorkerThread.h:
+ * workers/service/server/SWServer.cpp:
+ (WebCore::SWServer::Connection::didFinishActivation):
+ (WebCore::SWServer::didFinishActivation):
+ (WebCore::SWServer::fireActivateEvent):
+ * workers/service/server/SWServer.h:
+ * workers/service/server/SWServerJobQueue.cpp:
+ (WebCore::SWServerJobQueue::didFinishInstall):
+ (WebCore::SWServerJobQueue::tryActivate):
+ (WebCore::SWServerJobQueue::activate):
+ (WebCore::SWServerJobQueue::didFinishActivation):
+ * workers/service/server/SWServerJobQueue.h:
+
2017-11-10 Alex Christensen <[email protected]>
Fix debug build after r224700
Modified: trunk/Source/WebCore/workers/service/context/SWContextManager.cpp (224701 => 224702)
--- trunk/Source/WebCore/workers/service/context/SWContextManager.cpp 2017-11-10 20:11:14 UTC (rev 224701)
+++ trunk/Source/WebCore/workers/service/context/SWContextManager.cpp 2017-11-10 20:30:58 UTC (rev 224702)
@@ -83,6 +83,15 @@
serviceWorker->thread().fireInstallEvent();
}
+void SWContextManager::fireActivateEvent(ServiceWorkerIdentifier identifier)
+{
+ auto* serviceWorker = m_workerMap.get(identifier);
+ if (!serviceWorker)
+ return;
+
+ serviceWorker->thread().fireActivateEvent();
+}
+
} // namespace WebCore
#endif
Modified: trunk/Source/WebCore/workers/service/context/SWContextManager.h (224701 => 224702)
--- trunk/Source/WebCore/workers/service/context/SWContextManager.h 2017-11-10 20:11:14 UTC (rev 224701)
+++ trunk/Source/WebCore/workers/service/context/SWContextManager.h 2017-11-10 20:30:58 UTC (rev 224702)
@@ -48,6 +48,7 @@
virtual void postMessageToServiceWorkerClient(const ServiceWorkerClientIdentifier& destinationIdentifier, Ref<SerializedScriptValue>&& message, ServiceWorkerIdentifier source, const String& sourceOrigin) = 0;
virtual void serviceWorkerStartedWithMessage(ServiceWorkerIdentifier, const String& exceptionMessage) = 0;
virtual void didFinishInstall(ServiceWorkerIdentifier, bool wasSuccessful) = 0;
+ virtual void didFinishActivation(ServiceWorkerIdentifier) = 0;
};
WEBCORE_EXPORT void setConnection(std::unique_ptr<Connection>&&);
@@ -57,6 +58,7 @@
WEBCORE_EXPORT ServiceWorkerThreadProxy* serviceWorkerThreadProxy(ServiceWorkerIdentifier) const;
WEBCORE_EXPORT void postMessageToServiceWorkerGlobalScope(ServiceWorkerIdentifier destination, Ref<SerializedScriptValue>&& message, const ServiceWorkerClientIdentifier& sourceIdentifier, const String& sourceOrigin);
WEBCORE_EXPORT void fireInstallEvent(ServiceWorkerIdentifier);
+ WEBCORE_EXPORT void fireActivateEvent(ServiceWorkerIdentifier);
private:
SWContextManager() = default;
Modified: trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp (224701 => 224702)
--- trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp 2017-11-10 20:11:14 UTC (rev 224701)
+++ trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp 2017-11-10 20:30:58 UTC (rev 224702)
@@ -140,6 +140,23 @@
runLoop().postTask(WTFMove(task));
}
+void ServiceWorkerThread::fireActivateEvent()
+{
+ ScriptExecutionContext::Task task([serviceWorkerIdentifier = this->identifier()] (ScriptExecutionContext& context) mutable {
+ auto& serviceWorkerGlobalScope = downcast<ServiceWorkerGlobalScope>(context);
+ auto activateEvent = ExtendableEvent::create(eventNames().activateEvent, { }, ExtendableEvent::IsTrusted::Yes);
+ serviceWorkerGlobalScope.dispatchEvent(activateEvent);
+
+ activateEvent->whenAllExtendLifetimePromisesAreSettled([serviceWorkerIdentifier](HashSet<Ref<DOMPromise>>&&) {
+ callOnMainThread([serviceWorkerIdentifier] () mutable {
+ if (auto* connection = SWContextManager::singleton().connection())
+ connection->didFinishActivation(serviceWorkerIdentifier);
+ });
+ });
+ });
+ runLoop().postTask(WTFMove(task));
+}
+
} // namespace WebCore
#endif // ENABLE(SERVICE_WORKER)
Modified: trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.h (224701 => 224702)
--- trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.h 2017-11-10 20:11:14 UTC (rev 224701)
+++ trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.h 2017-11-10 20:30:58 UTC (rev 224702)
@@ -57,6 +57,7 @@
WEBCORE_EXPORT void postFetchTask(Ref<ServiceWorkerFetch::Client>&&, ResourceRequest&&, FetchOptions&&);
WEBCORE_EXPORT void postMessageToServiceWorkerGlobalScope(Ref<SerializedScriptValue>&&, std::unique_ptr<MessagePortChannelArray>&&, const ServiceWorkerClientIdentifier& sourceIdentifier, const String& sourceOrigin);
void fireInstallEvent();
+ void fireActivateEvent();
uint64_t serverConnectionIdentifier() const { return m_serverConnectionIdentifier; }
const ServiceWorkerContextData& contextData() const { return m_data; }
Modified: trunk/Source/WebCore/workers/service/server/SWServer.cpp (224701 => 224702)
--- trunk/Source/WebCore/workers/service/server/SWServer.cpp 2017-11-10 20:11:14 UTC (rev 224701)
+++ trunk/Source/WebCore/workers/service/server/SWServer.cpp 2017-11-10 20:30:58 UTC (rev 224702)
@@ -117,6 +117,11 @@
m_server.didFinishInstall(*this, key, serviceWorkerIdentifier, wasSuccessful);
}
+void SWServer::Connection::didFinishActivation(const ServiceWorkerRegistrationKey& key, ServiceWorkerIdentifier serviceWorkerIdentifier)
+{
+ m_server.didFinishActivation(*this, key, serviceWorkerIdentifier);
+}
+
void SWServer::Connection::didResolveRegistrationPromise(const ServiceWorkerRegistrationKey& key)
{
m_server.didResolveRegistrationPromise(*this, key);
@@ -242,6 +247,14 @@
jobQueue->didFinishInstall(connection, serviceWorkerIdentifier, wasSuccessful);
}
+void SWServer::didFinishActivation(Connection& connection, const ServiceWorkerRegistrationKey& registrationKey, ServiceWorkerIdentifier serviceWorkerIdentifier)
+{
+ ASSERT_UNUSED(connection, m_connections.contains(connection.identifier()));
+
+ if (auto* registration = getRegistration(registrationKey))
+ SWServerJobQueue::didFinishActivation(*registration, serviceWorkerIdentifier);
+}
+
void SWServer::didResolveRegistrationPromise(Connection& connection, const ServiceWorkerRegistrationKey& registrationKey)
{
ASSERT(m_connections.contains(connection.identifier()));
@@ -295,6 +308,11 @@
connection.fireInstallEvent(serviceWorkerIdentifier);
}
+void SWServer::fireActivateEvent(Connection& connection, ServiceWorkerIdentifier serviceWorkerIdentifier)
+{
+ connection.fireActivateEvent(serviceWorkerIdentifier);
+}
+
void SWServer::taskThreadEntryPoint()
{
ASSERT(!isMainThread());
Modified: trunk/Source/WebCore/workers/service/server/SWServer.h (224701 => 224702)
--- trunk/Source/WebCore/workers/service/server/SWServer.h 2017-11-10 20:11:14 UTC (rev 224701)
+++ trunk/Source/WebCore/workers/service/server/SWServer.h 2017-11-10 20:30:58 UTC (rev 224702)
@@ -62,6 +62,7 @@
WEBCORE_EXPORT void scriptContextFailedToStart(const ServiceWorkerRegistrationKey&, ServiceWorkerIdentifier, const String& message);
WEBCORE_EXPORT void scriptContextStarted(const ServiceWorkerRegistrationKey&, ServiceWorkerIdentifier);
WEBCORE_EXPORT void didFinishInstall(const ServiceWorkerRegistrationKey&, ServiceWorkerIdentifier, bool wasSuccessful);
+ WEBCORE_EXPORT void didFinishActivation(const ServiceWorkerRegistrationKey&, ServiceWorkerIdentifier);
WEBCORE_EXPORT void didResolveRegistrationPromise(const ServiceWorkerRegistrationKey&);
const SWServerRegistration* doRegistrationMatching(const SecurityOriginData& topOrigin, const URL& clientURL) const { return m_server.doRegistrationMatching(topOrigin, clientURL); }
@@ -89,6 +90,7 @@
// Messages to the SW host WebProcess
virtual void installServiceWorkerContext(const ServiceWorkerContextData&) = 0;
virtual void fireInstallEvent(ServiceWorkerIdentifier) = 0;
+ virtual void fireActivateEvent(ServiceWorkerIdentifier) = 0;
SWServer& m_server;
};
@@ -113,6 +115,7 @@
Ref<SWServerWorker> updateWorker(Connection&, const ServiceWorkerRegistrationKey&, const URL&, const String& script, WorkerType);
void fireInstallEvent(Connection&, ServiceWorkerIdentifier);
+ void fireActivateEvent(Connection&, ServiceWorkerIdentifier);
SWServerWorker* workerByID(ServiceWorkerIdentifier identifier) const { return m_workersByID.get(identifier); }
Connection* getConnection(uint64_t identifier) { return m_connections.get(identifier); }
@@ -128,6 +131,7 @@
void scriptContextFailedToStart(Connection&, const ServiceWorkerRegistrationKey&, ServiceWorkerIdentifier, const String& message);
void scriptContextStarted(Connection&, const ServiceWorkerRegistrationKey&, ServiceWorkerIdentifier);
void didFinishInstall(Connection&, const ServiceWorkerRegistrationKey&, ServiceWorkerIdentifier, bool wasSuccessful);
+ void didFinishActivation(Connection&, const ServiceWorkerRegistrationKey&, ServiceWorkerIdentifier);
void didResolveRegistrationPromise(Connection&, const ServiceWorkerRegistrationKey&);
void addClientServiceWorkerRegistration(Connection&, const ServiceWorkerRegistrationKey&, ServiceWorkerRegistrationIdentifier);
Modified: trunk/Source/WebCore/workers/service/server/SWServerJobQueue.cpp (224701 => 224702)
--- trunk/Source/WebCore/workers/service/server/SWServerJobQueue.cpp 2017-11-10 20:11:14 UTC (rev 224701)
+++ trunk/Source/WebCore/workers/service/server/SWServerJobQueue.cpp 2017-11-10 20:30:58 UTC (rev 224702)
@@ -138,7 +138,7 @@
}
// https://w3c.github.io/ServiceWorker/#install
-void SWServerJobQueue::didFinishInstall(SWServer::Connection&, ServiceWorkerIdentifier identifier, bool wasSuccessful)
+void SWServerJobQueue::didFinishInstall(SWServer::Connection& connection, ServiceWorkerIdentifier identifier, bool wasSuccessful)
{
auto* registration = m_server.getRegistration(m_registrationKey);
ASSERT(registration);
@@ -174,17 +174,66 @@
finishCurrentJob();
- // FIXME: Invoke Try Activate with registration
- // FIXME: Do we need "Wait for all the tasks queued by Update Worker State invoked in this algorithm have executed" first?
- auto* waiting = registration->waitingWorker();
- ASSERT(waiting);
+ // FIXME: Wait for all the tasks queued by Update Worker State invoked in this algorithm have executed.
+ tryActivate(m_server, connection, *registration);
+}
- registration->updateRegistrationState(ServiceWorkerRegistrationState::Active, waiting);
- registration->updateRegistrationState(ServiceWorkerRegistrationState::Waiting, nullptr);
- registration->updateWorkerState(*waiting, ServiceWorkerState::Activating);
- registration->updateWorkerState(*waiting, ServiceWorkerState::Activated);
+// https://w3c.github.io/ServiceWorker/#try-activate-algorithm
+void SWServerJobQueue::tryActivate(SWServer& server, SWServer::Connection& connection, SWServerRegistration& registration)
+{
+ // If registration's waiting worker is null, return.
+ if (!registration.waitingWorker())
+ return;
+ // If registration's active worker is not null and registration's active worker's state is activating, return.
+ if (registration.activeWorker() && registration.activeWorker()->state() == ServiceWorkerState::Activating)
+ return;
+
+ // FIXME: Invoke Activate with registration if either of the following is true:
+ // - registration's active worker is null.
+ // - The result of running Service Worker Has No Pending Events with registration's active worker is true,
+ // and no service worker client is using registration or registration's waiting worker's skip waiting
+ // flag is set.
+ activate(server, connection, registration);
}
+// https://w3c.github.io/ServiceWorker/#activate
+void SWServerJobQueue::activate(SWServer& server, SWServer::Connection& connection, SWServerRegistration& registration)
+{
+ // If registration's waiting worker is null, abort these steps.
+ if (!registration.waitingWorker())
+ return;
+
+ // If registration's active worker is not null, then:
+ if (registration.activeWorker()) {
+ // Terminate registration's active worker.
+ // registration.activeWorker()->terminate();
+ // Run the Update Worker State algorithm passing registration's active worker and redundant as the arguments.
+ registration.updateWorkerState(*registration.activeWorker(), ServiceWorkerState::Redundant);
+ }
+ // Run the Update Registration State algorithm passing registration, "active" and registration's waiting worker as the arguments.
+ registration.updateRegistrationState(ServiceWorkerRegistrationState::Active, registration.waitingWorker());
+ // Run the Update Registration State algorithm passing registration, "waiting" and null as the arguments.
+ registration.updateRegistrationState(ServiceWorkerRegistrationState::Waiting, nullptr);
+ // Run the Update Worker State algorithm passing registration's active worker and activating as the arguments.
+ registration.updateWorkerState(*registration.activeWorker(), ServiceWorkerState::Activating);
+ // FIXME: For each service worker client client whose creation URL matches registration's scope url...
+ // FIXME: For each service worker client client who is using registration...
+ // FIXME: Invoke Run Service Worker algorithm with activeWorker as the argument.
+
+ // Queue a task to fire the activate event.
+ server.fireActivateEvent(connection, registration.activeWorker()->identifier());
+}
+
+// https://w3c.github.io/ServiceWorker/#activate (post activate event steps).
+void SWServerJobQueue::didFinishActivation(SWServerRegistration& registration, ServiceWorkerIdentifier serviceWorkerIdentifier)
+{
+ if (!registration.activeWorker() || registration.activeWorker()->identifier() != serviceWorkerIdentifier)
+ return;
+
+ // Run the Update Worker State algorithm passing registration's active worker and activated as the arguments.
+ registration.updateWorkerState(*registration.activeWorker(), ServiceWorkerState::Activated);
+}
+
// https://w3c.github.io/ServiceWorker/#run-job
void SWServerJobQueue::runNextJob()
{
Modified: trunk/Source/WebCore/workers/service/server/SWServerJobQueue.h (224701 => 224702)
--- trunk/Source/WebCore/workers/service/server/SWServerJobQueue.h 2017-11-10 20:11:14 UTC (rev 224701)
+++ trunk/Source/WebCore/workers/service/server/SWServerJobQueue.h 2017-11-10 20:30:58 UTC (rev 224702)
@@ -51,6 +51,7 @@
void scriptContextFailedToStart(SWServer::Connection&, ServiceWorkerIdentifier, const String& message);
void scriptContextStarted(SWServer::Connection&, ServiceWorkerIdentifier);
void didFinishInstall(SWServer::Connection&, ServiceWorkerIdentifier, bool wasSuccessful);
+ static void didFinishActivation(SWServerRegistration&, ServiceWorkerIdentifier);
void didResolveRegistrationPromise(SWServer::Connection&);
private:
@@ -66,6 +67,8 @@
void tryClearRegistration(SWServerRegistration&);
void clearRegistration(SWServerRegistration&);
void install(SWServerRegistration&, SWServer::Connection&, ServiceWorkerIdentifier);
+ static void tryActivate(SWServer&, SWServer::Connection&, SWServerRegistration&);
+ static void activate(SWServer&, SWServer::Connection&, SWServerRegistration&);
Deque<ServiceWorkerJobData> m_jobQueue;
Modified: trunk/Source/WebKit/ChangeLog (224701 => 224702)
--- trunk/Source/WebKit/ChangeLog 2017-11-10 20:11:14 UTC (rev 224701)
+++ trunk/Source/WebKit/ChangeLog 2017-11-10 20:30:58 UTC (rev 224702)
@@ -1,3 +1,27 @@
+2017-11-10 Chris Dumez <[email protected]>
+
+ [Service Workers] Implement "Try Activate" / "Activate" algorithms
+ https://bugs.webkit.org/show_bug.cgi?id=179436
+
+ Reviewed by Brady Eidson.
+
+ Implement proper "Try Activate" / "Activate" algorithms as per:
+ - https://w3c.github.io/ServiceWorker/#try-activate-algorithm
+ - https://w3c.github.io/ServiceWorker/#activation-algorithm
+
+ * StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
+ (WebKit::WebSWServerConnection::fireActivateEvent):
+ * StorageProcess/ServiceWorker/WebSWServerConnection.h:
+ * StorageProcess/StorageProcess.cpp:
+ (WebKit::StorageProcess::didFinishServiceWorkerActivation):
+ * StorageProcess/StorageProcess.h:
+ * StorageProcess/StorageProcess.messages.in:
+ * WebProcess/Storage/WebSWContextManagerConnection.cpp:
+ (WebKit::WebSWContextManagerConnection::fireActivateEvent):
+ (WebKit::WebSWContextManagerConnection::didFinishActivation):
+ * WebProcess/Storage/WebSWContextManagerConnection.h:
+ * WebProcess/Storage/WebSWContextManagerConnection.messages.in:
+
2017-11-10 John Wilander <[email protected]>
Ignore HSTS for partitioned, cross-origin subresource requests
Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp (224701 => 224702)
--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp 2017-11-10 20:11:14 UTC (rev 224701)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp 2017-11-10 20:30:58 UTC (rev 224702)
@@ -124,6 +124,11 @@
sendToContextProcess(Messages::WebSWContextManagerConnection::FireInstallEvent(identifier(), serviceWorkerIdentifier));
}
+void WebSWServerConnection::fireActivateEvent(ServiceWorkerIdentifier serviceWorkerIdentifier)
+{
+ sendToContextProcess(Messages::WebSWContextManagerConnection::FireActivateEvent(identifier(), serviceWorkerIdentifier));
+}
+
void WebSWServerConnection::startFetch(uint64_t fetchIdentifier, std::optional<ServiceWorkerIdentifier> serviceWorkerIdentifier, const ResourceRequest& request, const FetchOptions& options)
{
sendToContextProcess(Messages::WebSWContextManagerConnection::StartFetch(identifier(), fetchIdentifier, serviceWorkerIdentifier, request, options));
Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h (224701 => 224702)
--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h 2017-11-10 20:11:14 UTC (rev 224701)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h 2017-11-10 20:30:58 UTC (rev 224702)
@@ -78,6 +78,7 @@
// Messages to the SW context WebProcess
void installServiceWorkerContext(const WebCore::ServiceWorkerContextData&) final;
void fireInstallEvent(WebCore::ServiceWorkerIdentifier) final;
+ void fireActivateEvent(WebCore::ServiceWorkerIdentifier) final;
IPC::Connection* messageSenderConnection() final { return m_contentConnection.ptr(); }
uint64_t messageSenderDestinationID() final { return identifier(); }
Modified: trunk/Source/WebKit/StorageProcess/StorageProcess.cpp (224701 => 224702)
--- trunk/Source/WebKit/StorageProcess/StorageProcess.cpp 2017-11-10 20:11:14 UTC (rev 224701)
+++ trunk/Source/WebKit/StorageProcess/StorageProcess.cpp 2017-11-10 20:30:58 UTC (rev 224702)
@@ -459,6 +459,12 @@
connection->didFinishInstall(registrationKey, serviceWorkerIdentifier, wasSuccessful);
}
+void StorageProcess::didFinishServiceWorkerActivation(uint64_t serverConnectionIdentifier, const ServiceWorkerRegistrationKey& registrationKey, ServiceWorkerIdentifier serviceWorkerIdentifier)
+{
+ if (auto* connection = m_swServerConnections.get(serverConnectionIdentifier))
+ connection->didFinishActivation(registrationKey, serviceWorkerIdentifier);
+}
+
void StorageProcess::registerSWServerConnection(WebSWServerConnection& connection)
{
ASSERT(!m_swServerConnections.contains(connection.identifier()));
Modified: trunk/Source/WebKit/StorageProcess/StorageProcess.h (224701 => 224702)
--- trunk/Source/WebKit/StorageProcess/StorageProcess.h 2017-11-10 20:11:14 UTC (rev 224701)
+++ trunk/Source/WebKit/StorageProcess/StorageProcess.h 2017-11-10 20:30:58 UTC (rev 224702)
@@ -129,6 +129,7 @@
void didNotHandleFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier);
void didFinishServiceWorkerInstall(uint64_t serverConnectionIdentifier, const WebCore::ServiceWorkerRegistrationKey&, WebCore::ServiceWorkerIdentifier, bool wasSuccessful);
+ void didFinishServiceWorkerActivation(uint64_t serverConnectionIdentifier, const WebCore::ServiceWorkerRegistrationKey&, WebCore::ServiceWorkerIdentifier);
void postMessageToServiceWorkerClient(const WebCore::ServiceWorkerClientIdentifier& destinationIdentifier, const IPC::DataReference& message, WebCore::ServiceWorkerIdentifier sourceIdentifier, const String& sourceOrigin);
#endif
#if ENABLE(INDEXED_DATABASE)
Modified: trunk/Source/WebKit/StorageProcess/StorageProcess.messages.in (224701 => 224702)
--- trunk/Source/WebKit/StorageProcess/StorageProcess.messages.in 2017-11-10 20:11:14 UTC (rev 224701)
+++ trunk/Source/WebKit/StorageProcess/StorageProcess.messages.in 2017-11-10 20:30:58 UTC (rev 224702)
@@ -41,6 +41,7 @@
ServiceWorkerContextFailedToStart(uint64_t serverConnectionIdentifier, WebCore::ServiceWorkerRegistrationKey registrationKey, WebCore::ServiceWorkerIdentifier serviceWorkerIdentifier, String message)
ServiceWorkerContextStarted(uint64_t serverConnectionIdentifier, WebCore::ServiceWorkerRegistrationKey registrationKey, WebCore::ServiceWorkerIdentifier serviceWorkerIdentifier)
DidFinishServiceWorkerInstall(uint64_t serverConnectionIdentifier, WebCore::ServiceWorkerRegistrationKey registrationKey, WebCore::ServiceWorkerIdentifier serviceWorkerIdentifier, bool wasSuccessful);
+ DidFinishServiceWorkerActivation(uint64_t serverConnectionIdentifier, WebCore::ServiceWorkerRegistrationKey registrationKey, WebCore::ServiceWorkerIdentifier serviceWorkerIdentifier);
DidNotHandleFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier)
DidFailFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier)
Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp (224701 => 224702)
--- trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp 2017-11-10 20:11:14 UTC (rev 224701)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp 2017-11-10 20:30:58 UTC (rev 224702)
@@ -155,6 +155,12 @@
SWContextManager::singleton().fireInstallEvent(identifier);
}
+void WebSWContextManagerConnection::fireActivateEvent(uint64_t serverConnectionIdentifier, ServiceWorkerIdentifier identifier)
+{
+ UNUSED_PARAM(serverConnectionIdentifier);
+ SWContextManager::singleton().fireActivateEvent(identifier);
+}
+
void WebSWContextManagerConnection::postMessageToServiceWorkerClient(const ServiceWorkerClientIdentifier& destinationIdentifier, Ref<SerializedScriptValue>&& message, ServiceWorkerIdentifier sourceIdentifier, const String& sourceOrigin)
{
m_connectionToStorageProcess->send(Messages::StorageProcess::PostMessageToServiceWorkerClient(destinationIdentifier, IPC::DataReference { message->data() }, sourceIdentifier, sourceOrigin), 0);
@@ -169,6 +175,15 @@
m_connectionToStorageProcess->send(Messages::StorageProcess::DidFinishServiceWorkerInstall(threadProxy->thread().serverConnectionIdentifier(), data.registrationKey, serviceWorkerIdentifier, wasSuccessful), 0);
}
+void WebSWContextManagerConnection::didFinishActivation(ServiceWorkerIdentifier serviceWorkerIdentifier)
+{
+ auto* threadProxy = SWContextManager::singleton().serviceWorkerThreadProxy(serviceWorkerIdentifier);
+ ASSERT(threadProxy);
+
+ auto& data = ""
+ m_connectionToStorageProcess->send(Messages::StorageProcess::DidFinishServiceWorkerActivation(threadProxy->thread().serverConnectionIdentifier(), data.registrationKey, serviceWorkerIdentifier), 0);
+}
+
} // namespace WebCore
#endif // ENABLE(SERVICE_WORKER)
Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h (224701 => 224702)
--- trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h 2017-11-10 20:11:14 UTC (rev 224701)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h 2017-11-10 20:30:58 UTC (rev 224702)
@@ -53,6 +53,7 @@
// WebCore::SWContextManager::Connection.
void postMessageToServiceWorkerClient(const WebCore::ServiceWorkerClientIdentifier& destinationIdentifier, Ref<WebCore::SerializedScriptValue>&& message, WebCore::ServiceWorkerIdentifier sourceIdentifier, const String& sourceOrigin) final;
void didFinishInstall(WebCore::ServiceWorkerIdentifier, bool wasSuccessful) final;
+ void didFinishActivation(WebCore::ServiceWorkerIdentifier) final;
// IPC messages.
void serviceWorkerStartedWithMessage(WebCore::ServiceWorkerIdentifier, const String& exceptionMessage) final;
@@ -60,6 +61,7 @@
void startFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, std::optional<WebCore::ServiceWorkerIdentifier>, WebCore::ResourceRequest&&, WebCore::FetchOptions&&);
void postMessageToServiceWorkerGlobalScope(WebCore::ServiceWorkerIdentifier destinationIdentifier, const IPC::DataReference& message, const WebCore::ServiceWorkerClientIdentifier& sourceIdentifier, const String& sourceOrigin);
void fireInstallEvent(uint64_t serverConnectionIdentifier, WebCore::ServiceWorkerIdentifier);
+ void fireActivateEvent(uint64_t serverConnectionIdentifier, WebCore::ServiceWorkerIdentifier);
Ref<IPC::Connection> m_connectionToStorageProcess;
uint64_t m_pageID { 0 };
Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.messages.in (224701 => 224702)
--- trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.messages.in 2017-11-10 20:11:14 UTC (rev 224701)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.messages.in 2017-11-10 20:30:58 UTC (rev 224702)
@@ -27,6 +27,7 @@
StartFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, std::optional<WebCore::ServiceWorkerIdentifier> serviceWorkerIdentifier, WebCore::ResourceRequest request, struct WebCore::FetchOptions options)
PostMessageToServiceWorkerGlobalScope(WebCore::ServiceWorkerIdentifier destinationIdentifier, IPC::DataReference message, struct WebCore::ServiceWorkerClientIdentifier sourceIdentifier, String sourceOrigin)
FireInstallEvent(uint64_t serverConnectionIdentifier, WebCore::ServiceWorkerIdentifier identifier)
+ FireActivateEvent(uint64_t serverConnectionIdentifier, WebCore::ServiceWorkerIdentifier identifier)
}
#endif