Changeset 279755 in webkit


Ignore:
Timestamp:
Jul 8, 2021, 3:13:59 PM (4 years ago)
Author:
Brent Fulgham
Message:

[Cocoa] Expose SPI to opt out of Extensible SSO authentication
https://bugs.webkit.org/show_bug.cgi?id=227729
<rdar://problem/75647892>

Reviewed by Tim Horton.

Source/WebKit:

WKWebView clients should be able to disable Extensible SSO authentication flows, so exposing the internal
mechanism as SPI. This is especially important for use cases where a WKWebView will be used to load content
without being attached to a Window, since a Window is required to present the Extensible SSO authentication
UI. Without a Window, WebKit will wait for a Window to be attached causing loads to timeout. By adopting this
API, developers can opt out of Extensible SSO, allowing loads to fail quickly rather than waiting for a timeout.

Tested by a new TestWebKitAPI test case: SOAuthorizationRedirect.DisableSSO

  • UIProcess/API/Cocoa/WKPreferences.h:
  • UIProcess/API/Cocoa/WKPreferences.mm:

(-[WKPreferences _extensibleSSOEnabled]): Add getter for new preference.
(-[WKPreferences _setExtensibleSSOEnabled:]): Add setter.

  • UIProcess/Cocoa/SOAuthorization/NavigationSOAuthorizationSession.mm:

(WebKit::NavigationSOAuthorizationSession::shouldStartInternal): Add new logging so developers can see when a WKWebView
without a Window is attempting to participate in Extensible SSO flows.

  • UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.mm:

(WebKit::PopUpSOAuthorizationSession::initSecretWebView): Switch from SPI to API.

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::decidePolicyForNavigationAction): Ditto.

  • UIProcess/WebPageProxy.h:

Source/WTF:

Create new WKPreference to allow WebKit clients to opt out of Extensible SSO authentication.

  • Scripts/Preferences/WebPreferences.yaml:

Tools:

Add a new test to confirm that Extenstible SSO authentication flows are bypassed when the new WKPreference
is used. Updated other tests to confirm that the SSO delegate is called when expected.

  • TestWebKitAPI/Tests/WebKitCocoa/TestSOAuthorization.mm:

