Tools/ChangeLog

 12019-01-31 Youenn Fablet <youenn@apple.com>
 2
 3 Add an API test to cover UIClient checkUserMediaPermissionForOrigin being nullptr
 4 https://bugs.webkit.org/show_bug.cgi?id=194106
 5 <rdar://problem/47676333>
 6
 7 Reviewed by NOBODY (OOPS!).
 8
 9 * TestWebKitAPI/Tests/WebKit/UserMedia.cpp:
 10 (TestWebKitAPI::didFinishNavigation):
 11 (TestWebKitAPI::TEST):
 12 * TestWebKitAPI/Tests/WebKit/getUserMedia.html:
 13
1142019-01-31 Zalan Bujtas <zalan@apple.com>
215
316 [LFC] Margin before/after/start/end initial value is 0 and not auto.

Tools/TestWebKitAPI/Tests/WebKit/UserMedia.cpp

@@TEST(WebKit, OnDeviceChangeCrash)
157157 EXPECT_TRUE(!didCrash);
158158}
159159
 160static bool didReceiveMessage;
 161static void didFinishNavigation(WKPageRef, WKNavigationRef, WKTypeRef, const void*)
 162{
 163 didReceiveMessage = true;
 164}
 165
 166TEST(WebKit, EnumerateDevicesCrash)
 167{
 168 auto context = adoptWK(WKContextCreateWithConfiguration(nullptr));
 169
 170 WKRetainPtr<WKPageGroupRef> pageGroup(AdoptWK, WKPageGroupCreateWithIdentifier(Util::toWK("GetUserMedia").get()));
 171 WKPreferencesRef preferences = WKPageGroupGetPreferences(pageGroup.get());
 172 WKPreferencesSetMediaDevicesEnabled(preferences, true);
 173 WKPreferencesSetFileAccessFromFileURLsAllowed(preferences, true);
 174 WKPreferencesSetMediaCaptureRequiresSecureConnection(preferences, false);
 175 WKPreferencesSetMockCaptureDevicesEnabled(preferences, true);
 176
 177 WKPageUIClientV6 uiClient;
 178 // We want uiClient.checkUserMediaPermissionForOrigin to be null.
 179 memset(&uiClient, 0, sizeof(uiClient));
 180 uiClient.base.version = 6;
 181
 182 WKPageNavigationClientV3 loaderClient;
 183 memset(&loaderClient, 0, sizeof(loaderClient));
 184 loaderClient.base.version = 3;
 185 loaderClient.didFinishNavigation = didFinishNavigation;
 186
 187 PlatformWebView webView(context.get(), pageGroup.get());
 188 WKPageSetPageUIClient(webView.page(), &uiClient.base);
 189 WKPageSetPageNavigationClient(webView.page(), &loaderClient.base);
 190
 191 // Load a page doing enumerateDevices.
 192 didReceiveMessage = false;
 193 auto url = adoptWK(Util::createURLForResource("getUserMedia", "html"));
 194 WKPageLoadURL(webView.page(), url.get());
 195 Util::run(&didReceiveMessage);
 196}
 197
160198} // namespace TestWebKitAPI
161199
162200#endif // ENABLE(MEDIA_STREAM)

Tools/TestWebKitAPI/Tests/WebKit/getUserMedia.html

55
66 let stream = null;
77
8  function promptForCapture()
 8 async function promptForCapture()
99 {
10  navigator.mediaDevices.getUserMedia({ audio: false, video: true })
11  .then((s) => {
12  stream = s;
13  video.srcObject = stream;
14  console.log("Got user media");
15  })
16  .catch((error) => console.log(`Failed with error: ${error}`));
 10 try {
 11 await navigator.mediaDevices.enumerateDevices();
 12 const stream = await navigator.mediaDevices.getUserMedia({ audio: false, video: true })
 13 video.srcObject = stream;
 14 console.log("Got user media");
 15 } catch(error) {
 16 console.log(`Failed with error: ${error}`);
 17 }
1718 }
1819
1920 function stop(kind)