Don't attempt to extend sandbox when running tests with mock media devices
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 May 2018 19:13:35 +0000 (19:13 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 May 2018 19:13:35 +0000 (19:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=186150
<rdar://problem/40690875>

Reviewed by Alexey Proskuryakov.

Avoid attempting to issue a sandbox extension to actual media devices when
running with Mock capture devices.

Also handle the 'denyNextRequest' test state outside of the USE(APPLE_INTERNAL_SDK)
guards, since it is needed for Open Source builds as well.

* UIProcess/UserMediaProcessManager.cpp:
(WebKit::UserMediaProcessManager::willCreateMediaStream):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232360 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/UserMediaProcessManager.cpp

index dc9918f..64e4962 100644 (file)
@@ -1,3 +1,20 @@
+2018-05-31  Brent Fulgham  <bfulgham@apple.com>
+
+        Don't attempt to extend sandbox when running tests with mock media devices
+        https://bugs.webkit.org/show_bug.cgi?id=186150
+        <rdar://problem/40690875>
+
+        Reviewed by Alexey Proskuryakov.
+
+        Avoid attempting to issue a sandbox extension to actual media devices when
+        running with Mock capture devices.
+
+        Also handle the 'denyNextRequest' test state outside of the USE(APPLE_INTERNAL_SDK)
+        guards, since it is needed for Open Source builds as well.
+
+        * UIProcess/UserMediaProcessManager.cpp:
+        (WebKit::UserMediaProcessManager::willCreateMediaStream):
+
 2018-05-31  Antti Koivisto  <antti@apple.com>
 
         WebKit memory management: Safari jetsams on some websites when zooming and scrolling
index ae946f1..cd0a55b 100644 (file)
@@ -128,15 +128,18 @@ void UserMediaProcessManager::muteCaptureMediaStreamsExceptIn(WebPageProxy& page
 
 bool UserMediaProcessManager::willCreateMediaStream(UserMediaPermissionRequestManagerProxy& proxy, bool withAudio, bool withVideo)
 {
-#if ENABLE(SANDBOX_EXTENSIONS) && USE(APPLE_INTERNAL_SDK)
-    auto& processStartingCapture = proxy.page().process();
-
-    ASSERT(stateMap().contains(&processStartingCapture));
-
     if (m_denyNextRequest) {
         m_denyNextRequest = false;
         return false;
     }
+    
+    if (proxy.page().preferences().mockCaptureDevicesEnabled())
+        return true;
+    
+#if ENABLE(SANDBOX_EXTENSIONS) && USE(APPLE_INTERNAL_SDK)
+    auto& processStartingCapture = proxy.page().process();
+
+    ASSERT(stateMap().contains(&processStartingCapture));
 
     auto& state = processState(processStartingCapture);
     size_t extensionCount = 0;