Add ability to API test Service Workers via a custom protocol.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Dec 2017 01:16:57 +0000 (01:16 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Dec 2017 01:16:57 +0000 (01:16 +0000)
commit4950b7657117bb5b05ae9bb366361bfe6e582440
tree8db527d5114b6ad325c27492835ee9ef909487fc
parentac76b420436eb331a29f0b1884e5c71820a3478d
Add ability to API test Service Workers via a custom protocol.
https://bugs.webkit.org/show_bug.cgi?id=180911

Reviewed by Chris Dumez.

Source/WebCore:

Covered by API test ServiceWorkers.Basic

This adds a set of "Service Workers can handle this" schemes to the scheme registry
and uses it for SW decisions instead of a handful of previous techniques.

* bindings/scripts/CodeGeneratorJS.pm:
(NeedsRuntimeCheck):
(GenerateRuntimeEnableConditionalString):
* bindings/scripts/IDLAttributes.json:

* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::hasServiceWorkerScheme):
* dom/ScriptExecutionContext.h:

* page/NavigatorServiceWorker.idl:

* platform/SchemeRegistry.cpp:
(WebCore::serviceWorkerSchemesLock):
(WebCore::serviceWorkerSchemes):
(WebCore::SchemeRegistry::registerURLSchemeServiceWorkersCanHandle):
(WebCore::SchemeRegistry::canServiceWorkersHandleURLScheme):
(WebCore::SchemeRegistry::isServiceWorkerContainerCustomScheme):
* platform/SchemeRegistry.h:

* workers/service/ServiceWorkerContainer.cpp:
(WebCore::ServiceWorkerContainer::addRegistration):

* workers/service/server/SWServerJobQueue.cpp:
(WebCore::SWServerJobQueue::runRegisterJob):

Source/WebKit:

This adds a set of "Service Workers can handle this" schemes to the scheme registry
and most of these WebKit changes are to support getting those values out to all processes.

Additionally, WebsiteDataRecords used to be file/http(s)-only. That seems bizarre and definitely
got in the way of testing. So I also added a way to allow any scheme to result in a valid record.

* Shared/ChildProcess.cpp:
(WebKit::ChildProcess::registerURLSchemeServiceWorkersCanHandle const):
* Shared/ChildProcess.h:
* Shared/ChildProcess.messages.in:

* Shared/Storage/StorageProcessCreationParameters.cpp:
(WebKit::StorageProcessCreationParameters::encode const):
(WebKit::StorageProcessCreationParameters::decode):
* Shared/Storage/StorageProcessCreationParameters.h:

* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::encode const):
(WebKit::WebProcessCreationParameters::decode):
* Shared/WebProcessCreationParameters.h:

* StorageProcess/StorageProcess.cpp:
(WebKit::StorageProcess::initializeWebsiteDataStore):

* UIProcess/API/Cocoa/WKProcessPool.mm:
(-[WKProcessPool _registerURLSchemeServiceWorkersCanHandle:]):
* UIProcess/API/Cocoa/WKProcessPoolPrivate.h:

* UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
(+[WKWebsiteDataStore _allowWebsiteDataRecordsForAllOrigins]):
* UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:

* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::ensureStorageProcessAndWebsiteDataStore):
(WebKit::WebProcessPool::initializeNewWebProcess):
(WebKit::WebProcessPool::registerURLSchemeServiceWorkersCanHandle):
* UIProcess/WebProcessPool.h:

* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::allowWebsiteDataRecordsForAllOrigins):
(WebKit::WebsiteDataStore::fetchDataAndApply):
* UIProcess/WebsiteData/WebsiteDataStore.h:

* WebProcess/Storage/WebServiceWorkerProvider.cpp:
(WebKit::WebServiceWorkerProvider::handleFetch):

* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::initializeWebProcess):

Tools:

Adds a very basic SW test:
- Verify WebsiteDataStore can wipe all SW registration data.
- Fire up a web page with a service worker
- Verify SW registration data for that page exists in the WebsiteDataStore.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226088 268f45cc-cd09-0410-ab3c-d52691b4dbfc
32 files changed:
Source/WebCore/ChangeLog
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/IDLAttributes.json
Source/WebCore/dom/ScriptExecutionContext.cpp
Source/WebCore/dom/ScriptExecutionContext.h
Source/WebCore/page/NavigatorServiceWorker.idl
Source/WebCore/platform/SchemeRegistry.cpp
Source/WebCore/platform/SchemeRegistry.h
Source/WebCore/workers/service/ServiceWorkerContainer.cpp
Source/WebCore/workers/service/server/SWServerJobQueue.cpp
Source/WebKit/ChangeLog
Source/WebKit/Shared/ChildProcess.cpp
Source/WebKit/Shared/ChildProcess.h
Source/WebKit/Shared/ChildProcess.messages.in
Source/WebKit/Shared/Storage/StorageProcessCreationParameters.cpp
Source/WebKit/Shared/Storage/StorageProcessCreationParameters.h
Source/WebKit/Shared/WebProcessCreationParameters.cpp
Source/WebKit/Shared/WebProcessCreationParameters.h
Source/WebKit/StorageProcess/StorageProcess.cpp
Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm
Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h
Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h
Source/WebKit/UIProcess/WebProcessPool.cpp
Source/WebKit/UIProcess/WebProcessPool.h
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h
Source/WebKit/WebProcess/Storage/WebServiceWorkerProvider.cpp
Source/WebKit/WebProcess/WebProcess.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm [new file with mode: 0644]