Title: [240830] trunk/Tools
Revision
240830
Author
you...@apple.com
Date
2019-01-31 16:45:19 -0800 (Thu, 31 Jan 2019)

Log Message

Add an API test to cover UIClient checkUserMediaPermissionForOrigin being nullptr
https://bugs.webkit.org/show_bug.cgi?id=194106
<rdar://problem/47676333>

Reviewed by Ryosuke Niwa.

* TestWebKitAPI/Tests/WebKit/UserMedia.cpp:
(TestWebKitAPI::didFinishNavigation):
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebKit/getUserMedia.html:

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (240829 => 240830)


--- trunk/Tools/ChangeLog	2019-02-01 00:38:55 UTC (rev 240829)
+++ trunk/Tools/ChangeLog	2019-02-01 00:45:19 UTC (rev 240830)
@@ -1,3 +1,16 @@
+2019-01-31  Youenn Fablet  <you...@apple.com>
+
+        Add an API test to cover UIClient checkUserMediaPermissionForOrigin being nullptr
+        https://bugs.webkit.org/show_bug.cgi?id=194106
+        <rdar://problem/47676333>
+
+        Reviewed by Ryosuke Niwa.
+
+        * TestWebKitAPI/Tests/WebKit/UserMedia.cpp:
+        (TestWebKitAPI::didFinishNavigation):
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/WebKit/getUserMedia.html:
+
 2019-01-31  Chris Dumez  <cdu...@apple.com>
 
         Page zoom level is lost after a process swap or a crash

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit/UserMedia.cpp (240829 => 240830)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit/UserMedia.cpp	2019-02-01 00:38:55 UTC (rev 240829)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit/UserMedia.cpp	2019-02-01 00:45:19 UTC (rev 240830)
@@ -157,6 +157,44 @@
     EXPECT_TRUE(!didCrash);
 }
 
+static bool didReceiveMessage;
+static void didFinishNavigation(WKPageRef, WKNavigationRef, WKTypeRef, const void*)
+{
+    didReceiveMessage = true;
+}
+
+TEST(WebKit, EnumerateDevicesCrash)
+{
+    auto context = adoptWK(WKContextCreateWithConfiguration(nullptr));
+
+    WKRetainPtr<WKPageGroupRef> pageGroup(AdoptWK, WKPageGroupCreateWithIdentifier(Util::toWK("GetUserMedia").get()));
+    WKPreferencesRef preferences = WKPageGroupGetPreferences(pageGroup.get());
+    WKPreferencesSetMediaDevicesEnabled(preferences, true);
+    WKPreferencesSetFileAccessFromFileURLsAllowed(preferences, true);
+    WKPreferencesSetMediaCaptureRequiresSecureConnection(preferences, false);
+    WKPreferencesSetMockCaptureDevicesEnabled(preferences, true);
+
+    WKPageUIClientV6 uiClient;
+    // We want uiClient.checkUserMediaPermissionForOrigin to be null.
+    memset(&uiClient, 0, sizeof(uiClient));
+    uiClient.base.version = 6;
+
+    WKPageNavigationClientV3 loaderClient;
+    memset(&loaderClient, 0, sizeof(loaderClient));
+    loaderClient.base.version = 3;
+    loaderClient.didFinishNavigation = didFinishNavigation;
+
+    PlatformWebView webView(context.get(), pageGroup.get());
+    WKPageSetPageUIClient(webView.page(), &uiClient.base);
+    WKPageSetPageNavigationClient(webView.page(), &loaderClient.base);
+
+    // Load a page doing enumerateDevices.
+    didReceiveMessage = false;
+    auto url = "" "html"));
+    WKPageLoadURL(webView.page(), url.get());
+    Util::run(&didReceiveMessage);
+}
+
 } // namespace TestWebKitAPI
 
 #endif // ENABLE(MEDIA_STREAM)

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit/getUserMedia.html (240829 => 240830)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit/getUserMedia.html	2019-02-01 00:38:55 UTC (rev 240829)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit/getUserMedia.html	2019-02-01 00:45:19 UTC (rev 240830)
@@ -5,15 +5,16 @@
 
             let stream = null;
 
-            function promptForCapture()
+            async function promptForCapture()
             {
-                navigator.mediaDevices.getUserMedia({ audio: false, video: true })
-                .then((s) => {
-                      stream = s;
-                      video.srcObject = stream;
-                      console.log("Got user media");
-                })
-                .catch((error) => console.log(`Failed with error: ${error}`));
+                try {
+                    await navigator.mediaDevices.enumerateDevices();
+                    const stream = await navigator.mediaDevices.getUserMedia({ audio: false, video: true })
+                    video.srcObject = stream;
+                    console.log("Got user media");
+                } catch(error) {
+                    console.log(`Failed with error: ${error}`);
+                }
             }
 
             function stop(kind)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to