<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[285717] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/285717">285717</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2021-11-12 06:57:30 -0800 (Fri, 12 Nov 2021)</dd>
</dl>
<h3>Log Message</h3>
<pre>Disable getUserMedia() when in Captive Portal Mode
https://bugs.webkit.org/show_bug.cgi?id=233021
Reviewed by Brent Fulgham.
Source/WebKit:
Disable getUserMedia() when in Captive Portal Mode.
No new tests, covered by updated API test.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):
Tools:
Add API test coverage.
* TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageWebPagecpp">trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitCocoaProcessSwapOnNavigationmm">trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (285716 => 285717)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog 2021-11-12 14:40:42 UTC (rev 285716)
+++ trunk/Source/WebKit/ChangeLog 2021-11-12 14:57:30 UTC (rev 285717)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2021-11-12 Chris Dumez <cdumez@apple.com>
+
+ Disable getUserMedia() when in Captive Portal Mode
+ https://bugs.webkit.org/show_bug.cgi?id=233021
+
+ Reviewed by Brent Fulgham.
+
+ Disable getUserMedia() when in Captive Portal Mode.
+
+ No new tests, covered by updated API test.
+
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::updatePreferences):
+
</ins><span class="cx"> 2021-11-11 Sergio Villar Senin <svillar@igalia.com>
</span><span class="cx">
</span><span class="cx"> [css-flexbox] Add flex-basis: content support
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (285716 => 285717)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2021-11-12 14:40:42 UTC (rev 285716)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2021-11-12 14:57:30 UTC (rev 285717)
</span><span class="lines">@@ -4064,6 +4064,9 @@
</span><span class="cx"> settings.setWebXREnabled(false);
</span><span class="cx"> settings.setWebXRAugmentedRealityModuleEnabled(false);
</span><span class="cx"> #endif
</span><ins>+#if ENABLE(MEDIA_STREAM)
+ settings.setMediaDevicesEnabled(false);
+#endif
</ins><span class="cx"> #if ENABLE(WEB_AUDIO)
</span><span class="cx"> settings.setWebAudioEnabled(false);
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (285716 => 285717)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog 2021-11-12 14:40:42 UTC (rev 285716)
+++ trunk/Tools/ChangeLog 2021-11-12 14:57:30 UTC (rev 285717)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2021-11-12 Chris Dumez <cdumez@apple.com>
+
+ Disable getUserMedia() when in Captive Portal Mode
+ https://bugs.webkit.org/show_bug.cgi?id=233021
+
+ Reviewed by Brent Fulgham.
+
+ Add API test coverage.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
+
</ins><span class="cx"> 2021-11-11 Brent Fulgham <bfulgham@apple.com>
</span><span class="cx">
</span><span class="cx"> [WebAuthn] Stop serializing BufferSource and Vector<uint8_t> duplicates of identifiers
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKitCocoaProcessSwapOnNavigationmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm (285716 => 285717)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm 2021-11-12 14:40:42 UTC (rev 285716)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm 2021-11-12 14:57:30 UTC (rev 285717)
</span><span class="lines">@@ -7646,33 +7646,40 @@
</span><span class="cx"> enum class IsShowingInitialEmptyDocument : bool { No, Yes };
</span><span class="cx"> static void checkSettingsControlledByCaptivePortalMode(WKWebView *webView, ShouldBeEnabled shouldBeEnabled, IsShowingInitialEmptyDocument isShowingInitialEmptyDocument = IsShowingInitialEmptyDocument::No)
</span><span class="cx"> {
</span><del>- auto checkWindowPropertyExists = [&](ASCIILiteral property) -> bool {
</del><ins>+ auto runJSCheck = [&](const String& js) -> bool {
</ins><span class="cx"> bool finishedRunningScript = false;
</span><del>- bool propertyExists = false;
- [webView evaluateJavaScript:makeString("!!window.", property) completionHandler:[&] (id result, NSError *error) {
</del><ins>+ bool checkResult = false;
+ [webView evaluateJavaScript:js completionHandler:[&] (id result, NSError *error) {
</ins><span class="cx"> EXPECT_NULL(error);
</span><del>- propertyExists = [result boolValue];
</del><ins>+ checkResult = [result boolValue];
</ins><span class="cx"> finishedRunningScript = true;
</span><span class="cx"> }];
</span><span class="cx"> TestWebKitAPI::Util::run(&finishedRunningScript);
</span><del>- return propertyExists;
</del><ins>+ return checkResult;
</ins><span class="cx"> };
</span><span class="cx">
</span><del>- EXPECT_EQ(checkWindowPropertyExists("WebGL2RenderingContext"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // WebGL2.
- EXPECT_EQ(checkWindowPropertyExists("Gamepad"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // Gamepad API.
- EXPECT_EQ(checkWindowPropertyExists("RemotePlayback"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // Remote Playback.
- EXPECT_EQ(checkWindowPropertyExists("FileSystemHandle"_s), isShowingInitialEmptyDocument != IsShowingInitialEmptyDocument::Yes && shouldBeEnabled == ShouldBeEnabled::Yes); // File System Access.
- EXPECT_EQ(checkWindowPropertyExists("EnterPictureInPictureEvent"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // Picture in Picture API.
- EXPECT_EQ(checkWindowPropertyExists("SpeechRecognitionEvent"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // Speech recognition.
- EXPECT_EQ(checkWindowPropertyExists("Notification"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // Notification API.
- EXPECT_EQ(checkWindowPropertyExists("WebXRSystem"_s), false); // WebXR (currently always disabled).
- EXPECT_EQ(checkWindowPropertyExists("AudioContext"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // WebAudio.
- EXPECT_EQ(checkWindowPropertyExists("RTCPeerConnection"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // WebRTC Peer Connection.
</del><ins>+ EXPECT_EQ(runJSCheck("!!window.WebGL2RenderingContext"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // WebGL2.
+ EXPECT_EQ(runJSCheck("!!window.Gamepad"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // Gamepad API.
+ EXPECT_EQ(runJSCheck("!!window.RemotePlayback"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // Remote Playback.
+ EXPECT_EQ(runJSCheck("!!window.FileSystemHandle"_s), isShowingInitialEmptyDocument != IsShowingInitialEmptyDocument::Yes && shouldBeEnabled == ShouldBeEnabled::Yes); // File System Access.
+ EXPECT_EQ(runJSCheck("!!window.EnterPictureInPictureEvent"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // Picture in Picture API.
+ EXPECT_EQ(runJSCheck("!!window.SpeechRecognitionEvent"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // Speech recognition.
+ EXPECT_EQ(runJSCheck("!!window.Notification"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // Notification API.
+ EXPECT_EQ(runJSCheck("!!window.WebXRSystem"_s), false); // WebXR (currently always disabled).
+ EXPECT_EQ(runJSCheck("!!window.AudioContext"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // WebAudio.
+ EXPECT_EQ(runJSCheck("!!window.RTCPeerConnection"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // WebRTC Peer Connection.
+ EXPECT_EQ(runJSCheck("!!navigator.mediaDevices"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // GetUserMedia (Media Capture).
+ EXPECT_EQ(runJSCheck("!!navigator.getUserMedia"_s), false); // Legacy GetUserMedia (currently always disabled).
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> TEST(ProcessSwap, NavigatingToCaptivePortalMode)
</span><span class="cx"> {
</span><del>- auto webView = adoptNS([WKWebView new]);
</del><ins>+ auto webViewConfiguration = adoptNS([WKWebViewConfiguration new]);
+ EXPECT_FALSE(webViewConfiguration.get().defaultWebpagePreferences.captivePortalModeEnabled);
+ [webViewConfiguration.get().preferences _setMediaDevicesEnabled:YES];
+ webViewConfiguration.get().preferences._mediaCaptureRequiresSecureConnection = NO;
+
+ auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
</ins><span class="cx"> auto delegate = adoptNS([TestNavigationDelegate new]);
</span><span class="cx"> [webView setNavigationDelegate:delegate.get()];
</span><span class="cx">
</span><span class="lines">@@ -7716,6 +7723,8 @@
</span><span class="cx"> auto webViewConfiguration = adoptNS([WKWebViewConfiguration new]);
</span><span class="cx"> EXPECT_FALSE(webViewConfiguration.get().defaultWebpagePreferences.captivePortalModeEnabled);
</span><span class="cx"> webViewConfiguration.get().defaultWebpagePreferences.captivePortalModeEnabled = YES;
</span><ins>+ [webViewConfiguration.get().preferences _setMediaDevicesEnabled:YES];
+ webViewConfiguration.get().preferences._mediaCaptureRequiresSecureConnection = NO;
</ins><span class="cx">
</span><span class="cx"> auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
</span><span class="cx"> auto delegate = adoptNS([TestNavigationDelegate new]);
</span><span class="lines">@@ -7769,7 +7778,10 @@
</span><span class="cx"> checkSettingsControlledByCaptivePortalMode(webView.get(), ShouldBeEnabled::Yes);
</span><span class="cx">
</span><span class="cx"> // captive portal mode should be disabled in new WebViews since it is not enabled globally.
</span><del>- auto webView2 = adoptNS([WKWebView new]);
</del><ins>+ auto webViewConfiguration2 = adoptNS([WKWebViewConfiguration new]);
+ [webViewConfiguration2.get().preferences _setMediaDevicesEnabled:YES];
+ webViewConfiguration2.get().preferences._mediaCaptureRequiresSecureConnection = NO;
+ auto webView2 = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration2.get()]);
</ins><span class="cx"> [webView2 setNavigationDelegate:delegate.get()];
</span><span class="cx"> EXPECT_TRUE(isJITEnabled(webView2.get()));
</span><span class="cx"> checkSettingsControlledByCaptivePortalMode(webView2.get(), ShouldBeEnabled::Yes, IsShowingInitialEmptyDocument::Yes);
</span></span></pre>
</div>
</div>
</body>
</html>