(-[TestSOAuthorizationDelegate _webView:decidePolicyForSOAuthorizationLoadWithCurrentPolicy:forExtension:completionHandler:]):
(resetState):
(TestWebKitAPI::TEST):

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r279680 r279755  
     12021-07-08  Brent Fulgham  <bfulgham@apple.com>
     2
     3        [Cocoa] Expose SPI to opt out of Extensible SSO authentication
     4        https://bugs.webkit.org/show_bug.cgi?id=227729
     5        <rdar://problem/75647892>
     6
     7        Reviewed by Tim Horton.
     8
     9        Create new WKPreference to allow WebKit clients to opt out of Extensible SSO authentication.
     10
     11        * Scripts/Preferences/WebPreferences.yaml:
     12
    1132021-07-07  Alex Christensen  <achristensen@webkit.org>
    214
  • trunk/Source/WTF/Scripts/Preferences/WebPreferences.yaml

    r277030 r279755  
    760760      default: false
    761761
     762ExtensibleSSOEnabled:
     763  type: bool
     764  getter: isExtensibleSSOEnabled
     765  webcoreBinding: none
     766  condition: HAVE(APP_SSO)
     767  exposed: [ WebKit ]
     768  defaultValue:
     769    WebKit:
     770      default: true
     771
    762772FTPDirectoryTemplatePath:
    763773  type: String
  • trunk/Source/WebKit/ChangeLog

    r279751 r279755  
     12021-07-08  Brent Fulgham  <bfulgham@apple.com>
     2
     3        [Cocoa] Expose SPI to opt out of Extensible SSO authentication
     4        https://bugs.webkit.org/show_bug.cgi?id=227729
     5        <rdar://problem/75647892>
     6
     7        Reviewed by Tim Horton.
     8
     9        WKWebView clients should be able to disable Extensible SSO authentication flows, so exposing the internal
     10        mechanism as SPI. This is especially important for use cases where a WKWebView will be used to load content
     11        without being attached to a Window, since a Window is required to present the Extensible SSO authentication
     12        UI. Without a Window, WebKit will wait for a Window to be attached causing loads to timeout. By adopting this
     13        API, developers can opt out of Extensible SSO, allowing loads to fail quickly rather than waiting for a timeout.
     14
     15        Tested by a new TestWebKitAPI test case: SOAuthorizationRedirect.DisableSSO
     16
     17        * UIProcess/API/Cocoa/WKPreferences.h:
     18        * UIProcess/API/Cocoa/WKPreferences.mm:
     19        (-[WKPreferences _extensibleSSOEnabled]): Add getter for new preference.
     20        (-[WKPreferences _setExtensibleSSOEnabled:]): Add setter.
     21        * UIProcess/Cocoa/SOAuthorization/NavigationSOAuthorizationSession.mm:
     22        (WebKit::NavigationSOAuthorizationSession::shouldStartInternal): Add new logging so developers can see when a WKWebView
     23        without a Window is attempting to participate in Extensible SSO flows.
     24        * UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.mm:
     25        (WebKit::PopUpSOAuthorizationSession::initSecretWebView): Switch from SPI to API.
     26        * UIProcess/WebPageProxy.cpp:
     27        (WebKit::WebPageProxy::decidePolicyForNavigationAction): Ditto.
     28        * UIProcess/WebPageProxy.h:
     29
    1302021-07-08  Wenson Hsieh  <wenson_hsieh@apple.com>
    231
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm

    r275910 r279755  
    14921492}
    14931493
     1494- (BOOL)_isExtensibleSSOEnabled
     1495{
     1496#if HAVE(APP_SSO)
     1497    return _preferences->isExtensibleSSOEnabled();
     1498#else
     1499    return false;
     1500#endif
     1501}
     1502
     1503- (void)_setExtensibleSSOEnabled:(BOOL)extensibleSSOEnabled
     1504{
     1505#if HAVE(APP_SSO)
     1506    _preferences->setExtensibleSSOEnabled(extensibleSSOEnabled);
     1507#endif
     1508}
     1509
    14941510@end
    14951511
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h

    r279089 r279755  
    172172@property (nonatomic, setter=_setPitchCorrectionAlgorithm:) _WKPitchCorrectionAlgorithm _pitchCorrectionAlgorithm WK_API_AVAILABLE(macos(12.0), ios(15.0));
    173173@property (nonatomic, setter=_setMediaSessionEnabled:) BOOL _mediaSessionEnabled WK_API_AVAILABLE(macos(12.0), ios(15.0));
     174@property (nonatomic, getter=_isExtensibleSSOEnabled, setter=_setExtensibleSSOEnabled:) BOOL _extensibleSSOEnabled WK_API_AVAILABLE(macos(12.0), ios(15.0));
     175
    174176
    175177#if !TARGET_OS_IPHONE
  • trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/NavigationSOAuthorizationSession.mm

    r279305 r279755  
    5858    beforeStart();
    5959    if (!page->isInWindow()) {
     60        AUTHORIZATIONSESSION_RELEASE_LOG("shouldStartInternal: Starting Extensible SSO authentication for a web view that is not attached to a window. Loading will pause until a window is attached.");
    6061        setState(State::Waiting);
    6162        page->addObserver(*this);
  • trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.mm

    r279305 r279755  
    190190    [m_secretWebView setNavigationDelegate:m_secretDelegate.get()];
    191191
    192     m_secretWebView->_page->setShouldSuppressSOAuthorizationInAllNavigationPolicyDecision();
     192    m_secretWebView->_page->preferences().setExtensibleSSOEnabled(false);
    193193    WTFLogAlways("SecretWebView is created.");
    194194}
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r279750 r279755  
    54345434    else {
    54355435#if HAVE(APP_SSO)
    5436         if (m_shouldSuppressSOAuthorizationInNextNavigationPolicyDecision || m_shouldSuppressSOAuthorizationInAllNavigationPolicyDecision)
     5436        if (m_shouldSuppressSOAuthorizationInNextNavigationPolicyDecision || !m_preferences->isExtensibleSSOEnabled())
    54375437            navigationAction->unsetShouldPerformSOAuthorization();
    54385438#endif
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r279750 r279755  
    17791779
    17801780#if HAVE(APP_SSO)
    1781     void setShouldSuppressSOAuthorizationInAllNavigationPolicyDecision() { m_shouldSuppressSOAuthorizationInAllNavigationPolicyDecision = true; }
    17821781    void setShouldSuppressSOAuthorizationInNextNavigationPolicyDecision() { m_shouldSuppressSOAuthorizationInNextNavigationPolicyDecision = true; }
    17831782    void decidePolicyForSOAuthorizationLoad(const String&, CompletionHandler<void(SOAuthorizationLoadPolicy)>&&);
     
    27332732#if HAVE(APP_SSO)
    27342733    bool m_shouldSuppressSOAuthorizationInNextNavigationPolicyDecision { false };
    2735     bool m_shouldSuppressSOAuthorizationInAllNavigationPolicyDecision { false };
    27362734#endif
    27372735
  • trunk/Tools/ChangeLog

    r279750 r279755  
     12021-07-08  Brent Fulgham  <bfulgham@apple.com>
     2
     3        [Cocoa] Expose SPI to opt out of Extensible SSO authentication
     4        https://bugs.webkit.org/show_bug.cgi?id=227729
     5        <rdar://problem/75647892>
     6
     7        Reviewed by Tim Horton.
     8
     9        Add a new test to confirm that Extenstible SSO authentication flows are bypassed when the new WKPreference
     10        is used. Updated other tests to confirm that the SSO delegate is called when expected.
     11
     12        * TestWebKitAPI/Tests/WebKitCocoa/TestSOAuthorization.mm:
     13        (-[TestSOAuthorizationDelegate _webView:decidePolicyForSOAuthorizationLoadWithCurrentPolicy:forExtension:completionHandler:]):
     14        (resetState):
     15        (TestWebKitAPI::TEST):
     16
    1172021-07-08  Kate Cheney  <katherine_cheney@apple.com>
    218
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/TestSOAuthorization.mm

    r273308 r279755  
    11/*
    2  * Copyright (C) 2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2019-2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3737#import <WebKit/WKNavigationDelegatePrivate.h>
    3838#import <WebKit/WKNavigationPrivate.h>
     39#import <WebKit/WKPreferencesPrivate.h>
    3940#import <WebKit/WKWebViewPrivate.h>
    4041#import <pal/cocoa/AppSSOSoftLink.h>
     
    4849
    4950static bool navigationCompleted = false;
     51static bool policyForAppSSOPerformed = false;
    5052static bool authorizationPerformed = false;
    5153static bool authorizationCancelled = false;
     
    194196    EXPECT_EQ(policy, _WKSOAuthorizationLoadPolicyAllow);
    195197    EXPECT_TRUE([extension isEqual:@"Test"]);
     198    policyForAppSSOPerformed = true;
    196199    if (!self.isAsyncExecution) {
    197200        if (self.allowSOAuthorizationLoad)
     
    328331{
    329332    navigationCompleted = false;
     333    policyForAppSSOPerformed = false;
    330334    authorizationPerformed = false;
    331335    authorizationCancelled = false;
     
    385389    Util::run(&navigationCompleted);
    386390
     391    EXPECT_FALSE(policyForAppSSOPerformed);
    387392    EXPECT_WK_STREQ(testURL.get().absoluteString, finalURL);
    388393}
    389394
     395TEST(SOAuthorizationRedirect, DisableSSO)
     396{
     397    resetState();
     398    ClassMethodSwizzler swizzler1(PAL::getSOAuthorizationClass(), @selector(canPerformAuthorizationWithURL:responseCode:), reinterpret_cast<IMP>(overrideCanPerformAuthorizationWithURL));
     399    InstanceMethodSwizzler swizzler2(PAL::getSOAuthorizationClass(), @selector(setDelegate:), reinterpret_cast<IMP>(overrideSetDelegate));
     400    InstanceMethodSwizzler swizzler3(PAL::getSOAuthorizationClass(), @selector(beginAuthorizationWithURL:httpHeaders:httpBody:), reinterpret_cast<IMP>(overrideBeginAuthorizationWithURL));
     401    InstanceMethodSwizzler swizzler4(PAL::getSOAuthorizationClass(), @selector(getAuthorizationHintsWithURL:responseCode:completion:), reinterpret_cast<IMP>(overrideGetAuthorizationHintsWithURL));
     402
     403    RetainPtr<NSURL> testURL = [[NSBundle mainBundle] URLForResource:@"simple" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
     404
     405    auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
     406    auto preferences = configuration.get().preferences;
     407    EXPECT_TRUE(preferences._isExtensibleSSOEnabled);
     408
     409    preferences._extensibleSSOEnabled = NO;
     410
     411    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500) configuration:configuration.get()]);
     412    auto delegate = adoptNS([[TestSOAuthorizationDelegate alloc] init]);
     413    configureSOAuthorizationWebView(webView.get(), delegate.get(), OpenExternalSchemesPolicy::Allow);
     414
     415    [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
     416    Util::run(&navigationCompleted);
     417
     418    EXPECT_FALSE(policyForAppSSOPerformed);
     419    EXPECT_WK_STREQ(testURL.get().absoluteString, finalURL);
     420}
     421
    390422TEST(SOAuthorizationRedirect, InterceptionError)
    391423{
     
    403435    Util::run(&navigationCompleted);
    404436
     437    EXPECT_TRUE(policyForAppSSOPerformed);
    405438    EXPECT_WK_STREQ(testURL.get().absoluteString, finalURL);
    406439}
     
    423456    Util::run(&authorizationPerformed);
    424457    checkAuthorizationOptions(false, "", 0);
     458    EXPECT_TRUE(policyForAppSSOPerformed);
    425459
    426460    [gDelegate authorizationDidNotHandle:gAuthorization];
     
    447481    Util::run(&authorizationPerformed);
    448482    checkAuthorizationOptions(false, "", 0);
     483    EXPECT_TRUE(policyForAppSSOPerformed);
    449484
    450485    [gDelegate authorizationDidCancel:gAuthorization];
     
    471506    Util::run(&authorizationPerformed);
    472507    checkAuthorizationOptions(false, "", 0);
     508    EXPECT_TRUE(policyForAppSSOPerformed);
    473509
    474510    [gDelegate authorizationDidComplete:gAuthorization];
     
    495531    Util::run(&authorizationPerformed);
    496532    checkAuthorizationOptions(false, "", 0);
     533    EXPECT_TRUE(policyForAppSSOPerformed);
    497534
    498535    [gDelegate authorization:gAuthorization didCompleteWithHTTPAuthorizationHeaders:adoptNS([[NSDictionary alloc] init]).get()];
     
    520557    Util::run(&authorizationPerformed);
    521558    checkAuthorizationOptions(false, "", 0);
     559    EXPECT_FALSE(policyForAppSSOPerformed); // The delegate isn't registered, so this won't be set.
    522560#if PLATFORM(MAC)
    523561    EXPECT_TRUE(gAuthorization.enableEmbeddedAuthorizationViewController);
     
    564602    checkAuthorizationOptions(true, "null", 0);
    565603#endif
     604    EXPECT_FALSE(policyForAppSSOPerformed); // The delegate isn't registered, so this won't be set.
    566605
    567606    RetainPtr<NSURL> redirectURL = [[NSBundle mainBundle] URLForResource:@"simple2" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
     
    600639    checkAuthorizationOptions(true, "null", 0);
    601640#endif
     641    EXPECT_TRUE(policyForAppSSOPerformed);
    602642
    603643    RetainPtr<NSURL> redirectURL = [[NSBundle mainBundle] URLForResource:@"simple2" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
     
    628668    Util::run(&authorizationPerformed);
    629669    checkAuthorizationOptions(false, "", 0);
     670    EXPECT_TRUE(policyForAppSSOPerformed);
    630671
    631672    RetainPtr<NSURL> redirectURL = [[NSBundle mainBundle] URLForResource:@"simple2" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
     
    657698    Util::run(&authorizationPerformed);
    658699    checkAuthorizationOptions(false, "", 0);
     700    EXPECT_TRUE(policyForAppSSOPerformed);
    659701
    660702    RetainPtr<NSURL> redirectURL = [[NSBundle mainBundle] URLForResource:@"simple2" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
     
    682724    Util::run(&authorizationPerformed);
    683725    checkAuthorizationOptions(false, "", 0);
     726    EXPECT_TRUE(policyForAppSSOPerformed);
    684727
    685728    RetainPtr<NSURL> redirectURL = [[NSBundle mainBundle] URLForResource:@"simple2" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
     
    718761    Util::run(&authorizationPerformed);
    719762    checkAuthorizationOptions(false, "", 0);
     763    EXPECT_TRUE(policyForAppSSOPerformed);
    720764
    721765    RetainPtr<NSURL> redirectURL = [[NSBundle mainBundle] URLForResource:@"simple2" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
     
    763807    checkAuthorizationOptions(true, "null", 0);
    764808#endif
     809    EXPECT_TRUE(policyForAppSSOPerformed);
    765810
    766811    RetainPtr<NSURL> redirectURL = [[NSBundle mainBundle] URLForResource:@"simple2" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
     
    795840    Util::run(&authorizationPerformed);
    796841    checkAuthorizationOptions(false, "", 0);
     842    EXPECT_TRUE(policyForAppSSOPerformed);
    797843
    798844    auto redirectURL = URL(URL(), "https://www.example.com");
     
    821867    [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
    822868    Util::run(&navigationPolicyDecided);
     869    EXPECT_FALSE(policyForAppSSOPerformed);
    823870    EXPECT_FALSE(authorizationPerformed);
    824871
     
    827874    Util::run(&authorizationPerformed);
    828875    checkAuthorizationOptions(false, "", 0);
     876    EXPECT_TRUE(policyForAppSSOPerformed);
    829877
    830878    RetainPtr<NSURL> redirectURL = [[NSBundle mainBundle] URLForResource:@"simple2" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
     
    858906    [webView loadRequest:[NSURLRequest requestWithURL:testURL1.get()]];
    859907    Util::run(&navigationPolicyDecided);
     908    EXPECT_FALSE(policyForAppSSOPerformed);
    860909    EXPECT_FALSE(authorizationPerformed);
    861910
     
    866915    // The waiting session should be aborted as the previous navigation is overwritten by a new navigation.
    867916    Util::run(&navigationCompleted);
     917    EXPECT_FALSE(policyForAppSSOPerformed);
    868918    EXPECT_FALSE(authorizationPerformed);
    869919}
     
    886936    Util::run(&authorizationPerformed);
    887937    checkAuthorizationOptions(false, "", 0);
     938    EXPECT_TRUE(policyForAppSSOPerformed);
    888939
    889940    // Should be a no op.
     
    917968    for (int i = 0; i < 2; i++) {
    918969        authorizationPerformed = false;
     970        policyForAppSSOPerformed = false;
    919971        [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
    920972        Util::run(&authorizationPerformed);
    921973        checkAuthorizationOptions(false, "", 0);
     974        EXPECT_TRUE(policyForAppSSOPerformed);
    922975
    923976        navigationCompleted = false;
     
    9521005    Util::run(&authorizationPerformed);
    9531006    checkAuthorizationOptions(false, "", 0);
     1007    EXPECT_TRUE(policyForAppSSOPerformed);
    9541008
    9551009    // Suppress the last active session.
    9561010    authorizationPerformed = false;
     1011    policyForAppSSOPerformed = false;
    9571012    [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
    9581013    Util::run(&authorizationCancelled);
    9591014    Util::run(&authorizationPerformed);
    9601015    checkAuthorizationOptions(false, "", 0);
     1016    EXPECT_TRUE(policyForAppSSOPerformed);
    9611017
    9621018    RetainPtr<NSURL> redirectURL = [[NSBundle mainBundle] URLForResource:@"simple2" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
     
    9901046    Util::run(&navigationPolicyDecided);
    9911047    EXPECT_FALSE(authorizationPerformed);
     1048    EXPECT_FALSE(policyForAppSSOPerformed);
    9921049
    9931050    // Suppress the last waiting session.
     
    9961053    Util::run(&navigationPolicyDecided);
    9971054    EXPECT_FALSE(authorizationPerformed);
     1055    EXPECT_FALSE(policyForAppSSOPerformed);
    9981056
    9991057    // Activate the last session.
     
    10011059    Util::run(&authorizationPerformed);
    10021060    checkAuthorizationOptions(false, "", 0);
     1061    EXPECT_TRUE(policyForAppSSOPerformed);
    10031062
    10041063    RetainPtr<NSURL> redirectURL = [[NSBundle mainBundle] URLForResource:@"simple2" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
     
    10351094    Util::run(&authorizationPerformed);
    10361095    checkAuthorizationOptions(false, "", 0);
     1096    EXPECT_TRUE(policyForAppSSOPerformed);
    10371097
    10381098    // Pass a HTTP 200 response with a html to mimic a SAML response.
     
    10631123    [webView loadRequest:[NSURLRequest requestWithURL:(NSURL *)testURL]];
    10641124    Util::run(&authorizationPerformed);
     1125    EXPECT_TRUE(policyForAppSSOPerformed);
    10651126
    10661127    navigationCompleted = false;
     
    10721133    authorizationPerformed = false;
    10731134    navigationPolicyDecided = false;
     1135    policyForAppSSOPerformed = false;
    10741136    [webView _evaluateJavaScriptWithoutUserGesture:@"location = 'http://www.example.com'" completionHandler:nil];
    10751137    Util::run(&navigationPolicyDecided);
     1138    EXPECT_TRUE(policyForAppSSOPerformed);
    10761139}
    10771140
     
    10951158    Util::run(&authorizationPerformed);
    10961159    checkAuthorizationOptions(true, "http://www.webkit.org", 0);
     1160    EXPECT_TRUE(policyForAppSSOPerformed);
    10971161}
    10981162
     
    11131177    [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
    11141178    Util::run(&authorizationPerformed);
     1179    EXPECT_TRUE(policyForAppSSOPerformed);
    11151180
    11161181    // Test passes if no crashes.
     
    11351200    [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
    11361201    Util::run(&authorizationPerformed);
     1202    EXPECT_TRUE(policyForAppSSOPerformed);
    11371203
    11381204    // Test passes if no crashes.
     
    11591225    Util::run(&navigationCompleted);
    11601226
     1227    EXPECT_TRUE(policyForAppSSOPerformed);
    11611228    EXPECT_WK_STREQ(testURL.get().absoluteString, finalURL);
    11621229}
     
    11791246    Util::run(&authorizationPerformed);
    11801247    checkAuthorizationOptions(false, "", 0);
     1248    EXPECT_TRUE(policyForAppSSOPerformed);
    11811249
    11821250    RetainPtr<NSURL> redirectURL = [[NSBundle mainBundle] URLForResource:@"simple2" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
     
    12081276    Util::run(&navigationCompleted);
    12091277
     1278    EXPECT_TRUE(policyForAppSSOPerformed);
    12101279    EXPECT_WK_STREQ(testURL.get().absoluteString, finalURL);
    12111280}
     
    12301299    [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
    12311300    Util::run(&authorizationPerformed);
     1301    EXPECT_TRUE(policyForAppSSOPerformed);
    12321302
    12331303    auto viewController = adoptNS([[TestSOAuthorizationViewController alloc] init]);
     
    12641334    [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
    12651335    Util::run(&authorizationPerformed);
     1336    EXPECT_TRUE(policyForAppSSOPerformed);
    12661337
    12671338    auto viewController = adoptNS([[TestSOAuthorizationViewController alloc] init]);
     
    12971368    [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
    12981369    Util::run(&authorizationPerformed);
     1370    EXPECT_TRUE(policyForAppSSOPerformed);
    12991371
    13001372    auto viewController = adoptNS([[TestSOAuthorizationViewController alloc] init]);
     
    13301402    [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
    13311403    Util::run(&authorizationPerformed);
     1404    EXPECT_TRUE(policyForAppSSOPerformed);
    13321405
    13331406    auto viewController = adoptNS([[TestSOAuthorizationViewController alloc] init]);
     
    13441417    [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
    13451418    Util::run(&authorizationCancelled);
     1419    EXPECT_TRUE(policyForAppSSOPerformed);
    13461420    Util::run(&authorizationPerformed);
    13471421    EXPECT_FALSE(uiShowed);
     
    13701444    [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
    13711445    Util::run(&authorizationPerformed);
     1446    EXPECT_TRUE(policyForAppSSOPerformed);
    13721447
    13731448    auto viewController = adoptNS([[TestSOAuthorizationViewController alloc] init]);
     
    14081483    [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
    14091484    Util::run(&authorizationPerformed);
     1485    EXPECT_TRUE(policyForAppSSOPerformed);
    14101486
    14111487    auto viewController = adoptNS([[TestSOAuthorizationViewController alloc] init]);
     
    14401516    [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
    14411517    Util::run(&authorizationPerformed);
     1518    EXPECT_TRUE(policyForAppSSOPerformed);
    14421519
    14431520    auto viewController = adoptNS([[TestSOAuthorizationViewController alloc] init]);
     
    14821559    [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
    14831560    Util::run(&authorizationPerformed);
     1561    EXPECT_TRUE(policyForAppSSOPerformed);
    14841562
    14851563    auto viewController = adoptNS([[TestSOAuthorizationViewController alloc] init]);
     
    15241602    [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
    15251603    Util::run(&authorizationPerformed);
     1604    EXPECT_TRUE(policyForAppSSOPerformed);
    15261605
    15271606    auto viewController1 = adoptNS([[TestSOAuthorizationViewController alloc] init]);
     
    15471626    // Load another AppSSO request.
    15481627    authorizationPerformed = false;
    1549     [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
    1550     Util::run(&authorizationPerformed);
     1628    policyForAppSSOPerformed = false;
     1629    [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
     1630    Util::run(&authorizationPerformed);
     1631    EXPECT_TRUE(policyForAppSSOPerformed);
    15511632
    15521633    // UI is only dimissed after the hostApp is unhidden.
     
    15711652    [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
    15721653    Util::run(&authorizationPerformed);
     1654    EXPECT_TRUE(policyForAppSSOPerformed);
    15731655
    15741656    auto viewController = adoptNS([[TestSOAuthorizationViewController alloc] init]);
     
    15941676    // Load another AppSSO request.
    15951677    authorizationPerformed = false;
    1596     [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
    1597     Util::run(&authorizationPerformed);
     1678    policyForAppSSOPerformed = false;
     1679    [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
     1680    Util::run(&authorizationPerformed);
     1681    EXPECT_TRUE(policyForAppSSOPerformed);
    15981682
    15991683    // UI is only dimissed after the hostApp is unhidden.
     
    16261710    Util::run(&newWindowCreated);
    16271711    Util::run(&navigationCompleted);
     1712    EXPECT_FALSE(policyForAppSSOPerformed);
    16281713    EXPECT_WK_STREQ(testURL.get().absoluteString, finalURL);
    16291714}
     
    16541739    [webView sendClicksAtPoint:NSMakePoint(200, 200) numberOfClicks:1];
    16551740    Util::run(&newWindowCreated);
     1741    EXPECT_FALSE(policyForAppSSOPerformed);
    16561742    EXPECT_FALSE(authorizationPerformed);
    16571743}
     
    16771763    Util::run(&newWindowCreated);
    16781764    EXPECT_FALSE(authorizationPerformed);
     1765    EXPECT_FALSE(policyForAppSSOPerformed);
    16791766}
    16801767
     
    17061793    Util::run(&authorizationPerformed);
    17071794    checkAuthorizationOptions(true, "file://", 1);
     1795    EXPECT_TRUE(policyForAppSSOPerformed);
    17081796
    17091797    authorizationPerformed = false;
    17101798    navigationCompleted = false;
     1799    policyForAppSSOPerformed = false;
    17111800    [gDelegate authorization:gAuthorization didCompleteWithError:adoptNS([[NSError alloc] initWithDomain:NSCocoaErrorDomain code:0 userInfo:nil]).get()];
    17121801    Util::run(&newWindowCreated);
     
    17141803    EXPECT_WK_STREQ(testURL.get().absoluteString, finalURL);
    17151804    EXPECT_FALSE(authorizationPerformed); // Don't intercept the first navigation in the new window.
     1805    EXPECT_FALSE(policyForAppSSOPerformed);
    17161806}
    17171807
     
    17421832    Util::run(&authorizationPerformed);
    17431833    checkAuthorizationOptions(true, "file://", 1);
     1834    EXPECT_TRUE(policyForAppSSOPerformed);
    17441835
    17451836    // The secret WKWebView needs to be destroyed right the way.
     
    17761867    Util::run(&authorizationPerformed);
    17771868    checkAuthorizationOptions(true, "file://", 1);
     1869    EXPECT_TRUE(policyForAppSSOPerformed);
    17781870
    17791871    auto response = adoptNS([[NSHTTPURLResponse alloc] initWithURL:testURL statusCode:200 HTTPVersion:@"HTTP/1.1" headerFields:nil]);
     
    18131905    Util::run(&authorizationPerformed);
    18141906    checkAuthorizationOptions(true, "file://", 1);
     1907    EXPECT_TRUE(policyForAppSSOPerformed);
    18151908
    18161909    auto response = adoptNS([[NSHTTPURLResponse alloc] initWithURL:testURL statusCode:200 HTTPVersion:@"HTTP/1.1" headerFields:nil]);
     
    18501943    Util::run(&authorizationPerformed);
    18511944    checkAuthorizationOptions(true, "file://", 1);
     1945    EXPECT_TRUE(policyForAppSSOPerformed);
    18521946
    18531947    auto response = adoptNS([[NSHTTPURLResponse alloc] initWithURL:testURL statusCode:200 HTTPVersion:@"HTTP/1.1" headerFields:nil]);
     
    18881982    Util::run(&authorizationPerformed);
    18891983    checkAuthorizationOptions(true, "file://", 1);
     1984    EXPECT_TRUE(policyForAppSSOPerformed);
    18901985
    18911986    // Will fallback to web path.
    18921987    navigationCompleted = false;
    18931988    authorizationPerformed = false;
     1989    policyForAppSSOPerformed = false;
    18941990    auto response = adoptNS([[NSHTTPURLResponse alloc] initWithURL:testURL.get() statusCode:400 HTTPVersion:@"HTTP/1.1" headerFields:nil]);
    18951991    auto resonseHtmlCString = generateHtml(newWindowResponseTemplate, "").utf8();
     
    18991995    EXPECT_WK_STREQ(testURL.get().absoluteString, finalURL);
    19001996    EXPECT_FALSE(authorizationPerformed);
     1997    EXPECT_FALSE(policyForAppSSOPerformed);
    19011998}
    19021999
     
    19282025    Util::run(&authorizationPerformed);
    19292026    checkAuthorizationOptions(true, "file://", 1);
     2027    EXPECT_TRUE(policyForAppSSOPerformed);
    19302028
    19312029    auto response = adoptNS([[NSHTTPURLResponse alloc] initWithURL:testURL statusCode:200 HTTPVersion:@"HTTP/1.1" headerFields:@{ @"Set-Cookie" : @"sessionid=38afes7a8;"}]);
     
    19602058    for (int i = 0; i < 2; i++) {
    19612059        authorizationPerformed = false;
     2060        policyForAppSSOPerformed = false;
    19622061#if PLATFORM(MAC)
    19632062        [webView sendClicksAtPoint:NSMakePoint(200, 200) numberOfClicks:1];
     
    19672066        Util::run(&authorizationPerformed);
    19682067        checkAuthorizationOptions(true, "file://", 1);
     2068        EXPECT_TRUE(policyForAppSSOPerformed);
    19692069
    19702070        auto response = adoptNS([[NSHTTPURLResponse alloc] initWithURL:testURL statusCode:200 HTTPVersion:@"HTTP/1.1" headerFields:nil]);
     
    20062106    Util::run(&authorizationPerformed);
    20072107    checkAuthorizationOptions(true, "file://", 1);
     2108    EXPECT_TRUE(policyForAppSSOPerformed);
    20082109
    20092110    // Suppress the last active session.
     
    20162117
    20172118    authorizationPerformed = false;
     2119    policyForAppSSOPerformed = false;
    20182120#if PLATFORM(MAC)
    20192121    [newWebView sendClicksAtPoint:NSMakePoint(200, 200) numberOfClicks:1];
     
    20242126    Util::run(&authorizationPerformed);
    20252127    checkAuthorizationOptions(true, "file://", 1);
     2128    EXPECT_TRUE(policyForAppSSOPerformed);
    20262129
    20272130    navigationCompleted = false;
     
    20682171    Util::run(&authorizationPerformed);
    20692172    checkAuthorizationOptions(true, "file://", 1);
     2173    EXPECT_TRUE(policyForAppSSOPerformed);
    20702174
    20712175    auto response = adoptNS([[NSHTTPURLResponse alloc] initWithURL:testURL statusCode:200 HTTPVersion:@"HTTP/1.1" headerFields:nil]);
     
    21042208    Util::run(&authorizationPerformed);
    21052209    checkAuthorizationOptions(true, "http://www.webkit.org", 1);
     2210    EXPECT_TRUE(policyForAppSSOPerformed);
    21062211}
    21072212
     
    21302235    Util::run(&newWindowCreated);
    21312236    EXPECT_FALSE(authorizationPerformed);
     2237    EXPECT_TRUE(policyForAppSSOPerformed);
    21322238}
    21332239
     
    21592265    Util::run(&authorizationPerformed);
    21602266    checkAuthorizationOptions(true, "file://", 1);
     2267    EXPECT_TRUE(policyForAppSSOPerformed);
    21612268
    21622269    auto response = adoptNS([[NSHTTPURLResponse alloc] initWithURL:testURL statusCode:200 HTTPVersion:@"HTTP/1.1" headerFields:nil]);
     
    21962303    Util::run(&newWindowCreated);
    21972304    EXPECT_FALSE(authorizationPerformed);
     2305    EXPECT_TRUE(policyForAppSSOPerformed);
    21982306}
    21992307
     
    22112319    [webView loadHTMLString:testHtml baseURL:baseURL.get()];
    22122320    [webView waitForMessage:@""];
     2321    EXPECT_FALSE(policyForAppSSOPerformed);
    22132322}
    22142323
     
    22322341    // Make sure we don't intercept the iframe.
    22332342    EXPECT_FALSE(authorizationPerformed);
     2343    EXPECT_FALSE(policyForAppSSOPerformed);
    22342344}
    22352345
     
    22552365    [webView waitForMessage:@"SOAuthorizationDidStart"];
    22562366    checkAuthorizationOptions(false, "file://", 2);
     2367    EXPECT_TRUE(policyForAppSSOPerformed);
    22572368
    22582369    [gDelegate authorization:gAuthorization didCompleteWithError:adoptNS([[NSError alloc] initWithDomain:NSCocoaErrorDomain code:0 userInfo:nil]).get()];
     
    22872398    [webView waitForMessage:@"SOAuthorizationDidStart"];
    22882399    checkAuthorizationOptions(false, "file://", 2);
     2400    EXPECT_TRUE(policyForAppSSOPerformed);
    22892401
    22902402    [gDelegate authorizationDidCancel:gAuthorization];
     
    23182430    [webView waitForMessage:@"SOAuthorizationDidStart"];
    23192431    checkAuthorizationOptions(false, "null", 2);
     2432    EXPECT_TRUE(policyForAppSSOPerformed);
    23202433
    23212434    auto response = adoptNS([[NSHTTPURLResponse alloc] initWithURL:testURL statusCode:200 HTTPVersion:@"HTTP/1.1" headerFields:nil]);
     
    23472460    [webView waitForMessage:@"SOAuthorizationDidStart"];
    23482461    checkAuthorizationOptions(false, "file://", 2);
     2462    EXPECT_TRUE(policyForAppSSOPerformed);
    23492463
    23502464    // Will fallback to web path.
     
    23822496    [webView waitForMessage:@"SOAuthorizationDidStart"];
    23832497    checkAuthorizationOptions(false, "null", 2);
     2498    EXPECT_TRUE(policyForAppSSOPerformed);
    23842499
    23852500    auto response = adoptNS([[NSHTTPURLResponse alloc] initWithURL:testURL statusCode:200 HTTPVersion:@"HTTP/1.1" headerFields:@{ @"Set-Cookie" : @"sessionid=38afes7a8;"}]);
     
    24092524        authorizationPerformed = false;
    24102525        navigationCompleted = false;
     2526        policyForAppSSOPerformed = false;
    24112527
    24122528        [webView loadHTMLString:testHtml baseURL:nil];
     
    24142530        [webView waitForMessage:@"SOAuthorizationDidStart"];
    24152531        checkAuthorizationOptions(false, "null", 2);
     2532        EXPECT_TRUE(policyForAppSSOPerformed);
    24162533
    24172534        auto response = adoptNS([[NSHTTPURLResponse alloc] initWithURL:testURL statusCode:200 HTTPVersion:@"HTTP/1.1" headerFields:nil]);
     
    24642581    // Make sure we don't intercept the iframe.
    24652582    EXPECT_FALSE(authorizationPerformed);
     2583#if PLATFORM(MAC)
     2584    EXPECT_TRUE(policyForAppSSOPerformed);
     2585#else
     2586    EXPECT_FALSE(policyForAppSSOPerformed);
     2587#endif
    24662588}
    24672589
     
    24872609    [webView waitForMessage:@"SOAuthorizationDidStart"];
    24882610    checkAuthorizationOptions(false, "null", 2);
     2611    EXPECT_TRUE(policyForAppSSOPerformed);
    24892612
    24902613    auto response = adoptNS([[NSHTTPURLResponse alloc] initWithURL:testURL statusCode:200 HTTPVersion:@"HTTP/1.1" headerFields:nil]);
     
    25152638    // Make sure we don't intercept the iframe.
    25162639    EXPECT_FALSE(authorizationPerformed);
     2640#if PLATFORM(MAC)
     2641    EXPECT_TRUE(policyForAppSSOPerformed);
     2642#else
     2643    EXPECT_FALSE(policyForAppSSOPerformed);
     2644#endif
    25172645}
    25182646
     
    25562684    [webView waitForMessage:(id)origin];
    25572685    [webView waitForMessage:@"SOAuthorizationDidStart"];
     2686    EXPECT_TRUE(policyForAppSSOPerformed);
    25582687
    25592688    [gDelegate authorization:gAuthorization didCompleteWithError:adoptNS([[NSError alloc] initWithDomain:NSCocoaErrorDomain code:0 userInfo:nil]).get()];
     
    25862715    [webView loadHTMLString:testHtml baseURL:baseURL.get()];
    25872716    Util::run(&authorizationPerformed);
     2717    EXPECT_TRUE(policyForAppSSOPerformed);
    25882718    [gDelegate authorization:gAuthorization didCompleteWithError:adoptNS([[NSError alloc] initWithDomain:NSCocoaErrorDomain code:0 userInfo:nil]).get()];
    25892719    Util::run(&allMessagesReceived);
     
    26122742    [webView loadHTMLString:testHtml baseURL:nil];
    26132743    Util::run(&authorizationPerformed);
     2744    EXPECT_TRUE(policyForAppSSOPerformed);
    26142745
    26152746    auto response = adoptNS([[NSHTTPURLResponse alloc] initWithURL:testURL statusCode:200 HTTPVersion:@"HTTP/1.1" headerFields:nil]);
Note: See TracChangeset for help on using the changeset viewer.