<!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>[285634] 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/285634">285634</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2021-11-11 09:18:22 -0800 (Thu, 11 Nov 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Turn off various preferences when in captive portal mode
https://bugs.webkit.org/show_bug.cgi?id=232958
<rdar://84622396>

Reviewed by Brent Fulgham.

Source/WebKit:

Disable the following settings when in captive portal mode:
- WebGL
- WebGL2
- Gamepads
- RemotePlayback
- FileSystemAccess
- AllowsPictureInPictureMediaPlayback
- PictureInPictureAPI
- SpeechRecognition
- Notifications
- WebXR
- WebXRAugmentedRealityModule
- WebAudio
- DownloadableBinaryFonts
- PeerConnection (WebRTC)

Covered by updated API tests.

* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::encode const):
(WebKit::WebProcessCreationParameters::decode):
* Shared/WebProcessCreationParameters.h:
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::initializeNewWebProcess):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::initializeWebProcess):
* WebProcess/WebProcess.h:
(WebKit::WebProcess::isCaptivePortalModeEnabled const):

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="#trunkSourceWebKitSharedWebProcessCreationParameterscpp">trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp</a></li>
<li><a href="#trunkSourceWebKitSharedWebProcessCreationParametersh">trunk/Source/WebKit/Shared/WebProcessCreationParameters.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessWebProcessPoolcpp">trunk/Source/WebKit/UIProcess/WebProcessPool.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageWebPagecpp">trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebProcesscpp">trunk/Source/WebKit/WebProcess/WebProcess.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebProcessh">trunk/Source/WebKit/WebProcess/WebProcess.h</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 (285633 => 285634)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2021-11-11 16:10:08 UTC (rev 285633)
+++ trunk/Source/WebKit/ChangeLog       2021-11-11 17:18:22 UTC (rev 285634)
</span><span class="lines">@@ -1,3 +1,42 @@
</span><ins>+2021-11-11  Chris Dumez  <cdumez@apple.com>
+
+        Turn off various preferences when in captive portal mode
+        https://bugs.webkit.org/show_bug.cgi?id=232958
+        <rdar://84622396>
+
+        Reviewed by Brent Fulgham.
+
+        Disable the following settings when in captive portal mode:
+        - WebGL
+        - WebGL2
+        - Gamepads
+        - RemotePlayback
+        - FileSystemAccess
+        - AllowsPictureInPictureMediaPlayback
+        - PictureInPictureAPI
+        - SpeechRecognition
+        - Notifications
+        - WebXR
+        - WebXRAugmentedRealityModule
+        - WebAudio
+        - DownloadableBinaryFonts
+        - PeerConnection (WebRTC)
+
+        Covered by updated API tests.
+
+        * Shared/WebProcessCreationParameters.cpp:
+        (WebKit::WebProcessCreationParameters::encode const):
+        (WebKit::WebProcessCreationParameters::decode):
+        * Shared/WebProcessCreationParameters.h:
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::initializeNewWebProcess):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences):
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::initializeWebProcess):
+        * WebProcess/WebProcess.h:
+        (WebKit::WebProcess::isCaptivePortalModeEnabled const):
+
</ins><span class="cx"> 2021-11-11  Per Arne Vollan <pvollan@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [macOS][GPUP] Allow access to power logging service
</span></span></pre></div>
<a id="trunkSourceWebKitSharedWebProcessCreationParameterscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp (285633 => 285634)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp      2021-11-11 16:10:08 UTC (rev 285633)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp 2021-11-11 17:18:22 UTC (rev 285634)
</span><span class="lines">@@ -123,6 +123,7 @@
</span><span class="cx">     encoder << attrStyleEnabled;
</span><span class="cx">     encoder << shouldThrowExceptionForGlobalConstantRedeclaration;
</span><span class="cx">     encoder << crossOriginMode;
</span><ins>+    encoder << isCaptivePortalModeEnabled;
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(SERVICE_CONTROLS)
</span><span class="cx">     encoder << hasImageServices;
</span><span class="lines">@@ -400,6 +401,8 @@
</span><span class="cx">         return false;
</span><span class="cx">     if (!decoder.decode(parameters.crossOriginMode))
</span><span class="cx">         return false;
</span><ins>+    if (!decoder.decode(parameters.isCaptivePortalModeEnabled))
+        return false;
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(SERVICE_CONTROLS)
</span><span class="cx">     if (!decoder.decode(parameters.hasImageServices))
</span></span></pre></div>
<a id="trunkSourceWebKitSharedWebProcessCreationParametersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.h (285633 => 285634)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.h        2021-11-11 16:10:08 UTC (rev 285633)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.h   2021-11-11 17:18:22 UTC (rev 285634)
</span><span class="lines">@@ -133,6 +133,7 @@
</span><span class="cx">     bool attrStyleEnabled { false };
</span><span class="cx">     bool shouldThrowExceptionForGlobalConstantRedeclaration { true };
</span><span class="cx">     WebCore::CrossOriginMode crossOriginMode { WebCore::CrossOriginMode::Shared }; // Cross-origin isolation via COOP+COEP headers.
</span><ins>+    bool isCaptivePortalModeEnabled { false };
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(SERVICE_CONTROLS)
</span><span class="cx">     bool hasImageServices { false };
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWebProcessPoolcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (285633 => 285634)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2021-11-11 16:10:08 UTC (rev 285633)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp    2021-11-11 17:18:22 UTC (rev 285634)
</span><span class="lines">@@ -830,6 +830,7 @@
</span><span class="cx">     parameters.attrStyleEnabled = m_configuration->attrStyleEnabled();
</span><span class="cx">     parameters.shouldThrowExceptionForGlobalConstantRedeclaration = m_configuration->shouldThrowExceptionForGlobalConstantRedeclaration();
</span><span class="cx">     parameters.crossOriginMode = process.crossOriginMode();
</span><ins>+    parameters.isCaptivePortalModeEnabled = process.captivePortalMode() == WebProcessProxy::CaptivePortalMode::Enabled;
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(SERVICE_CONTROLS)
</span><span class="cx">     auto& serviceController = ServicesController::singleton();
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (285633 => 285634)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp       2021-11-11 16:10:08 UTC (rev 285633)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp  2021-11-11 17:18:22 UTC (rev 285634)
</span><span class="lines">@@ -4041,6 +4041,39 @@
</span><span class="cx">     PlatformMediaSessionManager::setOpusDecoderEnabled(RuntimeEnabledFeatures::sharedFeatures().opusDecoderEnabled());
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    if (WebProcess::singleton().isCaptivePortalModeEnabled()) {
+        settings.setWebGLEnabled(false);
+#if ENABLE(WEBGL2)
+        settings.setWebGL2Enabled(false);
+#endif
+#if ENABLE(GAMEPAD)
+        settings.setGamepadsEnabled(false);
+#endif
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+        settings.setRemotePlaybackEnabled(false);
+#endif
+        settings.setFileSystemAccessEnabled(false);
+        settings.setAllowsPictureInPictureMediaPlayback(false);
+#if ENABLE(PICTURE_IN_PICTURE_API)
+        settings.setPictureInPictureAPIEnabled(false);
+#endif
+        settings.setSpeechRecognitionEnabled(false);
+#if ENABLE(NOTIFICATIONS)
+        settings.setNotificationsEnabled(false);
+#endif
+#if ENABLE(WEBXR)
+        settings.setWebXREnabled(false);
+        settings.setWebXRAugmentedRealityModuleEnabled(false);
+#endif
+#if ENABLE(WEB_AUDIO)
+        settings.setWebAudioEnabled(false);
+#endif
+        settings.setDownloadableBinaryFontsEnabled(false);
+#if ENABLE(WEB_RTC)
+        settings.setPeerConnectionEnabled(false);
+#endif
+    }
+
</ins><span class="cx">     m_page->settingsDidChange();
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebProcesscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebProcess.cpp (285633 => 285634)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebProcess.cpp    2021-11-11 16:10:08 UTC (rev 285633)
+++ trunk/Source/WebKit/WebProcess/WebProcess.cpp       2021-11-11 17:18:22 UTC (rev 285634)
</span><span class="lines">@@ -524,6 +524,7 @@
</span><span class="cx">     commonVM().setGlobalConstRedeclarationShouldThrow(parameters.shouldThrowExceptionForGlobalConstantRedeclaration);
</span><span class="cx"> 
</span><span class="cx">     ScriptExecutionContext::setCrossOriginMode(parameters.crossOriginMode);
</span><ins>+    m_isCaptivePortalModeEnabled = parameters.isCaptivePortalModeEnabled;
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(SERVICE_CONTROLS)
</span><span class="cx">     setEnabledServices(parameters.hasImageServices, parameters.hasSelectionServices, parameters.hasRichContentServices);
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebProcessh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebProcess.h (285633 => 285634)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebProcess.h      2021-11-11 16:10:08 UTC (rev 285633)
+++ trunk/Source/WebKit/WebProcess/WebProcess.h 2021-11-11 17:18:22 UTC (rev 285634)
</span><span class="lines">@@ -403,6 +403,8 @@
</span><span class="cx">     WebCore::AccessibilityAtspi& accessibilityAtspi() const { return *m_accessibility; }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    bool isCaptivePortalModeEnabled() const { return m_isCaptivePortalModeEnabled; }
+
</ins><span class="cx"> private:
</span><span class="cx">     WebProcess();
</span><span class="cx">     ~WebProcess();
</span><span class="lines">@@ -732,6 +734,7 @@
</span><span class="cx"> 
</span><span class="cx">     bool m_hasSuspendedPageProxy { false };
</span><span class="cx">     bool m_isSuspending { false };
</span><ins>+    bool m_isCaptivePortalModeEnabled { false };
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(MEDIA_STREAM) && ENABLE(SANDBOX_EXTENSIONS)
</span><span class="cx">     HashMap<String, RefPtr<SandboxExtension>> m_mediaCaptureSandboxExtensions;
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (285633 => 285634)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog    2021-11-11 16:10:08 UTC (rev 285633)
+++ trunk/Tools/ChangeLog       2021-11-11 17:18:22 UTC (rev 285634)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2021-11-11  Chris Dumez  <cdumez@apple.com>
+
+        Turn off various preferences when in captive portal mode
+        https://bugs.webkit.org/show_bug.cgi?id=232958
+        <rdar://84622396>
+
+        Reviewed by Brent Fulgham.
+
+        Add API test coverage.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
+
</ins><span class="cx"> 2021-11-11  Philippe Normand  <pnormand@igalia.com>
</span><span class="cx"> 
</span><span class="cx">         [Flatpak] http server is not properly tear down
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKitCocoaProcessSwapOnNavigationmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm (285633 => 285634)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm   2021-11-11 16:10:08 UTC (rev 285633)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm      2021-11-11 17:18:22 UTC (rev 285634)
</span><span class="lines">@@ -7638,6 +7638,34 @@
</span><span class="cx">     return isJITEnabledResult;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+enum class ShouldBeEnabled : bool { No, Yes };
+enum class IsShowingInitialEmptyDocument : bool { No, Yes };
+static void checkSettingsControlledByCaptivePortalMode(WKWebView *webView, ShouldBeEnabled shouldBeEnabled, IsShowingInitialEmptyDocument isShowingInitialEmptyDocument = IsShowingInitialEmptyDocument::No)
+{
+    auto checkWindowPropertyExists = [&](ASCIILiteral property) -> bool {
+        bool finishedRunningScript = false;
+        bool propertyExists = false;
+        [webView evaluateJavaScript:makeString("!!window.", property) completionHandler:[&] (id result, NSError *error) {
+            EXPECT_NULL(error);
+            propertyExists = [result boolValue];
+            finishedRunningScript = true;
+        }];
+        TestWebKitAPI::Util::run(&finishedRunningScript);
+        return propertyExists;
+    };
+
+    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.
+}
+
</ins><span class="cx"> TEST(ProcessSwap, NavigatingToCaptivePortalMode)
</span><span class="cx"> {
</span><span class="cx">     auto webView = adoptNS([WKWebView new]);
</span><span class="lines">@@ -7645,6 +7673,7 @@
</span><span class="cx">     [webView setNavigationDelegate:delegate.get()];
</span><span class="cx"> 
</span><span class="cx">     EXPECT_TRUE(isJITEnabled(webView.get()));
</span><ins>+    checkSettingsControlledByCaptivePortalMode(webView.get(), ShouldBeEnabled::Yes, IsShowingInitialEmptyDocument::Yes);
</ins><span class="cx"> 
</span><span class="cx">     __block bool finishedNavigation = false;
</span><span class="cx">     delegate.get().didFinishNavigation = ^(WKWebView *, WKNavigation *) {
</span><span class="lines">@@ -7659,6 +7688,7 @@
</span><span class="cx">     EXPECT_NE(pid1, 0);
</span><span class="cx"> 
</span><span class="cx">     EXPECT_TRUE(isJITEnabled(webView.get()));
</span><ins>+    checkSettingsControlledByCaptivePortalMode(webView.get(), ShouldBeEnabled::Yes);
</ins><span class="cx"> 
</span><span class="cx">     delegate.get().decidePolicyForNavigationActionWithPreferences = ^(WKNavigationAction *action, WKWebpagePreferences *preferences, void (^completionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) {
</span><span class="cx">         EXPECT_FALSE(preferences.captivePortalModeEnabled);
</span><span class="lines">@@ -7674,6 +7704,7 @@
</span><span class="cx">     // We should have process-swap for transitioning to captive portal mode.
</span><span class="cx">     EXPECT_NE(pid1, [webView _webProcessIdentifier]);
</span><span class="cx">     EXPECT_FALSE(isJITEnabled(webView.get()));
</span><ins>+    checkSettingsControlledByCaptivePortalMode(webView.get(), ShouldBeEnabled::No);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TEST(ProcessSwap, CaptivePortalModeEnabledByDefaultThenOptOut)
</span><span class="lines">@@ -7687,6 +7718,7 @@
</span><span class="cx">     [webView setNavigationDelegate:delegate.get()];
</span><span class="cx"> 
</span><span class="cx">     EXPECT_FALSE(isJITEnabled(webView.get()));
</span><ins>+    checkSettingsControlledByCaptivePortalMode(webView.get(), ShouldBeEnabled::No, IsShowingInitialEmptyDocument::Yes);
</ins><span class="cx">     pid_t pid1 = [webView _webProcessIdentifier];
</span><span class="cx"> 
</span><span class="cx">     __block bool finishedNavigation = false;
</span><span class="lines">@@ -7704,6 +7736,7 @@
</span><span class="cx">     TestWebKitAPI::Util::run(&finishedNavigation);
</span><span class="cx"> 
</span><span class="cx">     EXPECT_FALSE(isJITEnabled(webView.get()));
</span><ins>+    checkSettingsControlledByCaptivePortalMode(webView.get(), ShouldBeEnabled::No);
</ins><span class="cx">     EXPECT_EQ(pid1, [webView _webProcessIdentifier]);
</span><span class="cx"> 
</span><span class="cx">     finishedNavigation = false;
</span><span class="lines">@@ -7713,6 +7746,7 @@
</span><span class="cx"> 
</span><span class="cx">     EXPECT_EQ(pid1, [webView _webProcessIdentifier]); // Shouldn't have process-swapped since we're staying in captive portal mode.
</span><span class="cx">     EXPECT_FALSE(isJITEnabled(webView.get()));
</span><ins>+    checkSettingsControlledByCaptivePortalMode(webView.get(), ShouldBeEnabled::No);
</ins><span class="cx"> 
</span><span class="cx">     delegate.get().decidePolicyForNavigationActionWithPreferences = ^(WKNavigationAction *action, WKWebpagePreferences *preferences, void (^completionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) {
</span><span class="cx">         EXPECT_TRUE(preferences.captivePortalModeEnabled);
</span><span class="lines">@@ -7728,11 +7762,13 @@
</span><span class="cx">     // We should have process-swapped to get out of captive portal mode.
</span><span class="cx">     EXPECT_NE(pid1, [webView _webProcessIdentifier]);
</span><span class="cx">     EXPECT_TRUE(isJITEnabled(webView.get()));
</span><ins>+    checkSettingsControlledByCaptivePortalMode(webView.get(), ShouldBeEnabled::Yes);
</ins><span class="cx"> 
</span><span class="cx">     // captive portal mode should be disabled in new WebViews since it is not enabled globally.
</span><span class="cx">     auto webView2 = adoptNS([WKWebView new]);
</span><span class="cx">     [webView2 setNavigationDelegate:delegate.get()];
</span><span class="cx">     EXPECT_TRUE(isJITEnabled(webView2.get()));
</span><ins>+    checkSettingsControlledByCaptivePortalMode(webView2.get(), ShouldBeEnabled::Yes, IsShowingInitialEmptyDocument::Yes);
</ins><span class="cx">     pid_t pid2 = [webView2 _webProcessIdentifier];
</span><span class="cx"> 
</span><span class="cx">     delegate.get().decidePolicyForNavigationActionWithPreferences = nil;
</span><span class="lines">@@ -7742,5 +7778,6 @@
</span><span class="cx">     [webView2 loadRequest:[NSURLRequest requestWithURL:url]];
</span><span class="cx">     TestWebKitAPI::Util::run(&finishedNavigation);
</span><span class="cx">     EXPECT_TRUE(isJITEnabled(webView2.get()));
</span><ins>+    checkSettingsControlledByCaptivePortalMode(webView2.get(), ShouldBeEnabled::Yes);
</ins><span class="cx">     EXPECT_EQ(pid2, [webView2 _webProcessIdentifier]);
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>