[WebAuthn] Return NotAllowedError immediately for UI cancellations
authorjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Nov 2019 19:44:34 +0000 (19:44 +0000)
committerjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Nov 2019 19:44:34 +0000 (19:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=203937
<rdar://problem/56962420>

Reviewed by Brent Fulgham.

Source/WebKit:

NotAllowedError representing UI cancellations should be returned to sites
immediately such that sites could show appropriate error page immediately.

Covered by existing tests.

* UIProcess/WebAuthentication/AuthenticatorManager.cpp:
(WebKit::AuthenticatorManager::cancelRequest):
(WebKit::AuthenticatorManager::clearState):
(WebKit::AuthenticatorManager::resetState): Deleted.
* UIProcess/WebAuthentication/AuthenticatorManager.h:

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm:
(TestWebKitAPI::TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@252248 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.cpp
Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.h
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm

index 6d47cb2..275caf6 100644 (file)
@@ -1,3 +1,22 @@
+2019-11-06  Jiewen Tan  <jiewen_tan@apple.com>
+
+        [WebAuthn] Return NotAllowedError immediately for UI cancellations
+        https://bugs.webkit.org/show_bug.cgi?id=203937
+        <rdar://problem/56962420>
+
+        Reviewed by Brent Fulgham.
+
+        NotAllowedError representing UI cancellations should be returned to sites
+        immediately such that sites could show appropriate error page immediately.
+
+        Covered by existing tests.
+
+        * UIProcess/WebAuthentication/AuthenticatorManager.cpp:
+        (WebKit::AuthenticatorManager::cancelRequest):
+        (WebKit::AuthenticatorManager::clearState):
+        (WebKit::AuthenticatorManager::resetState): Deleted.
+        * UIProcess/WebAuthentication/AuthenticatorManager.h:
+
 2019-11-08  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK] Add pointer lock permission request API
index 6f371d7..e8c40eb 100644 (file)
@@ -198,7 +198,9 @@ void AuthenticatorManager::cancelRequest(const API::WebAuthenticationPanel& pane
     RELEASE_ASSERT(RunLoop::isMain());
     if (!m_pendingCompletionHandler || m_pendingRequestData.panel.get() != &panel)
         return;
-    resetState();
+    invokePendingCompletionHandler(ExceptionData { NotAllowedError, "This request has been cancelled by the user."_s });
+    clearState();
+    m_requestTimeOutTimer.stop();
 }
 
 void AuthenticatorManager::clearStateAsync()
@@ -214,7 +216,9 @@ void AuthenticatorManager::clearState()
 {
     if (m_pendingCompletionHandler)
         return;
-    resetState();
+    m_authenticators.clear();
+    m_services.clear();
+    m_pendingRequestData = { };
 }
 
 void AuthenticatorManager::authenticatorAdded(Ref<Authenticator>&& authenticator)
@@ -354,13 +358,6 @@ void AuthenticatorManager::invokePendingCompletionHandler(Respond&& respond)
     m_pendingCompletionHandler(WTFMove(respond));
 }
 
-void AuthenticatorManager::resetState()
-{
-    m_authenticators.clear();
-    m_services.clear();
-    m_pendingRequestData = { };
-}
-
 void AuthenticatorManager::restartDiscovery()
 {
     for (auto& service : m_services)
index 05a2487..eee24ea 100644 (file)
@@ -92,7 +92,6 @@ private:
     void initTimeOutTimer();
     void timeOutTimerFired();
     void runPanel();
-    void resetState();
     void restartDiscovery();
     TransportSet getTransports() const;
 
index 75ab319..b63594d 100644 (file)
@@ -1,3 +1,14 @@
+2019-11-06  Jiewen Tan  <jiewen_tan@apple.com>
+
+        [WebAuthn] Return NotAllowedError immediately for UI cancellations
+        https://bugs.webkit.org/show_bug.cgi?id=203937
+        <rdar://problem/56962420>
+
+        Reviewed by Brent Fulgham.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm:
+        (TestWebKitAPI::TEST):
+
 2019-11-08  Aakash Jain  <aakash_jain@apple.com>
 
         [ews] Prioritize builders over testers when a bot is shared over multiple queues
index f23cfc7..66f74d3 100644 (file)
@@ -558,9 +558,8 @@ TEST(WebAuthenticationPanel, PanelHidCancel)
     [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
     Util::run(&webAuthenticationPanelRan);
     [[delegate panel] cancel];
-    [webView waitForMessage:@"Operation timed out."];
-    EXPECT_FALSE(webAuthenticationPanelFailed);
-    EXPECT_FALSE(webAuthenticationPanelSucceded);
+    [webView waitForMessage:@"This request has been cancelled by the user."];
+    EXPECT_TRUE(webAuthenticationPanelFailed);
 }
 
 TEST(WebAuthenticationPanel, PanelHidCtapNoCredentialsFound)