Add an entitlement check for service worker on iOS
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 17 Feb 2018 00:46:52 +0000 (00:46 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 17 Feb 2018 00:46:52 +0000 (00:46 +0000)
commit1ead5e3d98dbc65721a8b8a007acf01e138ee11b
tree865d2c9c0b8e5247400e89330b1ba382611e84c3
parent0fb5b51101f7f2f4c06e9acb6b3510cdb326294d
Add an entitlement check for service worker on iOS
https://bugs.webkit.org/show_bug.cgi?id=182865
<rdar://problem/37505903>

Reviewed by Brady Eidson.

Source/WebKit:

Added an entitlement check to enable service workers on iOS.

* Shared/mac/SandboxUtilities.h:
* Shared/mac/SandboxUtilities.mm:
(WebKit::connectedProcessHasEntitlement): Added.
* StorageProcess/StorageProcess.cpp:
(WebKit::StorageProcess::createStorageToWebProcessConnection): Enforce the entitlement check by crashing
when this code is executed without the parent process having the service worker entitlement. This should
never happen unless someone is trying to bypass the entitlement check in UI Process since we ordinarily
disable service worker gracefully in WKWebView _initializeWithConfiguration.
(WebKit::StorageProcess::swServerForSession): Ditto.
(WebKit::StorageProcess::registerSWServerConnection): Ditto.
* StorageProcess/StorageProcess.h:
(WebKit::StorageProcess::parentProcessHasServiceWorkerEntitlement const): Added.
* StorageProcess/ios/StorageProcessIOS.mm:
(WebKit::StorageProcess::parentProcessHasServiceWorkerEntitlement const): Added.
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _initializeWithConfiguration:]): Disable the service workers when the entitlement is
missing from the current process. The entitlement is enforced by WebContent and Storage process.
This check avoids crashing WebContent process and gracefully disabling the feature.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences): Enforce the entitlement check.
* WebProcess/WebPage/WebPage.h:
(WebKit::WebPage::parentProcessHasServiceWorkerEntitlement const): Added.
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::parentProcessHasServiceWorkerEntitlement const): Added.

Tools:

Added the service worker entitlements to WebKitTestRunner and TestWebKitAPI on iOS.

* TestWebKitAPI/Configurations/TestWebKitAPI-iOS.entitlements:
* WebKitTestRunner/Configurations/WebKitTestRunnerApp-iOS.entitlements:
* WebKitTestRunner/Configurations/WebKitTestRunnerApp.xcconfig:
* WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@228589 268f45cc-cd09-0410-ab3c-d52691b4dbfc
15 files changed:
Source/WebKit/ChangeLog
Source/WebKit/Shared/mac/SandboxUtilities.h
Source/WebKit/Shared/mac/SandboxUtilities.mm
Source/WebKit/StorageProcess/StorageProcess.cpp
Source/WebKit/StorageProcess/StorageProcess.h
Source/WebKit/StorageProcess/ios/StorageProcessIOS.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
Tools/ChangeLog
Tools/TestWebKitAPI/Configurations/TestWebKitAPI-iOS.entitlements
Tools/WebKitTestRunner/Configurations/WebKitTestRunnerApp-iOS.entitlements [new file with mode: 0644]
Tools/WebKitTestRunner/Configurations/WebKitTestRunnerApp.xcconfig
Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj