https://bugs.webkit.org/show_bug.cgi?id=178735
Reviewed by Brady Eidson.
Source/WebCore:
Add support for unregistering a service worker:
- https://w3c.github.io/ServiceWorker/#navigator-service-worker-unregister
Test: http/tests/workers/service/basic-unregister.https.html
* workers/service/ServiceWorkerContainer.cpp:
(WebCore::ServiceWorkerContainer::addRegistration):
(WebCore::ServiceWorkerContainer::removeRegistration):
(WebCore::ServiceWorkerContainer::jobResolvedWithUnregistrationResult):
* workers/service/ServiceWorkerContainer.h:
* workers/service/ServiceWorkerJob.cpp:
(WebCore::ServiceWorkerJob::resolvedWithUnregistrationResult):
* workers/service/ServiceWorkerJob.h:
* workers/service/ServiceWorkerJobClient.h:
* workers/service/ServiceWorkerJobData.h:
(WebCore::ServiceWorkerJobData::encode const):
(WebCore::ServiceWorkerJobData::decode):
* workers/service/ServiceWorkerJobType.h:
* workers/service/ServiceWorkerRegistration.cpp:
(WebCore::containerForScriptExecutionContext):
(WebCore::ServiceWorkerRegistration::unregister):
* workers/service/server/SWClientConnection.cpp:
(WebCore::SWClientConnection::registrationJobResolvedInServer):
(WebCore::SWClientConnection::unregistrationJobResolvedInServer):
* workers/service/server/SWClientConnection.h:
* workers/service/server/SWServer.cpp:
(WebCore::SWServer::resolveRegistationJob):
(WebCore::SWServer::resolveUnregistrationJob):
* workers/service/server/SWServer.h:
* workers/service/server/SWServerRegistration.cpp:
(WebCore::SWServerRegistration::scriptContextStarted):
(WebCore::SWServerRegistration::startNextJob):
(WebCore::SWServerRegistration::runUnregisterJob):
(WebCore::SWServerRegistration::resolveWithRegistrationOnMainThread):
(WebCore::SWServerRegistration::resolveWithUnregistrationResultOnMainThread):
(WebCore::SWServerRegistration::resolveCurrentRegistrationJob):
(WebCore::SWServerRegistration::resolveCurrentUnregistrationJob):
* workers/service/server/SWServerRegistration.h:
Source/WebKit:
Add support for unregistering a service worker:
- https://w3c.github.io/ServiceWorker/#navigator-service-worker-unregister
* StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
(WebKit::WebSWServerConnection::resolveRegistrationJobInClient):
(WebKit::WebSWServerConnection::resolveUnregistrationJobInClient):
* StorageProcess/ServiceWorker/WebSWServerConnection.h:
* WebProcess/Storage/WebSWClientConnection.messages.in:
LayoutTests:
Add layout test coverage.
* http/tests/workers/service/basic-unregister.https-expected.txt: Added.
* http/tests/workers/service/basic-unregister.https.html: Added.
* http/tests/workers/service/resources/basic-unregister.js: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223964
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2017-10-25 Chris Dumez <cdumez@apple.com>
+
+ Add support for unregistering a service worker
+ https://bugs.webkit.org/show_bug.cgi?id=178735
+
+ Reviewed by Brady Eidson.
+
+ Add layout test coverage.
+
+ * http/tests/workers/service/basic-unregister.https-expected.txt: Added.
+ * http/tests/workers/service/basic-unregister.https.html: Added.
+ * http/tests/workers/service/resources/basic-unregister.js: Added.
+
2017-10-25 Andy Estes <aestes@apple.com>
[Payment Request] Implement the "user aborts the payment request" algorithm
--- /dev/null
+PASS: There is initially no service worker registered for the origin
+PASS: registration scope is https://127.0.0.1:8443/workers/service/
+PASS: There is a service worker registered for the origin
+PASS: Unregistration was successful
+PASS: There is no service worker registered for the origin
+PASS: Unregistration failed as expected
+PASS: There is no service worker registered for the origin
+PASS: registration scope is https://127.0.0.1:8443/workers/service/
+PASS: There is a service worker registered for the origin
+
--- /dev/null
+<html>
+<head>
+<script src="resources/sw-test-pre.js"></script>
+</head>
+<body>
+
+<script src="resources/basic-unregister.js"></script>
+</body>
+</html>
--- /dev/null
+function done()
+{
+ finishSWTest();
+}
+
+async function test()
+{
+ try {
+ if (!internals.hasServiceWorkerRegisteredForOrigin(self.origin))
+ log("PASS: There is initially no service worker registered for the origin");
+ else
+ log("FAIL: There is initially a service worker registered for the origin");
+
+ let registration = await navigator.serviceWorker.register("resources/basic-fetch-worker.js", { });
+ if (registration.scope === "https://127.0.0.1:8443/workers/service/")
+ log("PASS: registration scope is " + registration.scope);
+ else
+ log("FAIL: registration scope is " + registration.scope);
+
+ if (internals.hasServiceWorkerRegisteredForOrigin(self.origin))
+ log("PASS: There is a service worker registered for the origin");
+ else
+ log("FAIL: There is no service worker registered for the origin");
+
+ let unregistrationResult = await registration.unregister();
+ if (unregistrationResult)
+ log("PASS: Unregistration was successful");
+ else
+ log("FAIL: Unregistration failed");
+
+ if (!internals.hasServiceWorkerRegisteredForOrigin(self.origin))
+ log("PASS: There is no service worker registered for the origin");
+ else
+ log("FAIL: There is a service worker registered for the origin");
+
+ unregistrationResult = await registration.unregister();
+ if (!unregistrationResult)
+ log("PASS: Unregistration failed as expected");
+ else
+ log("FAIL: Unregistration succeeded unexpectedly");
+
+ if (!internals.hasServiceWorkerRegisteredForOrigin(self.origin))
+ log("PASS: There is no service worker registered for the origin");
+ else
+ log("FAIL: There is a service worker registered for the origin");
+
+ registration = await navigator.serviceWorker.register("resources/basic-fetch-worker.js", { });
+ if (registration.scope === "https://127.0.0.1:8443/workers/service/")
+ log("PASS: registration scope is " + registration.scope);
+ else
+ log("FAIL: registration scope is " + registration.scope);
+
+ if (internals.hasServiceWorkerRegisteredForOrigin(self.origin))
+ log("PASS: There is a service worker registered for the origin");
+ else
+ log("FAIL: There is no service worker registered for the origin");
+ } catch(e) {
+ console.log("Got exception: " + e);
+ }
+ finishSWTest();
+}
+
+test();
+2017-10-25 Chris Dumez <cdumez@apple.com>
+
+ Add support for unregistering a service worker
+ https://bugs.webkit.org/show_bug.cgi?id=178735
+
+ Reviewed by Brady Eidson.
+
+ Add support for unregistering a service worker:
+ - https://w3c.github.io/ServiceWorker/#navigator-service-worker-unregister
+
+ Test: http/tests/workers/service/basic-unregister.https.html
+
+ * workers/service/ServiceWorkerContainer.cpp:
+ (WebCore::ServiceWorkerContainer::addRegistration):
+ (WebCore::ServiceWorkerContainer::removeRegistration):
+ (WebCore::ServiceWorkerContainer::jobResolvedWithUnregistrationResult):
+ * workers/service/ServiceWorkerContainer.h:
+ * workers/service/ServiceWorkerJob.cpp:
+ (WebCore::ServiceWorkerJob::resolvedWithUnregistrationResult):
+ * workers/service/ServiceWorkerJob.h:
+ * workers/service/ServiceWorkerJobClient.h:
+ * workers/service/ServiceWorkerJobData.h:
+ (WebCore::ServiceWorkerJobData::encode const):
+ (WebCore::ServiceWorkerJobData::decode):
+ * workers/service/ServiceWorkerJobType.h:
+ * workers/service/ServiceWorkerRegistration.cpp:
+ (WebCore::containerForScriptExecutionContext):
+ (WebCore::ServiceWorkerRegistration::unregister):
+ * workers/service/server/SWClientConnection.cpp:
+ (WebCore::SWClientConnection::registrationJobResolvedInServer):
+ (WebCore::SWClientConnection::unregistrationJobResolvedInServer):
+ * workers/service/server/SWClientConnection.h:
+ * workers/service/server/SWServer.cpp:
+ (WebCore::SWServer::resolveRegistationJob):
+ (WebCore::SWServer::resolveUnregistrationJob):
+ * workers/service/server/SWServer.h:
+ * workers/service/server/SWServerRegistration.cpp:
+ (WebCore::SWServerRegistration::scriptContextStarted):
+ (WebCore::SWServerRegistration::startNextJob):
+ (WebCore::SWServerRegistration::runUnregisterJob):
+ (WebCore::SWServerRegistration::resolveWithRegistrationOnMainThread):
+ (WebCore::SWServerRegistration::resolveWithUnregistrationResultOnMainThread):
+ (WebCore::SWServerRegistration::resolveCurrentRegistrationJob):
+ (WebCore::SWServerRegistration::resolveCurrentUnregistrationJob):
+ * workers/service/server/SWServerRegistration.h:
+
2017-10-25 Simon Fraser <simon.fraser@apple.com>
MediaSessionManager* needs to catch Obj-C exceptions
auto* context = scriptExecutionContext();
if (!context || !context->sessionID().isValid()) {
ASSERT_NOT_REACHED();
+ promise->reject(Exception(InvalidStateError));
return;
}
- if (!m_swConnection)
- m_swConnection = &ServiceWorkerProvider::singleton().serviceWorkerConnectionForSession(context->sessionID());
-
if (relativeScriptURL.isEmpty()) {
promise->reject(Exception { TypeError, ASCIILiteral("serviceWorker.register() cannot be called with an empty script URL") });
return;
}
+ if (!m_swConnection)
+ m_swConnection = &ServiceWorkerProvider::singleton().serviceWorkerConnectionForSession(scriptExecutionContext()->sessionID());
+
ServiceWorkerJobData jobData(m_swConnection->identifier());
jobData.scriptURL = context->completeURL(relativeScriptURL);
scheduleJob(ServiceWorkerJob::create(*this, WTFMove(promise), WTFMove(jobData)));
}
+void ServiceWorkerContainer::removeRegistration(const URL& scopeURL, Ref<DeferredPromise>&& promise)
+{
+ auto* context = scriptExecutionContext();
+ if (!context || !context->sessionID().isValid()) {
+ ASSERT_NOT_REACHED();
+ promise->reject(Exception(InvalidStateError));
+ return;
+ }
+
+ if (!m_swConnection) {
+ ASSERT_NOT_REACHED();
+ promise->reject(Exception(InvalidStateError));
+ return;
+ }
+
+ ServiceWorkerJobData jobData(m_swConnection->identifier());
+ jobData.clientCreationURL = context->url();
+ jobData.topOrigin = SecurityOriginData::fromSecurityOrigin(context->topOrigin());
+ jobData.type = ServiceWorkerJobType::Unregister;
+ jobData.scopeURL = scopeURL;
+
+ scheduleJob(ServiceWorkerJob::create(*this, WTFMove(promise), WTFMove(jobData)));
+}
+
void ServiceWorkerContainer::scheduleJob(Ref<ServiceWorkerJob>&& job)
{
ASSERT(m_swConnection);
job.promise().resolve<IDLInterface<ServiceWorkerRegistration>>(registration.get());
}
+void ServiceWorkerContainer::jobResolvedWithUnregistrationResult(ServiceWorkerJob& job, bool unregistrationResult)
+{
+ ScopeGuard guard([this, &job] {
+ jobDidFinish(job);
+ });
+
+ auto* context = scriptExecutionContext();
+ if (!context) {
+ LOG_ERROR("ServiceWorkerContainer::jobResolvedWithUnregistrationResult called but the containers ScriptExecutionContext is gone");
+ return;
+ }
+
+ // FIXME: Implement proper selection of service workers.
+ if (unregistrationResult)
+ context->setSelectedServiceWorkerIdentifier(0);
+
+ job.promise().resolve<IDLBoolean>(unregistrationResult);
+}
+
void ServiceWorkerContainer::startScriptFetchForJob(ServiceWorkerJob& job)
{
LOG(ServiceWorker, "SeviceWorkerContainer %p starting script fetch for job %" PRIu64, this, job.data().identifier());
ReadyPromise& ready() { return m_readyPromise; }
void addRegistration(const String& scriptURL, const RegistrationOptions&, Ref<DeferredPromise>&&);
+ void removeRegistration(const URL& scopeURL, Ref<DeferredPromise>&&);
void getRegistration(const String& url, Ref<DeferredPromise>&&);
void getRegistrations(Ref<DeferredPromise>&&);
void jobFailedWithException(ServiceWorkerJob&, const Exception&) final;
void jobResolvedWithRegistration(ServiceWorkerJob&, ServiceWorkerRegistrationData&&) final;
+ void jobResolvedWithUnregistrationResult(ServiceWorkerJob&, bool unregistrationResult) final;
void startScriptFetchForJob(ServiceWorkerJob&) final;
void jobFinishedLoadingScript(ServiceWorkerJob&, const String&) final;
void jobFailedLoadingScript(ServiceWorkerJob&, const ResourceError&) final;
m_client->jobResolvedWithRegistration(*this, WTFMove(data));
}
+void ServiceWorkerJob::resolvedWithUnregistrationResult(bool unregistrationResult)
+{
+ ASSERT(currentThread() == m_creationThread);
+ ASSERT(!m_completed);
+
+ m_completed = true;
+ m_client->jobResolvedWithUnregistrationResult(*this, unregistrationResult);
+}
+
void ServiceWorkerJob::startScriptFetch()
{
ASSERT(currentThread() == m_creationThread);
void failedWithException(const Exception&);
void resolvedWithRegistration(ServiceWorkerRegistrationData&&);
+ void resolvedWithUnregistrationResult(bool);
void startScriptFetch();
ServiceWorkerJobData data() const { return m_jobData; }
virtual void jobFailedWithException(ServiceWorkerJob&, const Exception&) = 0;
virtual void jobResolvedWithRegistration(ServiceWorkerJob&, ServiceWorkerRegistrationData&&) = 0;
+ virtual void jobResolvedWithUnregistrationResult(ServiceWorkerJob&, bool unregistrationResult) = 0;
virtual void startScriptFetchForJob(ServiceWorkerJob&) = 0;
virtual void jobFinishedLoadingScript(ServiceWorkerJob&, const String&) = 0;
virtual void jobFailedLoadingScript(ServiceWorkerJob&, const ResourceError&) = 0;
case ServiceWorkerJobType::Register:
encoder << registrationOptions;
break;
+ case ServiceWorkerJobType::Unregister:
+ break;
}
}
if (!decoder.decode(jobData->registrationOptions))
return std::nullopt;
break;
+ case ServiceWorkerJobType::Unregister:
+ break;
}
return jobData;
enum class ServiceWorkerJobType {
Register,
+ Unregister,
};
} // namespace WebCore
#include "ServiceWorkerRegistration.h"
#if ENABLE(SERVICE_WORKER)
+#include "DOMWindow.h"
+#include "Document.h"
+#include "Navigator.h"
+#include "ServiceWorkerContainer.h"
+#include "WorkerGlobalScope.h"
+#include "WorkerNavigator.h"
namespace WebCore {
+static ServiceWorkerContainer* containerForScriptExecutionContext(ScriptExecutionContext& context)
+{
+ NavigatorBase* navigator = nullptr;
+ if (is<Document>(context)) {
+ if (auto* window = downcast<Document>(context).domWindow())
+ navigator = window->navigator();
+ } else
+ navigator = &downcast<WorkerGlobalScope>(context).navigator();
+
+ return navigator ? navigator->serviceWorker() : nullptr;
+}
+
ServiceWorkerRegistration::ServiceWorkerRegistration(ScriptExecutionContext& context, ServiceWorkerRegistrationData&& registrationData)
: ActiveDOMObject(&context)
, m_registrationData(WTFMove(registrationData))
void ServiceWorkerRegistration::unregister(Ref<DeferredPromise>&& promise)
{
- promise->reject(Exception(NotSupportedError, ASCIILiteral("ServiceWorkerRegistration::unregister not yet implemented")));
+ auto* context = scriptExecutionContext();
+ if (!context) {
+ ASSERT_NOT_REACHED();
+ promise->reject(Exception(InvalidStateError));
+ return;
+ }
+
+ auto* container = containerForScriptExecutionContext(*context);
+ if (!container) {
+ promise->reject(Exception(InvalidStateError));
+ return;
+ }
+
+ container->removeRegistration(m_registrationData.scopeURL, WTFMove(promise));
}
EventTargetInterface ServiceWorkerRegistration::eventTargetInterface() const
job->failedWithException(exceptionData.toException());
}
-void SWClientConnection::jobResolvedInServer(uint64_t jobIdentifier, ServiceWorkerRegistrationData&& registrationData)
+void SWClientConnection::registrationJobResolvedInServer(uint64_t jobIdentifier, ServiceWorkerRegistrationData&& registrationData)
{
auto job = m_scheduledJobs.take(jobIdentifier);
if (!job) {
job->resolvedWithRegistration(WTFMove(registrationData));
}
+void SWClientConnection::unregistrationJobResolvedInServer(uint64_t jobIdentifier, bool unregistrationResult)
+{
+ auto job = m_scheduledJobs.take(jobIdentifier);
+ if (!job) {
+ LOG_ERROR("Job %" PRIu64 " resolved in server, but was not found", jobIdentifier);
+ return;
+ }
+
+ job->resolvedWithUnregistrationResult(unregistrationResult);
+}
+
void SWClientConnection::startScriptFetchForServer(uint64_t jobIdentifier)
{
auto job = m_scheduledJobs.get(jobIdentifier);
protected:
WEBCORE_EXPORT void jobRejectedInServer(uint64_t jobIdentifier, const ExceptionData&);
- WEBCORE_EXPORT void jobResolvedInServer(uint64_t jobIdentifier, ServiceWorkerRegistrationData&&);
+ WEBCORE_EXPORT void registrationJobResolvedInServer(uint64_t jobIdentifier, ServiceWorkerRegistrationData&&);
+ WEBCORE_EXPORT void unregistrationJobResolvedInServer(uint64_t jobIdentifier, bool unregistrationResult);
WEBCORE_EXPORT void startScriptFetchForServer(uint64_t jobIdentifier);
private:
connection->rejectJobInClient(jobData.identifier(), exceptionData);
}
-void SWServer::resolveJob(const ServiceWorkerJobData& jobData, const ServiceWorkerRegistrationData& registrationData)
+void SWServer::resolveRegistrationJob(const ServiceWorkerJobData& jobData, const ServiceWorkerRegistrationData& registrationData)
{
LOG(ServiceWorker, "Resolved ServiceWorker job %" PRIu64 "-%" PRIu64 " in server with registration %" PRIu64, jobData.connectionIdentifier(), jobData.identifier(), registrationData.identifier);
auto* connection = m_connections.get(jobData.connectionIdentifier());
if (!connection)
return;
- connection->resolveJobInClient(jobData.identifier(), registrationData);
+ connection->resolveRegistrationJobInClient(jobData.identifier(), registrationData);
+}
+
+void SWServer::resolveUnregistrationJob(const ServiceWorkerJobData& jobData, const ServiceWorkerRegistrationKey& registrationKey, bool unregistrationResult)
+{
+ auto* connection = m_connections.get(jobData.connectionIdentifier());
+ if (!connection)
+ return;
+
+ connection->resolveUnregistrationJobInClient(jobData.identifier(), registrationKey, unregistrationResult);
}
void SWServer::startScriptFetch(const ServiceWorkerJobData& jobData)
private:
// Messages to the client WebProcess
virtual void rejectJobInClient(uint64_t jobIdentifier, const ExceptionData&) = 0;
- virtual void resolveJobInClient(uint64_t jobIdentifier, const ServiceWorkerRegistrationData&) = 0;
+ virtual void resolveRegistrationJobInClient(uint64_t jobIdentifier, const ServiceWorkerRegistrationData&) = 0;
+ virtual void resolveUnregistrationJobInClient(uint64_t jobIdentifier, const ServiceWorkerRegistrationKey&, bool registrationResult) = 0;
virtual void startScriptFetchInClient(uint64_t jobIdentifier) = 0;
// Messages to the SW host WebProcess
void scheduleJob(const ServiceWorkerJobData&);
void rejectJob(const ServiceWorkerJobData&, const ExceptionData&);
- void resolveJob(const ServiceWorkerJobData&, const ServiceWorkerRegistrationData&);
+ void resolveRegistrationJob(const ServiceWorkerJobData&, const ServiceWorkerRegistrationData&);
+ void resolveUnregistrationJob(const ServiceWorkerJobData&, const ServiceWorkerRegistrationKey&, bool unregistrationResult);
void startScriptFetch(const ServiceWorkerJobData&);
void postTask(CrossThreadTask&&);
void SWServerRegistration::scriptContextStarted(SWServer::Connection&, uint64_t identifier, const String& workerID)
{
UNUSED_PARAM(workerID);
- resolveCurrentJob(ServiceWorkerRegistrationData { m_registrationKey, identifier, m_scopeURL, m_updateViaCache.value_or(ServiceWorkerUpdateViaCache::Imports) });
+ resolveCurrentRegistrationJob(ServiceWorkerRegistrationData { m_registrationKey, identifier, m_scopeURL, m_updateViaCache.value_or(ServiceWorkerUpdateViaCache::Imports) });
}
void SWServerRegistration::startNextJob()
case ServiceWorkerJobType::Register:
m_server.postTask(createCrossThreadTask(*this, &SWServerRegistration::runRegisterJob, *m_currentJob));
return;
+ case ServiceWorkerJobType::Unregister:
+ m_server.postTask(createCrossThreadTask(*this, &SWServerRegistration::runUnregisterJob, *m_currentJob));
+ return;
}
RELEASE_ASSERT_NOT_REACHED();
runUpdateJob(job);
}
+void SWServerRegistration::runUnregisterJob(const ServiceWorkerJobData& job)
+{
+ // If the origin of job’s scope url is not job's client's origin, then:
+ if (!protocolHostAndPortAreEqual(job.scopeURL, job.clientCreationURL))
+ return rejectWithExceptionOnMainThread(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.
+ // If registration is null, then:
+ if (isEmpty() || m_uninstalling) {
+ // Invoke Resolve Job Promise with job and false.
+ resolveWithUnregistrationResultOnMainThread(false);
+ return;
+ }
+
+ // Set registration’s uninstalling flag.
+ m_uninstalling = true;
+
+ // Invoke Resolve Job Promise with job and true.
+ resolveWithUnregistrationResultOnMainThread(true);
+
+ // FIXME: Invoke Try Clear Registration with registration.
+}
+
void SWServerRegistration::runUpdateJob(const ServiceWorkerJobData& job)
{
// If registration is null (in our parlance "empty") or registration’s uninstalling flag is set, then:
void SWServerRegistration::resolveWithRegistrationOnMainThread()
{
ASSERT(!isMainThread());
- m_server.postTaskReply(createCrossThreadTask(*this, &SWServerRegistration::resolveCurrentJob, data()));
+ m_server.postTaskReply(createCrossThreadTask(*this, &SWServerRegistration::resolveCurrentRegistrationJob, data()));
+}
+
+void SWServerRegistration::resolveWithUnregistrationResultOnMainThread(bool unregistrationResult)
+{
+ ASSERT(!isMainThread());
+ m_server.postTaskReply(createCrossThreadTask(*this, &SWServerRegistration::resolveCurrentUnregistrationJob, unregistrationResult));
}
void SWServerRegistration::startScriptFetchFromMainThread()
finishCurrentJob();
}
-void SWServerRegistration::resolveCurrentJob(const ServiceWorkerRegistrationData& data)
+void SWServerRegistration::resolveCurrentRegistrationJob(const ServiceWorkerRegistrationData& data)
+{
+ ASSERT(isMainThread());
+ ASSERT(m_currentJob);
+ ASSERT(m_currentJob->type == ServiceWorkerJobType::Register);
+
+ m_server.resolveRegistrationJob(*m_currentJob, data);
+
+ finishCurrentJob();
+}
+
+void SWServerRegistration::resolveCurrentUnregistrationJob(bool unregistrationResult)
{
ASSERT(isMainThread());
ASSERT(m_currentJob);
+ ASSERT(m_currentJob->type == ServiceWorkerJobType::Unregister);
- m_server.resolveJob(*m_currentJob, data);
+ m_server.resolveUnregistrationJob(*m_currentJob, m_registrationKey, unregistrationResult);
finishCurrentJob();
}
void jobTimerFired();
void startNextJob();
void rejectCurrentJob(const ExceptionData&);
- void resolveCurrentJob(const ServiceWorkerRegistrationData&);
+ void resolveCurrentRegistrationJob(const ServiceWorkerRegistrationData&);
+ void resolveCurrentUnregistrationJob(bool unregistrationResult);
void startScriptFetchForCurrentJob();
void finishCurrentJob();
void runRegisterJob(const ServiceWorkerJobData&);
+ void runUnregisterJob(const ServiceWorkerJobData&);
void runUpdateJob(const ServiceWorkerJobData&);
void rejectWithExceptionOnMainThread(const ExceptionData&);
void resolveWithRegistrationOnMainThread();
+ void resolveWithUnregistrationResultOnMainThread(bool);
void startScriptFetchFromMainThread();
bool isEmpty();
SWServerWorker* getNewestWorker();
2017-10-25 Chris Dumez <cdumez@apple.com>
+ Add support for unregistering a service worker
+ https://bugs.webkit.org/show_bug.cgi?id=178735
+
+ Reviewed by Brady Eidson.
+
+ Add support for unregistering a service worker:
+ - https://w3c.github.io/ServiceWorker/#navigator-service-worker-unregister
+
+ * StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
+ (WebKit::WebSWServerConnection::resolveRegistrationJobInClient):
+ (WebKit::WebSWServerConnection::resolveUnregistrationJobInClient):
+ * StorageProcess/ServiceWorker/WebSWServerConnection.h:
+ * WebProcess/Storage/WebSWClientConnection.messages.in:
+
+2017-10-25 Chris Dumez <cdumez@apple.com>
+
Make SharedStringHashTable less error prone
https://bugs.webkit.org/show_bug.cgi?id=178764
send(Messages::WebSWClientConnection::JobRejectedInServer(jobIdentifier, exceptionData));
}
-void WebSWServerConnection::resolveJobInClient(uint64_t jobIdentifier, const ServiceWorkerRegistrationData& registrationData)
+void WebSWServerConnection::resolveRegistrationJobInClient(uint64_t jobIdentifier, const ServiceWorkerRegistrationData& registrationData)
{
auto origin = registrationData.key.topOrigin.securityOrigin();
StorageProcess::singleton().ensureSWOriginStoreForSession(m_sessionID).add(origin);
- send(Messages::WebSWClientConnection::JobResolvedInServer(jobIdentifier, registrationData));
+ send(Messages::WebSWClientConnection::RegistrationJobResolvedInServer(jobIdentifier, registrationData));
+}
+
+void WebSWServerConnection::resolveUnregistrationJobInClient(uint64_t jobIdentifier, const ServiceWorkerRegistrationKey& registrationKey, bool unregistrationResult)
+{
+ auto origin = registrationKey.topOrigin.securityOrigin();
+ if (auto* store = StorageProcess::singleton().swOriginStoreForSession(m_sessionID))
+ store->remove(origin);
+ send(Messages::WebSWClientConnection::UnregistrationJobResolvedInServer(jobIdentifier, unregistrationResult));
}
void WebSWServerConnection::startScriptFetchInClient(uint64_t jobIdentifier)
private:
// Implement SWServer::Connection (Messages to the client WebProcess)
void rejectJobInClient(uint64_t jobIdentifier, const WebCore::ExceptionData&) final;
- void resolveJobInClient(uint64_t jobIdentifier, const WebCore::ServiceWorkerRegistrationData&) final;
+ void resolveRegistrationJobInClient(uint64_t jobIdentifier, const WebCore::ServiceWorkerRegistrationData&) final;
+ void resolveUnregistrationJobInClient(uint64_t jobIdentifier, const WebCore::ServiceWorkerRegistrationKey&, bool unregistrationResult) final;
void startScriptFetchInClient(uint64_t jobIdentifier) final;
void startFetch(uint64_t fetchIdentifier, uint64_t serviceWorkerIdentifier, const WebCore::ResourceRequest&, const WebCore::FetchOptions&);
messages -> WebSWClientConnection {
# When possible, these messages can be implemented directly by WebCore::SWServer::Connection
JobRejectedInServer(uint64_t identifier, struct WebCore::ExceptionData exception)
- JobResolvedInServer(uint64_t identifier, struct WebCore::ServiceWorkerRegistrationData registration)
+ RegistrationJobResolvedInServer(uint64_t identifier, struct WebCore::ServiceWorkerRegistrationData registration)
+ UnregistrationJobResolvedInServer(uint64_t identifier, bool unregistrationResult)
StartScriptFetchForServer(uint64_t jobIdentifier)
SetSWOriginTableSharedMemory(WebKit::SharedMemory::Handle handle)