Diff
Modified: trunk/LayoutTests/ChangeLog (224541 => 224542)
--- trunk/LayoutTests/ChangeLog 2017-11-07 20:02:48 UTC (rev 224541)
+++ trunk/LayoutTests/ChangeLog 2017-11-07 20:11:58 UTC (rev 224542)
@@ -1,3 +1,18 @@
+2017-11-07 Chris Dumez <[email protected]>
+
+ [Service Workers] Add support for "install" event
+ https://bugs.webkit.org/show_bug.cgi?id=179338
+
+ Reviewed by Youenn Fablet.
+
+ Add layout test coverage.
+
+ * http/tests/workers/service/basic-install-event-expected.txt: Added.
+ * http/tests/workers/service/basic-install-event.html: Added.
+ * http/tests/workers/service/resources/basic-install-event-worker.js: Added.
+ * http/tests/workers/service/resources/sw-test-pre.js:
+ (waitForState):
+
2017-11-07 Ryan Haddad <[email protected]>
Unreviewed, rolling out r224498.
Modified: trunk/LayoutTests/TestExpectations (224541 => 224542)
--- trunk/LayoutTests/TestExpectations 2017-11-07 20:02:48 UTC (rev 224541)
+++ trunk/LayoutTests/TestExpectations 2017-11-07 20:11:58 UTC (rev 224542)
@@ -140,8 +140,6 @@
imported/w3c/web-platform-tests/secure-contexts/shared-worker-secure-first.https.html [ Skip ]
# Skip service worker tests that are timing out.
-imported/w3c/web-platform-tests/service-workers/service-worker/ServiceWorkerGlobalScope/close.https.html [ Skip ]
-imported/w3c/web-platform-tests/service-workers/service-worker/ServiceWorkerGlobalScope/extendable-message-event-constructor.https.html [ Skip ]
imported/w3c/web-platform-tests/service-workers/service-worker/ServiceWorkerGlobalScope/extendable-message-event.https.html [ Skip ]
imported/w3c/web-platform-tests/service-workers/service-worker/ServiceWorkerGlobalScope/unregister.https.html [ Skip ]
imported/w3c/web-platform-tests/service-workers/service-worker/ServiceWorkerGlobalScope/update.https.html [ Skip ]
Added: trunk/LayoutTests/http/tests/workers/service/basic-install-event-expected.txt (0 => 224542)
--- trunk/LayoutTests/http/tests/workers/service/basic-install-event-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/basic-install-event-expected.txt 2017-11-07 20:11:58 UTC (rev 224542)
@@ -0,0 +1,2 @@
+PASS: service worker received install event
+
Added: trunk/LayoutTests/http/tests/workers/service/basic-install-event.html (0 => 224542)
--- trunk/LayoutTests/http/tests/workers/service/basic-install-event.html (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/basic-install-event.html 2017-11-07 20:11:58 UTC (rev 224542)
@@ -0,0 +1,23 @@
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script>
+navigator.serviceWorker.addEventListener("message", function(event) {
+ if (event.data)
+ log("PASS: service worker received install event");
+ else
+ log("FAIL: service worker did not receive install event");
+
+ finishSWTest();
+});
+
+navigator.serviceWorker.register("resources/basic-install-event-worker.js", { }).then(function(registration) {
+ waitForState(registration.installing, "installed").then(function() {
+ registration.waiting.postMessage("CheckReceivedPageState");
+ });
+});
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/http/tests/workers/service/resources/basic-install-event-worker.js (0 => 224542)
--- trunk/LayoutTests/http/tests/workers/service/resources/basic-install-event-worker.js (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/resources/basic-install-event-worker.js 2017-11-07 20:11:58 UTC (rev 224542)
@@ -0,0 +1,10 @@
+let receivedInstallEvent = false;
+
+self.addEventListener("install", (event) => {
+ receivedInstallEvent = true;
+});
+
+self.addEventListener("message", (event) => {
+ event.source.postMessage(receivedInstallEvent);
+});
+
Modified: trunk/LayoutTests/http/tests/workers/service/resources/sw-test-pre.js (224541 => 224542)
--- trunk/LayoutTests/http/tests/workers/service/resources/sw-test-pre.js 2017-11-07 20:02:48 UTC (rev 224541)
+++ trunk/LayoutTests/http/tests/workers/service/resources/sw-test-pre.js 2017-11-07 20:11:58 UTC (rev 224542)
@@ -1,7 +1,7 @@
// All SW tests are async and text-only
if (window.testRunner) {
- testRunner.dumpAsText();
- testRunner.waitUntilDone();
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
}
function log(msg)
@@ -17,6 +17,22 @@
console.appendChild(span);
}
+function waitForState(worker, state)
+{
+ if (!worker || worker.state == undefined)
+ return Promise.reject(new Error('wait_for_state must be passed a ServiceWorker'));
+
+ if (worker.state === state)
+ return Promise.resolve(state);
+
+ return new Promise(function(resolve) {
+ worker.addEventListener('statechange', function() {
+ if (worker.state === state)
+ resolve(state);
+ });
+ });
+}
+
function finishSWTest()
{
if (window.testRunner)
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/foreign-fetch-event.https-expected.txt (224541 => 224542)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/foreign-fetch-event.https-expected.txt 2017-11-07 20:02:48 UTC (rev 224541)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/foreign-fetch-event.https-expected.txt 2017-11-07 20:11:58 UTC (rev 224542)
@@ -1,5 +1,13 @@
-Harness Error (TIMEOUT), message = null
-
PASS ForeignFetchEvent constructor
+FAIL ForeignFetchEvent constructor with no init dict assert_throws: function "function () {
+ new ForeignFetchEvent('type');
+ }" threw object "ReferenceError: Can't find variable: ForeignFetchEvent" ("ReferenceError") expected object "TypeError" ("TypeError")
+FAIL ForeignFetchEvent constructor with empty init dict assert_throws: function "function () {
+ new ForeignFetchEvent('type', {});
+ }" threw object "ReferenceError: Can't find variable: ForeignFetchEvent" ("ReferenceError") expected object "TypeError" ("TypeError")
+FAIL ForeignFetchEvent constructor with null request assert_throws: function "function () {
+ new ForeignFetchEvent('type', { request: null });
+ }" threw object "ReferenceError: Can't find variable: ForeignFetchEvent" ("ReferenceError") expected object "TypeError" ("TypeError")
+FAIL ForeignFetchEvent constructor with all init dict members Can't find variable: ForeignFetchEvent
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/registration-mime-types.https-expected.txt (224541 => 224542)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/registration-mime-types.https-expected.txt 2017-11-07 20:02:48 UTC (rev 224541)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/registration-mime-types.https-expected.txt 2017-11-07 20:11:58 UTC (rev 224542)
@@ -1,6 +1,6 @@
-FAIL Registering script with no MIME type assert_unreached: Should have rejected: Registration of no MIME type script should fail. Reached unreachable code
-FAIL Registering script with bad MIME type assert_unreached: Should have rejected: Registration of plain text script should fail. Reached unreachable code
+PASS Registering script with no MIME type
+PASS Registering script with bad MIME type
FAIL Registering script that imports script with no MIME type assert_unreached: Should have rejected: Registration of no MIME type imported script should fail. Reached unreachable code
FAIL Registering script that imports script with bad MIME type assert_unreached: Should have rejected: Registration of plain text imported script should fail. Reached unreachable code
PASS Registering script with good MIME type application/ecmascript
Modified: trunk/Source/WebCore/ChangeLog (224541 => 224542)
--- trunk/Source/WebCore/ChangeLog 2017-11-07 20:02:48 UTC (rev 224541)
+++ trunk/Source/WebCore/ChangeLog 2017-11-07 20:11:58 UTC (rev 224542)
@@ -1,3 +1,44 @@
+2017-11-07 Chris Dumez <[email protected]>
+
+ [Service Workers] Add support for "install" event
+ https://bugs.webkit.org/show_bug.cgi?id=179338
+
+ Reviewed by Youenn Fablet.
+
+ Add support for "install" event as per:
+ - https://w3c.github.io/ServiceWorker/#installation-algorithm (Step 10)
+
+ For now, install always succeeds as our support for ExtendableEvent.waitUntil() is
+ still incomplete.
+
+ Test: http/tests/workers/service/basic-install-event.html
+
+ * workers/service/ServiceWorkerContainer.cpp:
+ (WebCore::ServiceWorkerContainer::firePostInstallEvents):
+ * workers/service/ServiceWorkerContainer.h:
+ * workers/service/context/SWContextManager.cpp:
+ (WebCore::SWContextManager::fireInstallEvent):
+ * workers/service/context/SWContextManager.h:
+ * workers/service/context/ServiceWorkerThread.cpp:
+ (WebCore::ServiceWorkerThread::fireInstallEvent):
+ * workers/service/context/ServiceWorkerThread.h:
+ * workers/service/server/SWClientConnection.cpp:
+ (WebCore::SWClientConnection::firePostInstallEvents):
+ * workers/service/server/SWClientConnection.h:
+ * workers/service/server/SWServer.cpp:
+ (WebCore::SWServer::Connection::didFinishInstall):
+ (WebCore::SWServer::didFinishInstall):
+ (WebCore::SWServer::fireInstallEvent):
+ * workers/service/server/SWServer.h:
+ * workers/service/server/SWServerJobQueue.cpp:
+ (WebCore::SWServerJobQueue::scriptContextStarted):
+ (WebCore::SWServerJobQueue::install):
+ (WebCore::SWServerJobQueue::didFinishInstall):
+ * workers/service/server/SWServerJobQueue.h:
+ * workers/service/server/SWServerRegistration.cpp:
+ (WebCore::SWServerRegistration::firePostInstallEvents):
+ * workers/service/server/SWServerRegistration.h:
+
2017-11-07 Ryan Haddad <[email protected]>
Unreviewed, rolling out r224498.
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp (224541 => 224542)
--- trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp 2017-11-07 20:02:48 UTC (rev 224541)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp 2017-11-07 20:11:58 UTC (rev 224542)
@@ -263,10 +263,26 @@
jobDidFinish(job);
}
-class FireUpdateFoundEventMicrotask final : public Microtask {
+void ServiceWorkerContainer::fireUpdateFoundEvent(const ServiceWorkerRegistrationKey& key)
+{
+ if (isStopped())
+ return;
+
+ auto* registration = m_registrations.get(key);
+ if (!registration)
+ return;
+
+ scriptExecutionContext()->postTask([container = makeRef(*this), registration = makeRef(*registration)] (ScriptExecutionContext&) {
+ if (container->isStopped())
+ return;
+ registration->dispatchEvent(Event::create(eventNames().updatefoundEvent, false, false));
+ });
+}
+
+class FirePostInstallEventsMicrotask final : public Microtask {
WTF_MAKE_FAST_ALLOCATED;
public:
- explicit FireUpdateFoundEventMicrotask(Ref<ServiceWorkerContainer>&& container, Ref<ServiceWorkerRegistration>&& registration)
+ explicit FirePostInstallEventsMicrotask(Ref<ServiceWorkerContainer>&& container, Ref<ServiceWorkerRegistration>&& registration)
: m_container(WTFMove(container))
, m_registration(WTFMove(registration))
{
@@ -274,27 +290,26 @@
private:
Result run() final
{
- callOnMainThread([container = WTFMove(m_container), registration = WTFMove(m_registration)] () mutable {
+ auto* serviceWorker = m_registration->installing();
+ if (!serviceWorker)
+ return Result::Done;
+
+ callOnMainThread([container = WTFMove(m_container), registration = WTFMove(m_registration), serviceWorker = makeRef(*serviceWorker)] () mutable {
if (container->isStopped())
return;
-
- registration->dispatchEvent(Event::create(eventNames().updatefoundEvent, false, false));
-
- // FIXME: We currently fake a few events to make it look like we are installing and activating the service worker.
- callOnMainThread([registration = WTFMove(registration)] () mutable {
- if (!registration->installing())
+ registration->setInstallingWorker(nullptr);
+ registration->setWaitingWorker(serviceWorker.copyRef());
+ serviceWorker->setState(ServiceWorker::State::Installed);
+ callOnMainThread([container = WTFMove(container), registration = WTFMove(registration), serviceWorker = WTFMove(serviceWorker)] () mutable {
+ if (container->isStopped())
return;
-
- registration->setWaitingWorker(registration->installing());
- registration->setInstallingWorker(nullptr);
- registration->waiting()->setState(ServiceWorker::State::Installed);
- callOnMainThread([registration = WTFMove(registration)] () mutable {
- registration->setActiveWorker(registration->waiting());
- registration->setWaitingWorker(nullptr);
- registration->active()->setState(ServiceWorker::State::Activating);
- callOnMainThread([registration = WTFMove(registration)] () mutable {
- registration->active()->setState(ServiceWorker::State::Activated);
- });
+ registration->setWaitingWorker(nullptr);
+ registration->setActiveWorker(serviceWorker.copyRef());
+ serviceWorker->setState(ServiceWorker::State::Activating);
+ callOnMainThread([container = WTFMove(container), serviceWorker = WTFMove(serviceWorker)] () mutable {
+ if (container->isStopped())
+ return;
+ serviceWorker->setState(ServiceWorker::State::Activated);
});
});
});
@@ -305,7 +320,8 @@
Ref<ServiceWorkerRegistration> m_registration;
};
-void ServiceWorkerContainer::fireUpdateFoundEvent(const ServiceWorkerRegistrationKey& key)
+// FIXME: This method is only use to mimick service worker activation and will do away once we implement it.
+void ServiceWorkerContainer::firePostInstallEvents(const ServiceWorkerRegistrationKey& key)
{
if (isStopped())
return;
@@ -314,7 +330,7 @@
if (!registration)
return;
- MicrotaskQueue::mainThreadQueue().append(std::make_unique<FireUpdateFoundEventMicrotask>(*this, *registration));
+ MicrotaskQueue::mainThreadQueue().append(std::make_unique<FirePostInstallEventsMicrotask>(*this, *registration));
}
void ServiceWorkerContainer::jobResolvedWithRegistration(ServiceWorkerJob& job, ServiceWorkerRegistrationData&& data)
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h (224541 => 224542)
--- trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h 2017-11-07 20:02:48 UTC (rev 224541)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h 2017-11-07 20:11:58 UTC (rev 224542)
@@ -67,6 +67,7 @@
void getRegistration(const String& clientURL, Ref<DeferredPromise>&&);
void updateRegistration(const ServiceWorkerRegistrationKey&, ServiceWorkerRegistrationState, const std::optional<ServiceWorkerIdentifier>&);
void fireUpdateFoundEvent(const ServiceWorkerRegistrationKey&);
+ void firePostInstallEvents(const ServiceWorkerRegistrationKey&);
using RegistrationsPromise = DOMPromiseDeferred<IDLSequence<IDLInterface<ServiceWorkerRegistration>>>;
void getRegistrations(RegistrationsPromise&&);
Modified: trunk/Source/WebCore/workers/service/context/SWContextManager.cpp (224541 => 224542)
--- trunk/Source/WebCore/workers/service/context/SWContextManager.cpp 2017-11-07 20:02:48 UTC (rev 224541)
+++ trunk/Source/WebCore/workers/service/context/SWContextManager.cpp 2017-11-07 20:11:58 UTC (rev 224542)
@@ -74,6 +74,15 @@
serviceWorker->thread().postMessageToServiceWorkerGlobalScope(WTFMove(message), nullptr, sourceIdentifier, sourceOrigin);
}
+void SWContextManager::fireInstallEvent(ServiceWorkerIdentifier identifier)
+{
+ auto* serviceWorker = m_workerMap.get(identifier);
+ if (!serviceWorker)
+ return;
+
+ serviceWorker->thread().fireInstallEvent();
+}
+
} // namespace WebCore
#endif
Modified: trunk/Source/WebCore/workers/service/context/SWContextManager.h (224541 => 224542)
--- trunk/Source/WebCore/workers/service/context/SWContextManager.h 2017-11-07 20:02:48 UTC (rev 224541)
+++ trunk/Source/WebCore/workers/service/context/SWContextManager.h 2017-11-07 20:11:58 UTC (rev 224542)
@@ -47,6 +47,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;
};
WEBCORE_EXPORT void setConnection(std::unique_ptr<Connection>&&);
@@ -55,7 +56,7 @@
WEBCORE_EXPORT void registerServiceWorkerThreadForUpdate(Ref<ServiceWorkerThreadProxy>&&);
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);
private:
SWContextManager() = default;
Modified: trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp (224541 => 224542)
--- trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp 2017-11-07 20:02:48 UTC (rev 224541)
+++ trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp 2017-11-07 20:11:58 UTC (rev 224542)
@@ -30,6 +30,7 @@
#include "CacheStorageProvider.h"
#include "ContentSecurityPolicyResponseHeaders.h"
+#include "EventNames.h"
#include "ExtendableMessageEvent.h"
#include "SecurityOrigin.h"
#include "ServiceWorkerFetch.h"
@@ -114,6 +115,22 @@
runLoop().postTask(WTFMove(task));
}
+void ServiceWorkerThread::fireInstallEvent()
+{
+ ScriptExecutionContext::Task task([serviceWorkerIdentifier = this->identifier()] (ScriptExecutionContext& context) mutable {
+ auto& serviceWorkerGlobalScope = downcast<ServiceWorkerGlobalScope>(context);
+ auto installEvent = ExtendableEvent::create(eventNames().installEvent, { }, ExtendableEvent::IsTrusted::Yes);
+ serviceWorkerGlobalScope.dispatchEvent(installEvent);
+
+ // FIXME: We are supposed to wait for all installEvent's extend lifetime promises.
+ callOnMainThread([serviceWorkerIdentifier] () mutable {
+ if (auto* connection = SWContextManager::singleton().connection())
+ connection->didFinishInstall(serviceWorkerIdentifier, true);
+ });
+ });
+ runLoop().postTask(WTFMove(task));
+}
+
} // namespace WebCore
#endif // ENABLE(SERVICE_WORKER)
Modified: trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.h (224541 => 224542)
--- trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.h 2017-11-07 20:02:48 UTC (rev 224541)
+++ trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.h 2017-11-07 20:11:58 UTC (rev 224542)
@@ -56,6 +56,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();
uint64_t serverConnectionIdentifier() const { return m_serverConnectionIdentifier; }
const ServiceWorkerContextData& contextData() const { return m_data; }
Modified: trunk/Source/WebCore/workers/service/server/SWClientConnection.cpp (224541 => 224542)
--- trunk/Source/WebCore/workers/service/server/SWClientConnection.cpp 2017-11-07 20:02:48 UTC (rev 224541)
+++ trunk/Source/WebCore/workers/service/server/SWClientConnection.cpp 2017-11-07 20:11:58 UTC (rev 224542)
@@ -138,24 +138,36 @@
container->dispatchEvent(messageEvent);
}
-void SWClientConnection::updateRegistrationState(const ServiceWorkerRegistrationKey& key, ServiceWorkerRegistrationState state, std::optional<ServiceWorkerIdentifier> serviceWorkerIdentifier)
+void SWClientConnection::forEachContainer(const WTF::Function<void(ServiceWorkerContainer&)>& apply)
{
// FIXME: We should iterate over all service worker clients, not only documents.
for (auto& document : Document::allDocuments()) {
if (auto* container = document->serviceWorkerContainer())
- container->updateRegistration(key, state, serviceWorkerIdentifier);
+ apply(*container);
}
}
+void SWClientConnection::updateRegistrationState(const ServiceWorkerRegistrationKey& key, ServiceWorkerRegistrationState state, std::optional<ServiceWorkerIdentifier> serviceWorkerIdentifier)
+{
+ forEachContainer([&](ServiceWorkerContainer& container) {
+ container.updateRegistration(key, state, serviceWorkerIdentifier);
+ });
+}
+
void SWClientConnection::fireUpdateFoundEvent(const ServiceWorkerRegistrationKey& key)
{
- // FIXME: We should iterate over all service worker clients, not only documents.
- for (auto& document : Document::allDocuments()) {
- if (auto* container = document->serviceWorkerContainer())
- container->fireUpdateFoundEvent(key);
- }
+ forEachContainer([&](ServiceWorkerContainer& container) {
+ container.fireUpdateFoundEvent(key);
+ });
}
+void SWClientConnection::firePostInstallEvents(const ServiceWorkerRegistrationKey& key)
+{
+ forEachContainer([&](ServiceWorkerContainer& container) {
+ container.firePostInstallEvents(key);
+ });
+}
+
} // namespace WebCore
#endif // ENABLE(SERVICE_WORKER)
Modified: trunk/Source/WebCore/workers/service/server/SWClientConnection.h (224541 => 224542)
--- trunk/Source/WebCore/workers/service/server/SWClientConnection.h 2017-11-07 20:02:48 UTC (rev 224541)
+++ trunk/Source/WebCore/workers/service/server/SWClientConnection.h 2017-11-07 20:11:58 UTC (rev 224542)
@@ -36,6 +36,7 @@
class ResourceError;
class SecurityOrigin;
class SerializedScriptValue;
+class ServiceWorkerContainer;
class ServiceWorkerRegistration;
class SharedBuffer;
enum class ServiceWorkerRegistrationState;
@@ -68,6 +69,7 @@
WEBCORE_EXPORT void postMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, Ref<SerializedScriptValue>&& message, ServiceWorkerIdentifier source, const String& sourceOrigin);
WEBCORE_EXPORT void updateRegistrationState(const ServiceWorkerRegistrationKey&, ServiceWorkerRegistrationState, std::optional<ServiceWorkerIdentifier>);
WEBCORE_EXPORT void fireUpdateFoundEvent(const ServiceWorkerRegistrationKey&);
+ WEBCORE_EXPORT void firePostInstallEvents(const ServiceWorkerRegistrationKey&);
private:
virtual void scheduleJobInServer(const ServiceWorkerJobData&) = 0;
@@ -74,6 +76,7 @@
virtual void finishFetchingScriptInServer(const ServiceWorkerFetchResult&) = 0;
virtual void addServiceWorkerRegistrationInServer(const ServiceWorkerRegistrationKey&, uint64_t registrationIdentifier) = 0;
virtual void removeServiceWorkerRegistrationInServer(const ServiceWorkerRegistrationKey&, uint64_t registrationIdentifier) = 0;
+ void forEachContainer(const WTF::Function<void(ServiceWorkerContainer&)>& apply);
HashMap<uint64_t, RefPtr<ServiceWorkerJob>> m_scheduledJobs;
};
Modified: trunk/Source/WebCore/workers/service/server/SWServer.cpp (224541 => 224542)
--- trunk/Source/WebCore/workers/service/server/SWServer.cpp 2017-11-07 20:02:48 UTC (rev 224541)
+++ trunk/Source/WebCore/workers/service/server/SWServer.cpp 2017-11-07 20:11:58 UTC (rev 224542)
@@ -112,6 +112,11 @@
m_server.scriptFetchFinished(*this, result);
}
+void SWServer::Connection::didFinishInstall(const ServiceWorkerRegistrationKey& key, ServiceWorkerIdentifier serviceWorkerIdentifier, bool wasSuccessful)
+{
+ m_server.didFinishInstall(*this, key, serviceWorkerIdentifier, wasSuccessful);
+}
+
void SWServer::Connection::addServiceWorkerRegistrationInServer(const ServiceWorkerRegistrationKey& key, uint64_t clientRegistrationIdentifier)
{
m_server.addClientServiceWorkerRegistration(*this, key, clientRegistrationIdentifier);
@@ -224,6 +229,14 @@
jobQueue->scriptContextStarted(connection, identifier);
}
+void SWServer::didFinishInstall(Connection& connection, const ServiceWorkerRegistrationKey& registrationKey, ServiceWorkerIdentifier serviceWorkerIdentifier, bool wasSuccessful)
+{
+ ASSERT(m_connections.contains(connection.identifier()));
+
+ if (auto* jobQueue = m_jobQueues.get(registrationKey))
+ jobQueue->didFinishInstall(connection, serviceWorkerIdentifier, wasSuccessful);
+}
+
void SWServer::addClientServiceWorkerRegistration(Connection& connection, const ServiceWorkerRegistrationKey& key, uint64_t registrationIdentifier)
{
auto* registration = m_registrations.get(key);
@@ -258,6 +271,11 @@
return result.iterator->value.get();
}
+void SWServer::fireInstallEvent(Connection& connection, ServiceWorkerIdentifier serviceWorkerIdentifier)
+{
+ connection.fireInstallEvent(serviceWorkerIdentifier);
+}
+
void SWServer::taskThreadEntryPoint()
{
ASSERT(!isMainThread());
Modified: trunk/Source/WebCore/workers/service/server/SWServer.h (224541 => 224542)
--- trunk/Source/WebCore/workers/service/server/SWServer.h 2017-11-07 20:02:48 UTC (rev 224541)
+++ trunk/Source/WebCore/workers/service/server/SWServer.h 2017-11-07 20:11:58 UTC (rev 224542)
@@ -60,11 +60,13 @@
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);
const SWServerRegistration* doRegistrationMatching(const SecurityOriginData& topOrigin, const URL& clientURL) const { return m_server.doRegistrationMatching(topOrigin, clientURL); }
// Messages to the client WebProcess
virtual void updateRegistrationStateInClient(const ServiceWorkerRegistrationKey&, ServiceWorkerRegistrationState, std::optional<ServiceWorkerIdentifier>) = 0;
virtual void fireUpdateFoundEvent(const ServiceWorkerRegistrationKey&) = 0;
+ virtual void firePostInstallEvents(const ServiceWorkerRegistrationKey&) = 0;
protected:
WEBCORE_EXPORT Connection(SWServer&, uint64_t identifier);
@@ -84,6 +86,7 @@
// Messages to the SW host WebProcess
virtual void updateServiceWorkerContext(const ServiceWorkerContextData&) = 0;
+ virtual void fireInstallEvent(ServiceWorkerIdentifier) = 0;
SWServer& m_server;
};
@@ -107,6 +110,7 @@
void postTaskReply(CrossThreadTask&&);
Ref<SWServerWorker> updateWorker(Connection&, const ServiceWorkerRegistrationKey&, const URL&, const String& script, WorkerType);
+ void fireInstallEvent(Connection&, ServiceWorkerIdentifier);
Connection* getConnection(uint64_t identifier) { return m_connections.get(identifier); }
@@ -120,6 +124,7 @@
void scriptFetchFinished(Connection&, const ServiceWorkerFetchResult&);
void scriptContextFailedToStart(Connection&, const ServiceWorkerRegistrationKey&, ServiceWorkerIdentifier, const String& message);
void scriptContextStarted(Connection&, const ServiceWorkerRegistrationKey&, ServiceWorkerIdentifier);
+ void didFinishInstall(Connection&, const ServiceWorkerRegistrationKey&, ServiceWorkerIdentifier, bool wasSuccessful);
void addClientServiceWorkerRegistration(Connection&, const ServiceWorkerRegistrationKey&, uint64_t registrationIdentifier);
void removeClientServiceWorkerRegistration(Connection&, const ServiceWorkerRegistrationKey&, uint64_t registrationIdentifier);
Modified: trunk/Source/WebCore/workers/service/server/SWServerJobQueue.cpp (224541 => 224542)
--- trunk/Source/WebCore/workers/service/server/SWServerJobQueue.cpp 2017-11-07 20:02:48 UTC (rev 224541)
+++ trunk/Source/WebCore/workers/service/server/SWServerJobQueue.cpp 2017-11-07 20:11:58 UTC (rev 224542)
@@ -78,7 +78,7 @@
// text, then:
if (newestWorker && equalIgnoringFragmentIdentifier(newestWorker->scriptURL(), job.scriptURL) && result.script == newestWorker->script()) {
// FIXME: if script is a classic script, and script's module record's [[ECMAScriptCode]] is a byte-for-byte
- // match with newestWorker’s script resource's module record's [[ECMAScriptCode]] otherwise.
+ // match with newestWorker's script resource's module record's [[ECMAScriptCode]] otherwise.
// Invoke Resolve Job Promise with job and registration.
m_server.resolveRegistrationJob(job, registration->data());
@@ -98,7 +98,7 @@
ASSERT(registration);
// FIXME: Install has failed. Run the install failed substeps
- // Run the Update Worker State algorithm passing registration’s installing worker and redundant as the arguments.
+ // Run the Update Worker State algorithm passing registration's installing worker and redundant as the arguments.
// Run the Update Registration State algorithm passing registration, "installing" and null as the arguments.
// If newestWorker is null, invoke Clear Registration algorithm passing registration as its argument.
@@ -109,17 +109,17 @@
UNUSED_PARAM(message);
}
-void SWServerJobQueue::scriptContextStarted(SWServer::Connection&, ServiceWorkerIdentifier identifier)
+void SWServerJobQueue::scriptContextStarted(SWServer::Connection& connection, ServiceWorkerIdentifier identifier)
{
auto* registration = m_server.getRegistration(m_registrationKey);
ASSERT(registration);
registration->setActiveServiceWorkerIdentifier(identifier);
- install(*registration);
+ install(*registration, connection, identifier);
}
// https://w3c.github.io/ServiceWorker/#install
-void SWServerJobQueue::install(SWServerRegistration& registration)
+void SWServerJobQueue::install(SWServerRegistration& registration, SWServer::Connection& connection, ServiceWorkerIdentifier serviceWorkerIdentifier)
{
// Invoke Resolve Job Promise with job and registration.
m_server.resolveRegistrationJob(firstJob(), registration.data());
@@ -129,6 +129,31 @@
// all the service workers whose containing service worker registration is registration.
registration.fireUpdateFoundEvent(firstJob().connectionIdentifier());
+ // Queue a task to fire the InstallEvent.
+ m_server.fireInstallEvent(connection, serviceWorkerIdentifier);
+}
+
+// https://w3c.github.io/ServiceWorker/#install
+void SWServerJobQueue::didFinishInstall(SWServer::Connection&, ServiceWorkerIdentifier, bool wasSuccessful)
+{
+ auto* registration = m_server.getRegistration(m_registrationKey);
+ ASSERT(registration);
+
+ if (!wasSuccessful) {
+ // FIXME: Run the Update Worker State algorithm passing registration's installing worker and redundant as the arguments.
+ // FIXME: Run the Update Registration State algorithm passing registration, "installing" and null as the arguments.
+
+ // If newestWorker is null, invoke Clear Registration algorithm passing registration as its argument.
+ if (!registration->getNewestWorker())
+ clearRegistration(*registration);
+ // Invoke Finish Job with job and abort these steps.
+ finishCurrentJob();
+ return;
+ }
+
+ // FIXME: Implement real post 'install' event steps of the Install algorithm (steps 14+).
+ registration->firePostInstallEvents(firstJob().connectionIdentifier());
+
finishCurrentJob();
}
@@ -166,11 +191,11 @@
if (!shouldTreatAsPotentiallyTrustworthy(job.scriptURL))
return rejectCurrentJob(ExceptionData { SecurityError, ASCIILiteral("Script URL is not potentially trustworthy") });
- // If the origin of job’s script url is not job’s referrer's origin, then:
+ // If the origin of job's script url is not job's referrer's origin, then:
if (!protocolHostAndPortAreEqual(job.scriptURL, job.clientCreationURL))
return rejectCurrentJob(ExceptionData { SecurityError, ASCIILiteral("Script origin does not match the registering client's origin") });
- // If the origin of job’s scope url is not job’s referrer's origin, then:
+ // If the origin of job's scope url is not job's referrer's origin, then:
if (!protocolHostAndPortAreEqual(job.scopeURL, job.clientCreationURL))
return rejectCurrentJob(ExceptionData { SecurityError, ASCIILiteral("Scope origin does not match the registering client's origin") });
@@ -194,11 +219,11 @@
// https://w3c.github.io/ServiceWorker/#unregister-algorithm
void SWServerJobQueue::runUnregisterJob(const ServiceWorkerJobData& job)
{
- // If the origin of job’s scope url is not job's client's origin, then:
+ // If the origin of job's scope url is not job's client's origin, then:
if (!protocolHostAndPortAreEqual(job.scopeURL, job.clientCreationURL))
return rejectCurrentJob(ExceptionData { SecurityError, ASCIILiteral("Origin of scope URL does not match the client's origin") });
- // Let registration be the result of running "Get Registration" algorithm passing job’s scope url as the argument.
+ // Let registration be the result of running "Get Registration" algorithm passing job's scope url as the argument.
auto* registration = m_server.getRegistration(m_registrationKey);
// If registration is null, then:
@@ -209,7 +234,7 @@
return;
}
- // Set registration’s uninstalling flag.
+ // Set registration's uninstalling flag.
registration->setIsUninstalling(true);
// Invoke Resolve Job Promise with job and true.
@@ -240,10 +265,10 @@
// https://w3c.github.io/ServiceWorker/#update-algorithm
void SWServerJobQueue::runUpdateJob(const ServiceWorkerJobData& job)
{
- // Let registration be the result of running the Get Registration algorithm passing job’s scope url as the argument.
+ // Let registration be the result of running the Get Registration algorithm passing job's scope url as the argument.
auto* registration = m_server.getRegistration(m_registrationKey);
- // If registration is null (in our parlance "empty") or registration’s uninstalling flag is set, then:
+ // If registration is null (in our parlance "empty") or registration's uninstalling flag is set, then:
if (!registration)
return rejectCurrentJob(ExceptionData { TypeError, ASCIILiteral("Cannot update a null/nonexistent service worker registration") });
if (registration->isUninstalling())
@@ -252,7 +277,7 @@
// Let newestWorker be the result of running Get Newest Worker algorithm passing registration as the argument.
auto* newestWorker = registration->getNewestWorker();
- // If job's type is update, and newestWorker's script url does not equal job’s script url with the exclude fragments flag set, then:
+ // If job's type is update, and newestWorker's script url does not equal job's script url with the exclude fragments flag set, then:
if (job.type == ServiceWorkerJobType::Update && newestWorker && !equalIgnoringFragmentIdentifier(job.scriptURL, newestWorker->scriptURL()))
return rejectCurrentJob(ExceptionData { TypeError, ASCIILiteral("Cannot update a service worker with a requested script URL whose newest worker has a different script URL") });
Modified: trunk/Source/WebCore/workers/service/server/SWServerJobQueue.h (224541 => 224542)
--- trunk/Source/WebCore/workers/service/server/SWServerJobQueue.h 2017-11-07 20:02:48 UTC (rev 224541)
+++ trunk/Source/WebCore/workers/service/server/SWServerJobQueue.h 2017-11-07 20:11:58 UTC (rev 224542)
@@ -50,6 +50,7 @@
void scriptFetchFinished(SWServer::Connection&, const ServiceWorkerFetchResult&);
void scriptContextFailedToStart(SWServer::Connection&, ServiceWorkerIdentifier, const String& message);
void scriptContextStarted(SWServer::Connection&, ServiceWorkerIdentifier);
+ void didFinishInstall(SWServer::Connection&, ServiceWorkerIdentifier, bool wasSuccessful);
private:
void jobTimerFired();
@@ -63,7 +64,7 @@
void tryClearRegistration(SWServerRegistration&);
void clearRegistration(SWServerRegistration&);
- void install(SWServerRegistration&);
+ void install(SWServerRegistration&, SWServer::Connection&, ServiceWorkerIdentifier);
Deque<ServiceWorkerJobData> m_jobQueue;
Modified: trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp (224541 => 224542)
--- trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp 2017-11-07 20:02:48 UTC (rev 224541)
+++ trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp 2017-11-07 20:11:58 UTC (rev 224542)
@@ -99,6 +99,20 @@
}
}
+// FIXME: This will do away once we correctly update the registration state after install.
+void SWServerRegistration::firePostInstallEvents(uint64_t connectionIdentifier)
+{
+ // No matter what, we send the event to the connection that scheduled the job. The client registration
+ // may not have gotten a chance to register itself yet.
+ if (auto* connection = m_server.getConnection(connectionIdentifier))
+ connection->firePostInstallEvents(m_registrationKey);
+
+ for (auto& connectionIdentifierWithClients : m_clientRegistrationsByConnection.keys()) {
+ if (auto* connection = m_server.getConnection(connectionIdentifierWithClients))
+ connection->firePostInstallEvents(m_registrationKey);
+ }
+}
+
ServiceWorkerRegistrationData SWServerRegistration::data() const
{
return { m_registrationKey, identifier(), m_activeServiceWorkerIdentifier, m_scopeURL, m_scriptURL, m_updateViaCache };
Modified: trunk/Source/WebCore/workers/service/server/SWServerRegistration.h (224541 => 224542)
--- trunk/Source/WebCore/workers/service/server/SWServerRegistration.h 2017-11-07 20:02:48 UTC (rev 224541)
+++ trunk/Source/WebCore/workers/service/server/SWServerRegistration.h 2017-11-07 20:11:58 UTC (rev 224542)
@@ -59,6 +59,7 @@
void updateRegistrationState(ServiceWorkerRegistrationState, SWServerWorker*);
void fireUpdateFoundEvent(uint64_t connectionIdentifier);
+ void firePostInstallEvents(uint64_t connectionIdentifier);
void addClientServiceWorkerRegistration(uint64_t connectionIdentifier, uint64_t clientRegistrationIdentifier);
void removeClientServiceWorkerRegistration(uint64_t connectionIdentifier, uint64_t clientRegistrationIdentifier);
Modified: trunk/Source/WebKit/ChangeLog (224541 => 224542)
--- trunk/Source/WebKit/ChangeLog 2017-11-07 20:02:48 UTC (rev 224541)
+++ trunk/Source/WebKit/ChangeLog 2017-11-07 20:11:58 UTC (rev 224542)
@@ -1,3 +1,25 @@
+2017-11-07 Chris Dumez <[email protected]>
+
+ [Service Workers] Add support for "install" event
+ https://bugs.webkit.org/show_bug.cgi?id=179338
+
+ Reviewed by Youenn Fablet.
+
+ * StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
+ (WebKit::WebSWServerConnection::firePostInstallEvents):
+ (WebKit::WebSWServerConnection::fireInstallEvent):
+ * StorageProcess/ServiceWorker/WebSWServerConnection.h:
+ * StorageProcess/StorageProcess.cpp:
+ (WebKit::StorageProcess::didFinishServiceWorkerInstall):
+ * StorageProcess/StorageProcess.h:
+ * StorageProcess/StorageProcess.messages.in:
+ * WebProcess/Storage/WebSWClientConnection.messages.in:
+ * WebProcess/Storage/WebSWContextManagerConnection.cpp:
+ (WebKit::WebSWContextManagerConnection::fireInstallEvent):
+ (WebKit::WebSWContextManagerConnection::didFinishInstall):
+ * WebProcess/Storage/WebSWContextManagerConnection.h:
+ * WebProcess/Storage/WebSWContextManagerConnection.messages.in:
+
2017-11-07 Youenn Fablet <[email protected]>
Support the case of fetch events that are not responded
Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp (224541 => 224542)
--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp 2017-11-07 20:02:48 UTC (rev 224541)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp 2017-11-07 20:11:58 UTC (rev 224542)
@@ -106,6 +106,11 @@
send(Messages::WebSWClientConnection::FireUpdateFoundEvent(key));
}
+void WebSWServerConnection::firePostInstallEvents(const ServiceWorkerRegistrationKey& key)
+{
+ send(Messages::WebSWClientConnection::FirePostInstallEvents(key));
+}
+
void WebSWServerConnection::updateServiceWorkerContext(const ServiceWorkerContextData& data)
{
if (sendToContextProcess(Messages::WebSWContextManagerConnection::UpdateServiceWorker(identifier(), data)))
@@ -114,6 +119,11 @@
m_pendingContextDatas.append(data);
}
+void WebSWServerConnection::fireInstallEvent(ServiceWorkerIdentifier serviceWorkerIdentifier)
+{
+ sendToContextProcess(Messages::WebSWContextManagerConnection::FireInstallEvent(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 (224541 => 224542)
--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h 2017-11-07 20:02:48 UTC (rev 224541)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h 2017-11-07 20:11:58 UTC (rev 224542)
@@ -67,6 +67,7 @@
void startScriptFetchInClient(uint64_t jobIdentifier) final;
void updateRegistrationStateInClient(const WebCore::ServiceWorkerRegistrationKey&, WebCore::ServiceWorkerRegistrationState, std::optional<WebCore::ServiceWorkerIdentifier>) final;
void fireUpdateFoundEvent(const WebCore::ServiceWorkerRegistrationKey&) final;
+ void firePostInstallEvents(const WebCore::ServiceWorkerRegistrationKey&) final;
void startFetch(uint64_t fetchIdentifier, std::optional<WebCore::ServiceWorkerIdentifier>, const WebCore::ResourceRequest&, const WebCore::FetchOptions&);
@@ -76,6 +77,7 @@
// Messages to the SW context WebProcess
void updateServiceWorkerContext(const WebCore::ServiceWorkerContextData&) final;
+ void fireInstallEvent(WebCore::ServiceWorkerIdentifier) final;
IPC::Connection* messageSenderConnection() final { return m_contentConnection.ptr(); }
uint64_t messageSenderDestinationID() final { return identifier(); }
Modified: trunk/Source/WebKit/StorageProcess/StorageProcess.cpp (224541 => 224542)
--- trunk/Source/WebKit/StorageProcess/StorageProcess.cpp 2017-11-07 20:02:48 UTC (rev 224541)
+++ trunk/Source/WebKit/StorageProcess/StorageProcess.cpp 2017-11-07 20:11:58 UTC (rev 224542)
@@ -453,6 +453,12 @@
connection->postMessageToServiceWorkerClient(destinationIdentifier.scriptExecutionContextIdentifier, message, sourceIdentifier, sourceOrigin);
}
+void StorageProcess::didFinishServiceWorkerInstall(uint64_t serverConnectionIdentifier, const ServiceWorkerRegistrationKey& registrationKey, ServiceWorkerIdentifier serviceWorkerIdentifier, bool wasSuccessful)
+{
+ if (auto* connection = m_swServerConnections.get(serverConnectionIdentifier))
+ connection->didFinishInstall(registrationKey, serviceWorkerIdentifier, wasSuccessful);
+}
+
void StorageProcess::registerSWServerConnection(WebSWServerConnection& connection)
{
ASSERT(!m_swServerConnections.contains(connection.identifier()));
Modified: trunk/Source/WebKit/StorageProcess/StorageProcess.h (224541 => 224542)
--- trunk/Source/WebKit/StorageProcess/StorageProcess.h 2017-11-07 20:02:48 UTC (rev 224541)
+++ trunk/Source/WebKit/StorageProcess/StorageProcess.h 2017-11-07 20:11:58 UTC (rev 224542)
@@ -128,6 +128,7 @@
void didFailFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier);
void didNotHandleFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier);
+ void didFinishServiceWorkerInstall(uint64_t serverConnectionIdentifier, const WebCore::ServiceWorkerRegistrationKey&, WebCore::ServiceWorkerIdentifier, bool wasSuccessful);
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 (224541 => 224542)
--- trunk/Source/WebKit/StorageProcess/StorageProcess.messages.in 2017-11-07 20:02:48 UTC (rev 224541)
+++ trunk/Source/WebKit/StorageProcess/StorageProcess.messages.in 2017-11-07 20:11:58 UTC (rev 224542)
@@ -40,6 +40,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);
DidNotHandleFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier)
DidFailFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier)
Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.messages.in (224541 => 224542)
--- trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.messages.in 2017-11-07 20:02:48 UTC (rev 224541)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.messages.in 2017-11-07 20:11:58 UTC (rev 224542)
@@ -30,6 +30,7 @@
StartScriptFetchForServer(uint64_t jobIdentifier)
UpdateRegistrationState(WebCore::ServiceWorkerRegistrationKey key, enum WebCore::ServiceWorkerRegistrationState state, std::optional<WebCore::ServiceWorkerIdentifier> serviceWorkerIdentifier)
FireUpdateFoundEvent(WebCore::ServiceWorkerRegistrationKey key)
+ FirePostInstallEvents(WebCore::ServiceWorkerRegistrationKey key)
SetSWOriginTableSharedMemory(WebKit::SharedMemory::Handle handle)
PostMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, IPC::DataReference message, WebCore::ServiceWorkerIdentifier sourceServiceWorkerIdentifier, String sourceOrigin)
Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp (224541 => 224542)
--- trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp 2017-11-07 20:02:48 UTC (rev 224541)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp 2017-11-07 20:11:58 UTC (rev 224542)
@@ -149,11 +149,26 @@
SWContextManager::singleton().postMessageToServiceWorkerGlobalScope(destinationIdentifier, SerializedScriptValue::adopt(message.vector()), sourceIdentifier, sourceOrigin);
}
+void WebSWContextManagerConnection::fireInstallEvent(uint64_t serverConnectionIdentifier, ServiceWorkerIdentifier identifier)
+{
+ UNUSED_PARAM(serverConnectionIdentifier);
+ SWContextManager::singleton().fireInstallEvent(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);
}
+void WebSWContextManagerConnection::didFinishInstall(ServiceWorkerIdentifier serviceWorkerIdentifier, bool wasSuccessful)
+{
+ auto* threadProxy = SWContextManager::singleton().serviceWorkerThreadProxy(serviceWorkerIdentifier);
+ ASSERT(threadProxy);
+
+ auto& data = ""
+ m_connectionToStorageProcess->send(Messages::StorageProcess::DidFinishServiceWorkerInstall(threadProxy->thread().serverConnectionIdentifier(), data.registrationKey, serviceWorkerIdentifier, wasSuccessful), 0);
+}
+
} // namespace WebCore
#endif // ENABLE(SERVICE_WORKER)
Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h (224541 => 224542)
--- trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h 2017-11-07 20:02:48 UTC (rev 224541)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h 2017-11-07 20:11:58 UTC (rev 224542)
@@ -52,6 +52,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;
// IPC messages.
void serviceWorkerStartedWithMessage(WebCore::ServiceWorkerIdentifier, const String& exceptionMessage) final;
@@ -58,6 +59,7 @@
void updateServiceWorker(uint64_t serverConnectionIdentifier, const WebCore::ServiceWorkerContextData&);
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);
Ref<IPC::Connection> m_connectionToStorageProcess;
uint64_t m_pageID { 0 };
Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.messages.in (224541 => 224542)
--- trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.messages.in 2017-11-07 20:02:48 UTC (rev 224541)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.messages.in 2017-11-07 20:11:58 UTC (rev 224542)
@@ -26,6 +26,7 @@
UpdateServiceWorker(uint64_t serverConnectionIdentifier, struct WebCore::ServiceWorkerContextData contextData)
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)
}
#endif