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

Changeset 285873 in webkit


Ignore:
Timestamp:
Nov 16, 2021, 10:27:57 AM (5 years ago)
Author:
Chris Dumez
Message:

[iOS] Do not require the web browser entitlement to opt into captive portal mode
https://bugs.webkit.org/show_bug.cgi?id=233191

Reviewed by Brent Fulgham.

Source/WebKit:

Do not require the web browser entitlement to opt into captive portal mode on iOS, only require
it to opt out.

  • UIProcess/API/Cocoa/WKWebpagePreferences.mm:

(-[WKWebpagePreferences _setCaptivePortalModeEnabled:]):

Tools:

Update API test coverage accordingly.

  • TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r285869 r285873  
     12021-11-16  Chris Dumez  <cdumez@apple.com>
     2
     3        [iOS] Do not require the web browser entitlement to opt into captive portal mode
     4        https://bugs.webkit.org/show_bug.cgi?id=233191
     5
     6        Reviewed by Brent Fulgham.
     7
     8        Do not require the web browser entitlement to opt into captive portal mode on iOS, only require
     9        it to opt out.
     10
     11        * UIProcess/API/Cocoa/WKWebpagePreferences.mm:
     12        (-[WKWebpagePreferences _setCaptivePortalModeEnabled:]):
     13
    1142021-11-16  Per Arne Vollan <pvollan@apple.com>
    215
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm

    r285739 r285873  
    394394- (void)_setCaptivePortalModeEnabled:(BOOL)captivePortalModeEnabled
    395395{
     396    if (_websitePolicies->captivePortalModeEnabled() == captivePortalModeEnabled)
     397        return;
     398
    396399#if PLATFORM(IOS_FAMILY)
    397     if (!WTF::processHasEntitlement("com.apple.developer.web-browser"))
    398         return;
    399 #endif
     400    // On iOS, the web browser entitlement is required to disable captive portal mode.
     401    if (!captivePortalModeEnabled && !WTF::processHasEntitlement("com.apple.developer.web-browser"))
     402        [NSException raise:NSInternalInconsistencyException format:@"The 'com.apple.developer.web-browser' restricted entitlement is required to disable captive portal mode"];
     403#endif
     404
    400405    _websitePolicies->setCaptivePortalModeEnabled(!!captivePortalModeEnabled);
    401406}
  • trunk/Tools/ChangeLog

    r285872 r285873  
     12021-11-16  Chris Dumez  <cdumez@apple.com>
     2
     3        [iOS] Do not require the web browser entitlement to opt into captive portal mode
     4        https://bugs.webkit.org/show_bug.cgi?id=233191
     5
     6        Reviewed by Brent Fulgham.
     7
     8        Update API test coverage accordingly.
     9
     10        * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
     11
    1122021-11-16  Andres Gonzalez  <andresg_22@apple.com>
    213
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm

    r285739 r285873  
    76277627}
    76287628
    7629 // On iOS, toggling the captive portal mode requires the browser entitlement, which TestWebKit API doesn't have.
    7630 // Also, some API tests rely on the browser entitlement not being present.
    7631 #if !PLATFORM(IOS)
    7632 
    76337629static bool isJITEnabled(WKWebView *webView)
    76347630{
     
    77247720}
    77257721
     7722#if PLATFORM(IOS)
     7723
     7724TEST(ProcessSwap, CannotDisableCaptivePortalModeWithoutBrowserEntitlement)
     7725{
     7726    auto webViewConfiguration = adoptNS([WKWebViewConfiguration new]);
     7727    EXPECT_FALSE(webViewConfiguration.get().defaultWebpagePreferences._captivePortalModeEnabled);
     7728    [webViewConfiguration.get().defaultWebpagePreferences _setCaptivePortalModeEnabled:YES];
     7729    [webViewConfiguration.get().preferences _setMediaDevicesEnabled:YES];
     7730    webViewConfiguration.get().preferences._mediaCaptureRequiresSecureConnection = NO;
     7731
     7732    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
     7733    auto delegate = adoptNS([TestNavigationDelegate new]);
     7734    [webView setNavigationDelegate:delegate.get()];
     7735
     7736    EXPECT_FALSE(isJITEnabled(webView.get()));
     7737    checkSettingsControlledByCaptivePortalMode(webView.get(), ShouldBeEnabled::No, IsShowingInitialEmptyDocument::Yes);
     7738    pid_t pid1 = [webView _webProcessIdentifier];
     7739
     7740    __block bool finishedNavigation = false;
     7741    delegate.get().didFinishNavigation = ^(WKWebView *, WKNavigation *) {
     7742        finishedNavigation = true;
     7743    };
     7744
     7745    delegate.get().decidePolicyForNavigationActionWithPreferences = ^(WKNavigationAction *action, WKWebpagePreferences *preferences, void (^completionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) {
     7746        EXPECT_TRUE(preferences._captivePortalModeEnabled);
     7747        bool didThrowWhenTryingToDisableCaptivePortalMode = false;
     7748        // TestWebKitAPI doesn't have the web browser entitlement and thus shouldn't be able to disable captive portal mode.
     7749        @try {
     7750            [preferences _setCaptivePortalModeEnabled:NO];
     7751        } @catch (NSException *exception) {
     7752            didThrowWhenTryingToDisableCaptivePortalMode = true;
     7753        }
     7754        EXPECT_TRUE(didThrowWhenTryingToDisableCaptivePortalMode);
     7755        completionHandler(WKNavigationActionPolicyAllow, preferences);
     7756    };
     7757
     7758    NSURL *url = [[NSBundle mainBundle] URLForResource:@"simple" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
     7759    [webView loadRequest:[NSURLRequest requestWithURL:url]];
     7760    TestWebKitAPI::Util::run(&finishedNavigation);
     7761
     7762    EXPECT_EQ(pid1, [webView _webProcessIdentifier]); // Shouldn't have process-swapped since we're staying in captive portal mode.
     7763    EXPECT_FALSE(isJITEnabled(webView.get()));
     7764    checkSettingsControlledByCaptivePortalMode(webView.get(), ShouldBeEnabled::No);
     7765}
     7766
     7767#else
     7768
    77267769TEST(ProcessSwap, CaptivePortalModeEnabledByDefaultThenOptOut)
    77277770{
Note: See TracChangeset for help on using the changeset viewer.