⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 285717 in webkit


Ignore:
Timestamp:
Nov 12, 2021, 6:57:30 AM (5 years ago)
Author:
Chris Dumez
Message:

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:
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r285709 r285717  
     12021-11-12  Chris Dumez  <cdumez@apple.com>
     2
     3        Disable getUserMedia() when in Captive Portal Mode
     4        https://bugs.webkit.org/show_bug.cgi?id=233021
     5
     6        Reviewed by Brent Fulgham.
     7
     8        Disable getUserMedia() when in Captive Portal Mode.
     9
     10        No new tests, covered by updated API test.
     11
     12        * WebProcess/WebPage/WebPage.cpp:
     13        (WebKit::WebPage::updatePreferences):
     14
    1152021-11-11  Sergio Villar Senin  <svillar@igalia.com>
    216
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp

    r285655 r285717  
    40654065        settings.setWebXRAugmentedRealityModuleEnabled(false);
    40664066#endif
     4067#if ENABLE(MEDIA_STREAM)
     4068        settings.setMediaDevicesEnabled(false);
     4069#endif
    40674070#if ENABLE(WEB_AUDIO)
    40684071        settings.setWebAudioEnabled(false);
  • trunk/Tools/ChangeLog

    r285698 r285717  
     12021-11-12  Chris Dumez  <cdumez@apple.com>
     2
     3        Disable getUserMedia() when in Captive Portal Mode
     4        https://bugs.webkit.org/show_bug.cgi?id=233021
     5
     6        Reviewed by Brent Fulgham.
     7
     8        Add API test coverage.
     9
     10        * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
     11
    1122021-11-11  Brent Fulgham  <bfulgham@apple.com>
    213
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm

    r285672 r285717  
    76477647static void checkSettingsControlledByCaptivePortalMode(WKWebView *webView, ShouldBeEnabled shouldBeEnabled, IsShowingInitialEmptyDocument isShowingInitialEmptyDocument = IsShowingInitialEmptyDocument::No)
    76487648{
    7649     auto checkWindowPropertyExists = [&](ASCIILiteral property) -> bool {
     7649    auto runJSCheck = [&](const String& js) -> bool {
    76507650        bool finishedRunningScript = false;
    7651         bool propertyExists = false;
    7652         [webView evaluateJavaScript:makeString("!!window.", property) completionHandler:[&] (id result, NSError *error) {
     7651        bool checkResult = false;
     7652        [webView evaluateJavaScript:js completionHandler:[&] (id result, NSError *error) {
    76537653            EXPECT_NULL(error);
    7654             propertyExists = [result boolValue];
     7654            checkResult = [result boolValue];
    76557655            finishedRunningScript = true;
    76567656        }];
    76577657        TestWebKitAPI::Util::run(&finishedRunningScript);
    7658         return propertyExists;
     7658        return checkResult;
    76597659    };
    76607660
    7661     EXPECT_EQ(checkWindowPropertyExists("WebGL2RenderingContext"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // WebGL2.
    7662     EXPECT_EQ(checkWindowPropertyExists("Gamepad"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // Gamepad API.
    7663     EXPECT_EQ(checkWindowPropertyExists("RemotePlayback"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // Remote Playback.
    7664     EXPECT_EQ(checkWindowPropertyExists("FileSystemHandle"_s), isShowingInitialEmptyDocument != IsShowingInitialEmptyDocument::Yes && shouldBeEnabled == ShouldBeEnabled::Yes); // File System Access.
    7665     EXPECT_EQ(checkWindowPropertyExists("EnterPictureInPictureEvent"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // Picture in Picture API.
    7666     EXPECT_EQ(checkWindowPropertyExists("SpeechRecognitionEvent"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // Speech recognition.
    7667     EXPECT_EQ(checkWindowPropertyExists("Notification"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // Notification API.
    7668     EXPECT_EQ(checkWindowPropertyExists("WebXRSystem"_s), false); // WebXR (currently always disabled).
    7669     EXPECT_EQ(checkWindowPropertyExists("AudioContext"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // WebAudio.
    7670     EXPECT_EQ(checkWindowPropertyExists("RTCPeerConnection"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // WebRTC Peer Connection.
     7661    EXPECT_EQ(runJSCheck("!!window.WebGL2RenderingContext"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // WebGL2.
     7662    EXPECT_EQ(runJSCheck("!!window.Gamepad"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // Gamepad API.
     7663    EXPECT_EQ(runJSCheck("!!window.RemotePlayback"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // Remote Playback.
     7664    EXPECT_EQ(runJSCheck("!!window.FileSystemHandle"_s), isShowingInitialEmptyDocument != IsShowingInitialEmptyDocument::Yes && shouldBeEnabled == ShouldBeEnabled::Yes); // File System Access.
     7665    EXPECT_EQ(runJSCheck("!!window.EnterPictureInPictureEvent"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // Picture in Picture API.
     7666    EXPECT_EQ(runJSCheck("!!window.SpeechRecognitionEvent"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // Speech recognition.
     7667    EXPECT_EQ(runJSCheck("!!window.Notification"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // Notification API.
     7668    EXPECT_EQ(runJSCheck("!!window.WebXRSystem"_s), false); // WebXR (currently always disabled).
     7669    EXPECT_EQ(runJSCheck("!!window.AudioContext"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // WebAudio.
     7670    EXPECT_EQ(runJSCheck("!!window.RTCPeerConnection"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // WebRTC Peer Connection.
     7671    EXPECT_EQ(runJSCheck("!!navigator.mediaDevices"_s), shouldBeEnabled == ShouldBeEnabled::Yes); // GetUserMedia (Media Capture).
     7672    EXPECT_EQ(runJSCheck("!!navigator.getUserMedia"_s), false); // Legacy GetUserMedia (currently always disabled).
    76717673}
    76727674
    76737675TEST(ProcessSwap, NavigatingToCaptivePortalMode)
    76747676{
    7675     auto webView = adoptNS([WKWebView new]);
     7677    auto webViewConfiguration = adoptNS([WKWebViewConfiguration new]);
     7678    EXPECT_FALSE(webViewConfiguration.get().defaultWebpagePreferences.captivePortalModeEnabled);
     7679    [webViewConfiguration.get().preferences _setMediaDevicesEnabled:YES];
     7680    webViewConfiguration.get().preferences._mediaCaptureRequiresSecureConnection = NO;
     7681
     7682    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
    76767683    auto delegate = adoptNS([TestNavigationDelegate new]);
    76777684    [webView setNavigationDelegate:delegate.get()];
     
    77177724    EXPECT_FALSE(webViewConfiguration.get().defaultWebpagePreferences.captivePortalModeEnabled);
    77187725    webViewConfiguration.get().defaultWebpagePreferences.captivePortalModeEnabled = YES;
     7726    [webViewConfiguration.get().preferences _setMediaDevicesEnabled:YES];
     7727    webViewConfiguration.get().preferences._mediaCaptureRequiresSecureConnection = NO;
    77197728
    77207729    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
     
    77707779
    77717780    // captive portal mode should be disabled in new WebViews since it is not enabled globally.
    7772     auto webView2 = adoptNS([WKWebView new]);
     7781    auto webViewConfiguration2 = adoptNS([WKWebViewConfiguration new]);
     7782    [webViewConfiguration2.get().preferences _setMediaDevicesEnabled:YES];
     7783    webViewConfiguration2.get().preferences._mediaCaptureRequiresSecureConnection = NO;
     7784    auto webView2 = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration2.get()]);
    77737785    [webView2 setNavigationDelegate:delegate.get()];
    77747786    EXPECT_TRUE(isJITEnabled(webView2.get()));
Note: See TracChangeset for help on using the changeset viewer.