Service workers do not work well inside Web.app
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 25 Feb 2018 19:02:15 +0000 (19:02 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 25 Feb 2018 19:02:15 +0000 (19:02 +0000)
commit6f0b9a57e003b0152e03e720ee0ee5af7f3fe7af
treed0e7ae26720d670982fa67239cd689908afd32b1
parent686155dbf3b0ebd35750c99634ab3e0a00356aa6
Service workers do not work well inside Web.app
https://bugs.webkit.org/show_bug.cgi?id=183105
<rdar://problem/37864140>

Reviewed by Youenn Fablet.

Source/WebCore:

SessionID::defaultSessionID() was hardcoded in the ServiceWorkerThread constructor
instead of using the sessionID of the SWServer that created the service worker thread.
As a result, when the Service Worker would establish a SWClientConnection to the
server, it would use the wrong sessionID and would end up using a different SWServer
(Since we have a different SWServer instance per sessionID). As a result,
ServiceWorkerRegistration / ServiceWorker objects inside the service worker would not
be kept in sync with the server (since they registered themselves with the wrong
SWServer).

Covered by new API test.

* workers/service/ServiceWorkerContextData.cpp:
(WebCore::ServiceWorkerContextData::isolatedCopy const):
* workers/service/ServiceWorkerContextData.h:
(WebCore::ServiceWorkerContextData::encode const):
(WebCore::ServiceWorkerContextData::decode):
* workers/service/context/ServiceWorkerThread.cpp:
(WebCore::ServiceWorkerThread::ServiceWorkerThread):
* workers/service/context/ServiceWorkerThreadProxy.cpp:
(WebCore::createPageForServiceWorker):
(WebCore::ServiceWorkerThreadProxy::ServiceWorkerThreadProxy):
* workers/service/server/RegistrationDatabase.cpp:
(WebCore::RegistrationDatabase::importRecords):
* workers/service/server/RegistrationStore.h:
(WebCore::RegistrationStore::server):
* workers/service/server/SWServer.cpp:
(WebCore::SWServer::updateWorker):
* workers/service/server/SWServerWorker.cpp:
(WebCore::SWServerWorker::contextData const):

Source/WebKit:

* StorageProcess/StorageProcess.cpp:
(WebKit::StorageProcess::didReceiveMessage):
We were failing to forward IPC messages to the ChildProcess class here. As a result,
the ChildProcess::RegisterURLSchemeServiceWorkersCanHandle IPC was being ignored
by the StorageProcess.

Tools:

Add API test coverage.

* TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@228978 268f45cc-cd09-0410-ab3c-d52691b4dbfc
13 files changed:
Source/WebCore/ChangeLog
Source/WebCore/workers/service/ServiceWorkerContextData.cpp
Source/WebCore/workers/service/ServiceWorkerContextData.h
Source/WebCore/workers/service/context/ServiceWorkerThread.cpp
Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp
Source/WebCore/workers/service/server/RegistrationDatabase.cpp
Source/WebCore/workers/service/server/RegistrationStore.h
Source/WebCore/workers/service/server/SWServer.cpp
Source/WebCore/workers/service/server/SWServerWorker.cpp
Source/WebKit/ChangeLog
Source/WebKit/StorageProcess/StorageProcess.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm