Handle failure to extend sandbox gracefully
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 May 2018 20:13:34 +0000 (20:13 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 May 2018 20:13:34 +0000 (20:13 +0000)
commit9d7007b32e678ac5eded480399e69daf7c223a78
treeb804dc5216395abe4ddf0ac8ceb39882fb6d22b6
parentb62cde3930e7de6f7ef1196b824805152448e6e7
Handle failure to extend sandbox gracefully
https://bugs.webkit.org/show_bug.cgi?id=185779
<rdar://problem/40316349>

Reviewed by Brent Fulgham.

Source/WebCore:

Test: TestWebKitAPI/Tests/WebKitCocoa/UserMediaSimulateFailedSandbox.mm

* Modules/mediastream/UserMediaRequest.cpp:
(WebCore::UserMediaRequest::deny): Include the error string in the promise rejection.
* Modules/mediastream/UserMediaRequest.h:

Source/WebKit:

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _denyNextUserMediaRequest]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:

* UIProcess/UserMediaPermissionRequestManagerProxy.cpp:
(WebKit::UserMediaPermissionRequestManagerProxy::userMediaAccessWasGranted): Don't append
the request to m_grantedRequests if it failed.
(WebKit::UserMediaPermissionRequestManagerProxy::grantAccess): Deny request if willCreateMediaStream
fails.
* UIProcess/UserMediaPermissionRequestManagerProxy.h:

* UIProcess/UserMediaProcessManager.cpp:
(WebKit::UserMediaProcessManager::willCreateMediaStream): Don't try to extend sandbox if
we fail to allocate all necessary handles.
* UIProcess/UserMediaProcessManager.h:
(WebKit::UserMediaProcessManager::denyNextUserMediaRequest): New, for testing.

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKitCocoa/UserMediaSimulateFailedSandbox.mm: Added.
(-[SimulateFailedSandboxMessageHandler userContentController:didReceiveScriptMessage:]):
(-[SimulateFailedSandboxUIDelegate _webView:requestUserMediaAuthorizationForDevices:url:mainFrameURL:decisionHandler:]):
(-[SimulateFailedSandboxUIDelegate _webView:checkUserMediaPermissionForURL:mainFrameURL:frameIdentifier:decisionHandler:]):
(MediaCaptureSimulateFailedSandbox::SetUp):
(MediaCaptureSimulateFailedSandbox::loadTestAndWaitForMessage):
(TEST_F):
* TestWebKitAPI/Tests/WebKitCocoa/disableGetUserMedia.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231979 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/UserMediaRequest.cpp
Source/WebCore/Modules/mediastream/UserMediaRequest.h
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h
Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.cpp
Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.h
Source/WebKit/UIProcess/UserMediaProcessManager.cpp
Source/WebKit/UIProcess/UserMediaProcessManager.h
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKitCocoa/UserMediaSimulateFailedSandbox.mm [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKitCocoa/disableGetUserMedia.html