Do not go to the storage process when registering a service worker client if there...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Jan 2018 22:58:48 +0000 (22:58 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Jan 2018 22:58:48 +0000 (22:58 +0000)
commit4ebd812d866436c67a5cdd6f489d10f6701d479e
tree81dbc7739336595110cfcd37d9132f45476a35d6
parent097b6dafd6df9c5e3b16343194cb048b78edef65
Do not go to the storage process when registering a service worker client if there is no service worker registered
https://bugs.webkit.org/show_bug.cgi?id=181740
<rdar://problem/36650400>

Patch by Youenn Fablet <youenn@apple.com> on 2018-01-19
Reviewed by Chris Dumez.

Source/WebCore:

Register a document as service worker client only if there is an existing service worker connection.
This allows not creating any connection if no service worker is registered.

Add internals API to test whether a service worker connection was created or not.
This is used by API tests that cover the changes.

* dom/Document.cpp:
(WebCore::Document::privateBrowsingStateDidChange): No need to create a service worker connection if client is not registered yet.
(WebCore::Document::setServiceWorkerConnection): No need to unregister/register if service worker connection is the same.
Similarly, if Document is to be destroyed or suspended, we should not register it.
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::commitData):
* testing/Internals.cpp:
(WebCore::Internals::hasServiceWorkerConnection):
* testing/Internals.h:
* testing/Internals.idl:
* workers/service/ServiceWorkerProvider.cpp:
(WebCore::ServiceWorkerProvider::registerServiceWorkerClients):
* workers/service/ServiceWorkerProvider.h:

Source/WebKit:

UIProcess notifies all web processes to register their service worker clients when spinning the service worker process.
Add private API to set the number of web processes for testing purposes.

* UIProcess/API/Cocoa/WKProcessPool.mm:
(-[WKProcessPool _setMaximumNumberOfProcesses:]):
* UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::establishWorkerContextConnectionToStorageProcess):
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::registerServiceWorkerClients):
* WebProcess/WebProcess.h:
* WebProcess/WebProcess.messages.in:

Tools:

Add support for internals inside API tests.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/InjectInternals_Bundle.cpp: Added.
(TestWebKitAPI::InternalsInjectedBundleTest::InternalsInjectedBundleTest):
(TestWebKitAPI::InternalsInjectedBundleTest::initialize):
(TestWebKitAPI::InternalsInjectedBundleTest::didCreatePage):
(TestWebKitAPI::InternalsInjectedBundleTest::didClearWindowForFrame):
* TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:
(setConfigurationInjectedBundlePath):
(-[RegularPageMessageHandler userContentController:didReceiveScriptMessage:]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227242 268f45cc-cd09-0410-ab3c-d52691b4dbfc
19 files changed:
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/loader/DocumentLoader.cpp
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Source/WebCore/workers/service/ServiceWorkerProvider.cpp
Source/WebCore/workers/service/ServiceWorkerProvider.h
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm
Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h
Source/WebKit/UIProcess/WebProcessPool.cpp
Source/WebKit/WebProcess/WebProcess.cpp
Source/WebKit/WebProcess/WebProcess.h
Source/WebKit/WebProcess/WebProcess.messages.in
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/InjectInternals_Bundle.cpp [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm