ASSERTION FAILED: addResult.isNewEntry WebCore::SWServerRegistration::addClientUsingR...
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Nov 2017 23:13:54 +0000 (23:13 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Nov 2017 23:13:54 +0000 (23:13 +0000)
commit1286600dde7e2d93a26771ccaa9ff910df1ef5e5
tree28843d4d23635caf1da082f0383ce50404b9c6eb
parent7794a1b8d584b4cf36a5b13845c515655959e13b
ASSERTION FAILED: addResult.isNewEntry WebCore::SWServerRegistration::addClientUsingRegistration(WebCore::ServiceWorkerClientIdentifier const&) + 141
https://bugs.webkit.org/show_bug.cgi?id=180049

Reviewed by Brady Eidson.

Source/WebCore:

SWServer::serviceWorkerStoppedControllingClient() was failing to remove the client from the
SWServerRegistration in some cases. This is because we relied on the Service Worker Identifier
to get the SWServerRegistration, via the corresponding SWServerServiceWorker object. However,
It is possible for the SWServerServiceWorker to have been destroyed already.

In serviceWorkerStartedControllingClient / serviceWorkerStoppedControllingClient, we now
pass the registration identifier, so that we are able to look up the registration directly,
without going through the service worker object.

No new tests, already covered by imported/w3c/web-platform-tests/service-workers/service-worker/claim-affect-other-registration.https.html.

* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::setActiveServiceWorker):
* workers/service/ServiceWorker.h:
* workers/service/ServiceWorkerContainer.cpp:
(WebCore::ServiceWorkerContainer::addRegistration):
(WebCore::ServiceWorkerContainer::removeRegistration):
* workers/service/ServiceWorkerData.cpp:
(WebCore::ServiceWorkerData::isolatedCopy const):
* workers/service/ServiceWorkerData.h:
(WebCore::ServiceWorkerData::encode const):
(WebCore::ServiceWorkerData::decode):
* workers/service/server/SWClientConnection.h:
* workers/service/server/SWServer.cpp:
(WebCore::SWServer::addRegistration):
(WebCore::SWServer::removeRegistration):
(WebCore::SWServer::clearAll):
(WebCore::SWServer::Connection::addServiceWorkerRegistrationInServer):
(WebCore::SWServer::Connection::removeServiceWorkerRegistrationInServer):
(WebCore::SWServer::Connection::serviceWorkerStartedControllingClient):
(WebCore::SWServer::Connection::serviceWorkerStoppedControllingClient):
(WebCore::SWServer::addClientServiceWorkerRegistration):
(WebCore::SWServer::removeClientServiceWorkerRegistration):
(WebCore::SWServer::serviceWorkerStartedControllingClient):
(WebCore::SWServer::serviceWorkerStoppedControllingClient):
(WebCore::SWServer::installContextData):
* workers/service/server/SWServer.h:
* workers/service/server/SWServerWorker.cpp:
(WebCore::SWServerWorker::SWServerWorker):
* workers/service/server/SWServerWorker.h:

Source/WebKit:

* StorageProcess/ServiceWorker/WebSWServerConnection.messages.in:
* WebProcess/Storage/WebSWClientConnection.cpp:
(WebKit::WebSWClientConnection::addServiceWorkerRegistrationInServer):
(WebKit::WebSWClientConnection::removeServiceWorkerRegistrationInServer):
(WebKit::WebSWClientConnection::serviceWorkerStartedControllingClient):
(WebKit::WebSWClientConnection::serviceWorkerStoppedControllingClient):
* WebProcess/Storage/WebSWClientConnection.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225198 268f45cc-cd09-0410-ab3c-d52691b4dbfc
15 files changed:
Source/WebCore/ChangeLog
Source/WebCore/dom/ScriptExecutionContext.cpp
Source/WebCore/workers/service/ServiceWorker.h
Source/WebCore/workers/service/ServiceWorkerContainer.cpp
Source/WebCore/workers/service/ServiceWorkerData.cpp
Source/WebCore/workers/service/ServiceWorkerData.h
Source/WebCore/workers/service/server/SWClientConnection.h
Source/WebCore/workers/service/server/SWServer.cpp
Source/WebCore/workers/service/server/SWServer.h
Source/WebCore/workers/service/server/SWServerWorker.cpp
Source/WebCore/workers/service/server/SWServerWorker.h
Source/WebKit/ChangeLog
Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in
Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp
Source/WebKit/WebProcess/Storage/WebSWClientConnection.h