Title: [291443] trunk
Revision
291443
Author
bfulg...@apple.com
Date
2022-03-17 14:28:57 -0700 (Thu, 17 Mar 2022)

Log Message

Disable push features in CaptivePortal mode
https://bugs.webkit.org/show_bug.cgi?id=237981
<rdar://88897228>

Reviewed by Chris Dumez.

We should not support push features when running in a Captive Portal.

Source/WebKit:

Tests: TestWebKitAPI

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (291442 => 291443)


--- trunk/Source/WebKit/ChangeLog	2022-03-17 21:21:22 UTC (rev 291442)
+++ trunk/Source/WebKit/ChangeLog	2022-03-17 21:28:57 UTC (rev 291443)
@@ -1,3 +1,18 @@
+2022-03-17  Brent Fulgham  <bfulg...@apple.com>
+
+        Disable push features in CaptivePortal mode 
+        https://bugs.webkit.org/show_bug.cgi?id=237981
+        <rdar://88897228>
+
+        Reviewed by Chris Dumez.
+
+        We should not support push features when running in a Captive Portal.
+
+        Tests: TestWebKitAPI
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences):
+
 2022-03-17  Commit Queue  <commit-qu...@webkit.org>
 
         Unreviewed, reverting r290835.

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (291442 => 291443)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2022-03-17 21:21:22 UTC (rev 291442)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2022-03-17 21:28:57 UTC (rev 291443)
@@ -4096,6 +4096,9 @@
 #if ENABLE(NOTIFICATIONS)
         settings.setNotificationsEnabled(false);
 #endif
+#if ENABLE(SERVICE_WORKER)
+        settings.setPushAPIEnabled(false);
+#endif
 #if ENABLE(WEBXR)
         settings.setWebXREnabled(false);
         settings.setWebXRAugmentedRealityModuleEnabled(false);

Modified: trunk/Tools/ChangeLog (291442 => 291443)


