Diff
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/windowclient-navigate.https-expected.txt (224589 => 224590)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/windowclient-navigate.https-expected.txt 2017-11-08 19:35:18 UTC (rev 224589)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/windowclient-navigate.https-expected.txt 2017-11-08 20:02:24 UTC (rev 224590)
@@ -1,7 +1,7 @@
FAIL normal promise_test: Unhandled rejection with value: object "NotSupportedError: Passing MessagePort objects to postMessage is not yet supported"
FAIL blank url promise_test: Unhandled rejection with value: object "NotSupportedError: Passing MessagePort objects to postMessage is not yet supported"
-FAIL in scope but not controlled test on installing worker promise_test: Unhandled rejection with value: object "NotSupportedError: Passing MessagePort objects to postMessage is not yet supported"
+FAIL in scope but not controlled test on installing worker promise_test: Unhandled rejection with value: object "InvalidStateError: Service Worker state is redundant"
FAIL in scope but not controlled test on active worker promise_test: Unhandled rejection with value: object "NotSupportedError: Passing MessagePort objects to postMessage is not yet supported"
FAIL out of scope promise_test: Unhandled rejection with value: object "NotSupportedError: Passing MessagePort objects to postMessage is not yet supported"
FAIL cross orgin url promise_test: Unhandled rejection with value: object "NotSupportedError: Passing MessagePort objects to postMessage is not yet supported"
Modified: trunk/Source/WebCore/ChangeLog (224589 => 224590)
--- trunk/Source/WebCore/ChangeLog 2017-11-08 19:35:18 UTC (rev 224589)
+++ trunk/Source/WebCore/ChangeLog 2017-11-08 20:02:24 UTC (rev 224590)
@@ -1,3 +1,21 @@
+2017-11-08 Chris Dumez <[email protected]>
+
+ [Service Workers] Make sure SWServerRegistration update functions always message back the connection that scheduled the job
+ https://bugs.webkit.org/show_bug.cgi?id=179428
+
+ Reviewed by Brady Eidson.
+
+ * workers/service/server/SWServerJobQueue.cpp:
+ (WebCore::SWServerJobQueue::install):
+ (WebCore::SWServerJobQueue::didFinishInstall):
+ * workers/service/server/SWServerRegistration.cpp:
+ (WebCore::SWServerRegistration::updateRegistrationState):
+ (WebCore::SWServerRegistration::updateWorkerState):
+ (WebCore::SWServerRegistration::fireUpdateFoundEvent):
+ (WebCore::SWServerRegistration::firePostInstallEvents):
+ (WebCore::SWServerRegistration::forEachConnection):
+ * workers/service/server/SWServerRegistration.h:
+
2017-11-08 Maciej Stachowiak <[email protected]>
iOS supports some text encodings supposedly due to lack of TEC that aren't supported by the TEC decoder on macOS
Modified: trunk/Source/WebCore/workers/service/server/SWServerJobQueue.cpp (224589 => 224590)
--- trunk/Source/WebCore/workers/service/server/SWServerJobQueue.cpp 2017-11-08 19:35:18 UTC (rev 224589)
+++ trunk/Source/WebCore/workers/service/server/SWServerJobQueue.cpp 2017-11-08 20:02:24 UTC (rev 224590)
@@ -115,16 +115,18 @@
auto* worker = m_server.workerByID(installingWorker);
RELEASE_ASSERT(worker);
- registration.updateRegistrationState(ServiceWorkerRegistrationState::Installing, worker);
- registration.updateWorkerState(*worker, ServiceWorkerState::Installing);
+ auto& job = firstJob();
+ registration.updateRegistrationState(job, ServiceWorkerRegistrationState::Installing, worker);
+ registration.updateWorkerState(job, *worker, ServiceWorkerState::Installing);
+
// Invoke Resolve Job Promise with job and registration.
- m_server.resolveRegistrationJob(firstJob(), registration.data());
+ m_server.resolveRegistrationJob(job, registration.data());
// Queue a task to fire an event named updatefound at all the ServiceWorkerRegistration objects
// for all the service worker clients whose creation URL matches registration's scope url and
// all the service workers whose containing service worker registration is registration.
- registration.fireUpdateFoundEvent(firstJob().connectionIdentifier());
+ registration.fireUpdateFoundEvent(job);
// Queue a task to fire the InstallEvent.
m_server.fireInstallEvent(connection, installingWorker);
@@ -136,14 +138,16 @@
auto* registration = m_server.getRegistration(m_registrationKey);
ASSERT(registration);
+ auto& job = firstJob();
+
if (!wasSuccessful) {
auto* worker = m_server.workerByID(identifier);
RELEASE_ASSERT(worker);
// Run the Update Worker State algorithm passing registration's installing worker and redundant as the arguments.
- registration->updateWorkerState(*worker, ServiceWorkerState::Redundant);
+ registration->updateWorkerState(job, *worker, ServiceWorkerState::Redundant);
// Run the Update Registration State algorithm passing registration, "installing" and null as the arguments.
- registration->updateRegistrationState(ServiceWorkerRegistrationState::Installing, nullptr);
+ registration->updateRegistrationState(job, ServiceWorkerRegistrationState::Installing, nullptr);
// If newestWorker is null, invoke Clear Registration algorithm passing registration as its argument.
if (!registration->getNewestWorker())
@@ -154,7 +158,7 @@
}
// FIXME: Implement real post 'install' event steps of the Install algorithm (steps 14+).
- registration->firePostInstallEvents(firstJob().connectionIdentifier());
+ registration->firePostInstallEvents(job);
finishCurrentJob();
}
Modified: trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp (224589 => 224590)
--- trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp 2017-11-08 19:35:18 UTC (rev 224589)
+++ trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp 2017-11-08 20:02:24 UTC (rev 224590)
@@ -59,7 +59,7 @@
return m_activeWorker.get();
}
-void SWServerRegistration::updateRegistrationState(ServiceWorkerRegistrationState state, SWServerWorker* worker)
+void SWServerRegistration::updateRegistrationState(const ServiceWorkerJobData& job, ServiceWorkerRegistrationState state, SWServerWorker* worker)
{
LOG(ServiceWorker, "(%p) Updating registration state to %i with worker %p", this, (int)state, worker);
@@ -79,54 +79,49 @@
if (worker)
serviceWorkerIdentifier = worker->identifier();
- for (auto& connectionIdentifierWithClients : m_clientRegistrationsByConnection.keys()) {
- if (auto* connection = m_server.getConnection(connectionIdentifierWithClients))
- connection->updateRegistrationStateInClient(m_registrationKey, state, serviceWorkerIdentifier);
- }
+ forEachConnection(job, [&](auto& connection) {
+ connection.updateRegistrationStateInClient(m_registrationKey, state, serviceWorkerIdentifier);
+ });
}
-void SWServerRegistration::updateWorkerState(SWServerWorker& worker, ServiceWorkerState state)
+void SWServerRegistration::updateWorkerState(const ServiceWorkerJobData& job, SWServerWorker& worker, ServiceWorkerState state)
{
LOG(ServiceWorker, "Updating worker %p state to %i (%p)", &worker, (int)state, this);
worker.setState(state);
- for (auto& connectionIdentifierWithClients : m_clientRegistrationsByConnection.keys()) {
- if (auto* connection = m_server.getConnection(connectionIdentifierWithClients))
- connection->updateWorkerStateInClient(worker.identifier(), state);
- }
+ forEachConnection(job, [&](auto& connection) {
+ connection.updateWorkerStateInClient(worker.identifier(), state);
+ });
}
-void SWServerRegistration::fireUpdateFoundEvent(uint64_t connectionIdentifier)
+void SWServerRegistration::fireUpdateFoundEvent(const ServiceWorkerJobData& job)
{
- // 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->fireUpdateFoundEvent(m_registrationKey);
-
- for (auto& connectionIdentifierWithClients : m_clientRegistrationsByConnection.keys()) {
- if (connectionIdentifierWithClients == connectionIdentifier)
- continue;
-
- if (auto* connection = m_server.getConnection(connectionIdentifierWithClients))
- connection->fireUpdateFoundEvent(m_registrationKey);
- }
+ forEachConnection(job, [&](auto& connection) {
+ connection.fireUpdateFoundEvent(m_registrationKey);
+ });
}
// FIXME: This will do away once we correctly update the registration state after install.
-void SWServerRegistration::firePostInstallEvents(uint64_t connectionIdentifier)
+void SWServerRegistration::firePostInstallEvents(const ServiceWorkerJobData& job)
{
+ forEachConnection(job, [&](auto& connection) {
+ connection.firePostInstallEvents(m_registrationKey);
+ });
+}
+
+void SWServerRegistration::forEachConnection(const ServiceWorkerJobData& job, const WTF::Function<void(SWServer::Connection&)>& apply)
+{
// 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);
+ if (!m_clientRegistrationsByConnection.contains(job.connectionIdentifier())) {
+ if (auto* connection = m_server.getConnection(job.connectionIdentifier()))
+ apply(*connection);
+ }
for (auto& connectionIdentifierWithClients : m_clientRegistrationsByConnection.keys()) {
- if (connectionIdentifierWithClients == connectionIdentifier)
- continue;
-
if (auto* connection = m_server.getConnection(connectionIdentifierWithClients))
- connection->firePostInstallEvents(m_registrationKey);
+ apply(*connection);
}
}
Modified: trunk/Source/WebCore/workers/service/server/SWServerRegistration.h (224589 => 224590)
--- trunk/Source/WebCore/workers/service/server/SWServerRegistration.h 2017-11-08 19:35:18 UTC (rev 224589)
+++ trunk/Source/WebCore/workers/service/server/SWServerRegistration.h 2017-11-08 20:02:24 UTC (rev 224590)
@@ -56,15 +56,17 @@
void setLastUpdateTime(double time) { m_lastUpdateTime = time; }
ServiceWorkerUpdateViaCache updateViaCache() const { return m_updateViaCache; }
- void updateRegistrationState(ServiceWorkerRegistrationState, SWServerWorker*);
- void updateWorkerState(SWServerWorker&, ServiceWorkerState);
- void fireUpdateFoundEvent(uint64_t connectionIdentifier);
- void firePostInstallEvents(uint64_t connectionIdentifier);
+ void updateRegistrationState(const ServiceWorkerJobData&, ServiceWorkerRegistrationState, SWServerWorker*);
+ void updateWorkerState(const ServiceWorkerJobData&, SWServerWorker&, ServiceWorkerState);
+ void fireUpdateFoundEvent(const ServiceWorkerJobData&);
+ void firePostInstallEvents(const ServiceWorkerJobData&);
void addClientServiceWorkerRegistration(uint64_t connectionIdentifier, uint64_t clientRegistrationIdentifier);
void removeClientServiceWorkerRegistration(uint64_t connectionIdentifier, uint64_t clientRegistrationIdentifier);
private:
+ void forEachConnection(const ServiceWorkerJobData&, const WTF::Function<void(SWServer::Connection&)>&);
+
ServiceWorkerRegistrationKey m_registrationKey;
ServiceWorkerUpdateViaCache m_updateViaCache;
URL m_scopeURL;