Title: [295058] trunk
Revision
295058
Author
bfulg...@apple.com
Date
2022-05-31 10:12:54 -0700 (Tue, 31 May 2022)

Log Message

REGRESSION (250981@main): Two SOAuthorization API tests failing
https://bugs.webkit.org/show_bug.cgi?id=240979
<rdar://93996565>

Reviewed by Chris Dumez.

In Bug 240739 I modified AppSSO to lazily initialize the SOAuthenticationCoordinator. This introduced
two problems in the API Tests:
1. SOAuthorizationRedirect.InterceptionSucceed3 expected SOAuthentiationCoordinator initialization to
   happen as soon as the WKWebsiteDataStore was created, but this is now too soon. The assertion just
   needed to be made after an AppSSO operation was called that would construct the SSO object.
2. SOAuthorizationPopUp.InterceptionSucceedTwice revealed a real bug. We almost never start an AppSSO
   flow, then turn off the feature -- except in the case of a pop-up authentication, which creates a
   secret hidden window without AppSSO turned on. Hitting this test case caused a crash that needed
   to be addressed by checking for this rare case, and making sure we didn't dereference a nullptr.

* Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.mm:
(WebKit::PopUpSOAuthorizationSession::initSecretWebView): Properly disable AppSSO through the WKPreference,
rather than reaching into the object to modify WebKit internal state.
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::trySOAuthorization): Don't attempt to dereference the SOAuthenticationCoordinator when the
AppSSO feature is turned off for a pop-up window.
* Tools/TestWebKitAPI/Tests/WebKitCocoa/TestSOAuthorization.mm:
(TestWebKitAPI::TEST): Move the assertion to after AppSSO initialization is complete.

Canonical link: https://commits.webkit.org/251153@main

Modified Paths

Diff

Modified: trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.mm (295057 => 295058)


--- trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.mm	2022-05-31 17:05:31 UTC (rev 295057)
+++ trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.mm	2022-05-31 17:12:54 UTC (rev 295058)
@@ -30,6 +30,7 @@
 
 #import "APINavigationAction.h"
 #import <WebKit/WKNavigationDelegatePrivate.h>
+#import <WebKit/WKPreferencesPrivate.h>
 #import <WebKit/WKUIDelegate.h>
 #import <WebKit/WKWebViewConfigurationPrivate.h>
 #import "WKWebViewInternal.h"
@@ -183,6 +184,7 @@
         return;
     auto configuration = adoptNS([[initiatorWebView configuration] copy]);
     [configuration _setRelatedWebView:initiatorWebView.get()];
+    [configuration preferences]._extensibleSSOEnabled = NO;
     m_secretWebView = adoptNS([[WKWebView alloc] initWithFrame:CGRectZero configuration:configuration.get()]);
 
     m_secretDelegate = adoptNS([[WKSOSecretDelegate alloc] initWithSession:this]);
@@ -189,7 +191,7 @@
     [m_secretWebView setUIDelegate:m_secretDelegate.get()];
     [m_secretWebView setNavigationDelegate:m_secretDelegate.get()];
 
-    m_secretWebView->_page->preferences().setExtensibleSSOEnabled(false);
+    RELEASE_ASSERT(!m_secretWebView->_page->preferences().isExtensibleSSOEnabled());
     WTFLogAlways("SecretWebView is created.");
 }
 

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (295057 => 295058)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2022-05-31 17:05:31 UTC (rev 295057)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2022-05-31 17:12:54 UTC (rev 295058)
@@ -5996,10 +5996,12 @@
 static void trySOAuthorization(Ref<API::NavigationAction>&& navigationAction, WebPageProxy& page, NewPageCallback&& newPageCallback, UIClientCallback&& uiClientCallback)
 {
 #if HAVE(APP_SSO)
-    page.websiteDataStore().soAuthorizationCoordinator(page).tryAuthorize(WTFMove(navigationAction), page, WTFMove(newPageCallback), WTFMove(uiClientCallback));
-#else
+    if (page.preferences().isExtensibleSSOEnabled()) {
+        page.websiteDataStore().soAuthorizationCoordinator(page).tryAuthorize(WTFMove(navigationAction), page, WTFMove(newPageCallback), WTFMove(uiClientCallback));
+        return;
+    }
+#endif
     uiClientCallback(WTFMove(navigationAction), WTFMove(newPageCallback));
-#endif
 }
 
 void WebPageProxy::createNewPage(FrameInfoData&& originatingFrameInfoData, WebPageProxyIdentifier originatingPageID, ResourceRequest&& request, WindowFeatures&& windowFeatures, NavigationActionData&& navigationActionData, Messages::WebPageProxy::CreateNewPage::DelayedReply&& reply)

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/TestSOAuthorization.mm (295057 => 295058)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/TestSOAuthorization.mm	2022-05-31 17:05:31 UTC (rev 295057)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/TestSOAuthorization.mm	2022-05-31 17:12:54 UTC (rev 295058)
@@ -618,7 +618,6 @@
     auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
     auto delegate = adoptNS([[TestSOAuthorizationDelegate alloc] init]);
     configureSOAuthorizationWebView(webView.get(), delegate.get(), OpenExternalSchemesPolicy::Allow);
-    EXPECT_TRUE(gAuthorization.enableEmbeddedAuthorizationViewController);
 
     // Force App Links with a request.URL that has a different host than the current one (empty host) and ShouldOpenExternalURLsPolicy::ShouldAllow.
     URL testURL { "https://www.example.com"_str };
@@ -629,6 +628,7 @@
     [webView evaluateJavaScript: [NSString stringWithFormat:@"location = '%@'", (id)testURL.string()] completionHandler:nil];
 #endif
     Util::run(&authorizationPerformed);
+    EXPECT_TRUE(gAuthorization.enableEmbeddedAuthorizationViewController);
 #if PLATFORM(MAC)
     checkAuthorizationOptions(false, emptyString(), 0);
 #elif PLATFORM(IOS)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to