--- trunk/Tools/ChangeLog	2022-03-17 21:21:22 UTC (rev 291442)
+++ trunk/Tools/ChangeLog	2022-03-17 21:28:57 UTC (rev 291443)
@@ -1,3 +1,15 @@
+2022-03-17  Brent Fulgham  <bfulg...@apple.com>
+
+        Disable push features in CaptivePortal mode 
+        https://bugs.webkit.org/show_bug.cgi?id=237981
+        <rdar://88897228>
+
+        Reviewed by Chris Dumez.
+
+        We should not support push features when running in a Captive Portal.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
+
 2022-03-17  Jonathan Bedard  <jbed...@apple.com>
 
         [Merge-Queue] Remove merge-queue labels when blocking PR

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm (291442 => 291443)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm	2022-03-17 21:21:22 UTC (rev 291442)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm	2022-03-17 21:28:57 UTC (rev 291443)
@@ -7832,6 +7832,9 @@
     EXPECT_EQ(runJSCheck("!!navigator.getUserMedia"_s), false); // Legacy GetUserMedia (currently always disabled).
     EXPECT_EQ(runJSCheck("!!window.MathMLElement"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // MathML.
     EXPECT_EQ(runJSCheck("!!window.MathMLMathElement"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // MathML.
+    EXPECT_EQ(runJSCheck("!!window.PushManager"_s), isShowingInitialEmptyDocument != IsShowingInitialEmptyDocument::Yes && shouldBeEnabled == ShouldBeEnabled::Yes); // Push API.
+    EXPECT_EQ(runJSCheck("!!window.PushSubscription"_s), isShowingInitialEmptyDocument != IsShowingInitialEmptyDocument::Yes && shouldBeEnabled == ShouldBeEnabled::Yes); // Push API.
+    EXPECT_EQ(runJSCheck("!!window.PushSubscriptionOptions"_s), isShowingInitialEmptyDocument != IsShowingInitialEmptyDocument::Yes && shouldBeEnabled == ShouldBeEnabled::Yes); // Push API.
     String mathMLCheck = makeString("document.createElementNS('http://www.w3.org/1998/Math/MathML','mspace').__proto__ == ", shouldBeEnabled == ShouldBeEnabled::Yes ? "MathMLElement" : "Element", ".prototype");
     EXPECT_EQ(runJSCheck(mathMLCheck), true); // MathML.
 }
@@ -7849,6 +7852,19 @@
 
 @end
 
+void configureCaptivePortalWKWebViewConfiguration(WKWebViewConfiguration *config)
+{
+    [config.preferences _setMediaDevicesEnabled:YES];
+    config.preferences._mediaCaptureRequiresSecureConnection = NO;
+    [config.preferences _setNotificationsEnabled:YES];
+
+    for (_WKExperimentalFeature *feature in [WKPreferences _experimentalFeatures]) {
+        if ([feature.key isEqualToString:@"PushAPIEnabled"]) {
+            [config.preferences _setEnabled:YES forFeature:feature];
+        }
+    }
+}
+
 TEST(ProcessSwap, NavigatingToCaptivePortalMode)
 {
     auto messageHandler = adoptNS([[CaptivePortalMessageHandler alloc] init]);
@@ -7855,8 +7871,7 @@
 
     auto webViewConfiguration = adoptNS([WKWebViewConfiguration new]);
     EXPECT_FALSE(webViewConfiguration.get().defaultWebpagePreferences._captivePortalModeEnabled);
-    [webViewConfiguration.get().preferences _setMediaDevicesEnabled:YES];
-    webViewConfiguration.get().preferences._mediaCaptureRequiresSecureConnection = NO;
+    configureCaptivePortalWKWebViewConfiguration(webViewConfiguration.get());
     [webViewConfiguration.get().userContentController addScriptMessageHandler:messageHandler.get() name:@"testHandler"];
 
     auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
@@ -7986,9 +8001,8 @@
 {
     auto webViewConfiguration = adoptNS([WKWebViewConfiguration new]);
     EXPECT_FALSE(webViewConfiguration.get().defaultWebpagePreferences._captivePortalModeEnabled);
+    configureCaptivePortalWKWebViewConfiguration(webViewConfiguration.get());
     [webViewConfiguration.get().defaultWebpagePreferences _setCaptivePortalModeEnabled:YES];
-    [webViewConfiguration.get().preferences _setMediaDevicesEnabled:YES];
-    webViewConfiguration.get().preferences._mediaCaptureRequiresSecureConnection = NO;
 
     auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
     auto delegate = adoptNS([TestNavigationDelegate new]);
@@ -8031,9 +8045,8 @@
 {
     auto webViewConfiguration = adoptNS([WKWebViewConfiguration new]);
     EXPECT_FALSE(webViewConfiguration.get().defaultWebpagePreferences._captivePortalModeEnabled);
+    configureCaptivePortalWKWebViewConfiguration(webViewConfiguration.get());
     [webViewConfiguration.get().defaultWebpagePreferences _setCaptivePortalModeEnabled:YES];
-    [webViewConfiguration.get().preferences _setMediaDevicesEnabled:YES];
-    webViewConfiguration.get().preferences._mediaCaptureRequiresSecureConnection = NO;
 
     auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
     auto delegate = adoptNS([TestNavigationDelegate new]);
@@ -8088,8 +8101,8 @@
 
     // captive portal mode should be disabled in new WebViews since it is not enabled globally.
     auto webViewConfiguration2 = adoptNS([WKWebViewConfiguration new]);
-    [webViewConfiguration2.get().preferences _setMediaDevicesEnabled:YES];
-    webViewConfiguration2.get().preferences._mediaCaptureRequiresSecureConnection = NO;
+    configureCaptivePortalWKWebViewConfiguration(webViewConfiguration2.get());
+    EXPECT_TRUE([webViewConfiguration2.get().defaultWebpagePreferences _captivePortalModeEnabled] == NO);
     auto webView2 = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration2.get()]);
     [webView2 setNavigationDelegate:delegate.get()];
     EXPECT_TRUE(isJITEnabled(webView2.get()));
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to