Title: [251489] trunk
Revision
251489
Author
[email protected]
Date
2019-10-23 12:36:43 -0700 (Wed, 23 Oct 2019)

Log Message

[WebAuthn] Supply FrameInfo in -[WKUIDelegatePrivate _webView:runWebAuthenticationPanel:initiatedByFrame:completionHandler:]
https://bugs.webkit.org/show_bug.cgi?id=202563
<rdar://problem/55973968>

Reviewed by Brent Fulgham.

Source/WebCore:

Covered by new test contents within existing tests.

* Modules/webauthn/AuthenticatorCoordinator.cpp:
(WebCore::AuthenticatorCoordinator::create const):
(WebCore::AuthenticatorCoordinator::discoverFromExternalSource const):
* Modules/webauthn/AuthenticatorCoordinatorClient.h:

Source/WebKit:

This patch makes WKFrameInfo available to clients via the above SPI. To do so,
SecuirtyOrigin of the caller document is passed from WebContent Process.

* UIProcess/API/APIUIClient.h:
(API::UIClient::runWebAuthenticationPanel):
* UIProcess/API/C/WKPage.cpp:
(WKPageSetPageUIClient):
* UIProcess/Cocoa/UIDelegate.h:
* UIProcess/Cocoa/UIDelegate.mm:
(WebKit::UIDelegate::UIClient::runWebAuthenticationPanel):
* UIProcess/WebAuthentication/AuthenticatorManager.cpp:
(WebKit::AuthenticatorManager::runPanel):
* UIProcess/WebAuthentication/WebAuthenticationRequestData.h:
* UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp:
(WebKit::WebAuthenticatorCoordinatorProxy::makeCredential):
(WebKit::WebAuthenticatorCoordinatorProxy::getAssertion):
(WebKit::WebAuthenticatorCoordinatorProxy::handleRequest):
* UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.h:
* UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.messages.in:
* WebProcess/WebAuthentication/WebAuthenticatorCoordinator.cpp:
(WebKit::WebAuthenticatorCoordinator::makeCredential):
(WebKit::WebAuthenticatorCoordinator::getAssertion):
* WebProcess/WebAuthentication/WebAuthenticatorCoordinator.h:

Tools:

Adds new test contents into existing tests.

* TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm:
(-[TestWebAuthenticationPanelUIDelegate init]):
(-[TestWebAuthenticationPanelUIDelegate _webView:runWebAuthenticationPanel:initiatedByFrame:completionHandler:]):
(-[TestWebAuthenticationPanelUIDelegate frame]):
(TestWebKitAPI::TEST):

LayoutTests:

* http/wpt/webauthn/public-key-credential-get-success-hid.https.html:
Imporves the flakiness.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (251488 => 251489)


--- trunk/LayoutTests/ChangeLog	2019-10-23 19:34:32 UTC (rev 251488)
+++ trunk/LayoutTests/ChangeLog	2019-10-23 19:36:43 UTC (rev 251489)
@@ -1,3 +1,14 @@
+2019-10-22  Jiewen Tan  <[email protected]>
+
+        [WebAuthn] Supply FrameInfo in -[WKUIDelegatePrivate _webView:runWebAuthenticationPanel:initiatedByFrame:completionHandler:]
+        https://bugs.webkit.org/show_bug.cgi?id=202563
+        <rdar://problem/55973968>
+
+        Reviewed by Brent Fulgham.
+
+        * http/wpt/webauthn/public-key-credential-get-success-hid.https.html:
+        Imporves the flakiness.
+
 2019-10-23  Wenson Hsieh  <[email protected]>
 
         fast/forms/ios/click-should-not-suppress-misspelling.html is a flaky failure

Modified: trunk/LayoutTests/http/wpt/webauthn/public-key-credential-get-success-hid.https.html (251488 => 251489)


--- trunk/LayoutTests/http/wpt/webauthn/public-key-credential-get-success-hid.https.html	2019-10-23 19:34:32 UTC (rev 251488)
+++ trunk/LayoutTests/http/wpt/webauthn/public-key-credential-get-success-hid.https.html	2019-10-23 19:36:43 UTC (rev 251489)
@@ -90,7 +90,13 @@
             }
         };
 
+
+        // Stall the first request to wait for cancellation.
+        if (window.internals)
+            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", payloadBase64: [testAssertionMessageBase64], expectCancel: true } });
         promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "This request has been cancelled by a new request.");
+        if (window.internals)
+            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", payloadBase64: [testAssertionMessageBase64] } });
         return navigator.credentials.get(options).then(credential => {
             return checkCtapGetAssertionResult(credential);
         });

Modified: trunk/Source/WebCore/ChangeLog (251488 => 251489)


--- trunk/Source/WebCore/ChangeLog	2019-10-23 19:34:32 UTC (rev 251488)
+++ trunk/Source/WebCore/ChangeLog	2019-10-23 19:36:43 UTC (rev 251489)
@@ -1,3 +1,18 @@
+2019-10-22  Jiewen Tan  <[email protected]>
+
+        [WebAuthn] Supply FrameInfo in -[WKUIDelegatePrivate _webView:runWebAuthenticationPanel:initiatedByFrame:completionHandler:]
+        https://bugs.webkit.org/show_bug.cgi?id=202563
+        <rdar://problem/55973968>
+
+        Reviewed by Brent Fulgham.
+
+        Covered by new test contents within existing tests.
+
+        * Modules/webauthn/AuthenticatorCoordinator.cpp:
+        (WebCore::AuthenticatorCoordinator::create const):
+        (WebCore::AuthenticatorCoordinator::discoverFromExternalSource const):
+        * Modules/webauthn/AuthenticatorCoordinatorClient.h:
+
 2019-10-23  Andy Estes  <[email protected]>
 
         [Quick Look] Rename PreviewLoader{,Client} to LegacyPreviewLoader{,Client}

Modified: trunk/Source/WebCore/Modules/webauthn/AuthenticatorCoordinator.cpp (251488 => 251489)


--- trunk/Source/WebCore/Modules/webauthn/AuthenticatorCoordinator.cpp	2019-10-23 19:34:32 UTC (rev 251488)
+++ trunk/Source/WebCore/Modules/webauthn/AuthenticatorCoordinator.cpp	2019-10-23 19:36:43 UTC (rev 251489)
@@ -204,7 +204,7 @@
         promise.reject(exception.toException());
     };
     // Async operations are dispatched and handled in the messenger.
-    m_client->makeCredential(*frame, clientDataJsonHash, options, WTFMove(callback));
+    m_client->makeCredential(*frame, callerOrigin, clientDataJsonHash, options, WTFMove(callback));
 }
 
 void AuthenticatorCoordinator::discoverFromExternalSource(const Document& document, const PublicKeyCredentialRequestOptions& options, bool sameOriginWithAncestors, RefPtr<AbortSignal>&& abortSignal, CredentialPromise&& promise) const
@@ -275,7 +275,7 @@
         promise.reject(exception.toException());
     };
     // Async operations are dispatched and handled in the messenger.
-    m_client->getAssertion(*frame, clientDataJsonHash, options, WTFMove(callback));
+    m_client->getAssertion(*frame, callerOrigin, clientDataJsonHash, options, WTFMove(callback));
 }
 
 void AuthenticatorCoordinator::isUserVerifyingPlatformAuthenticatorAvailable(DOMPromiseDeferred<IDLBoolean>&& promise) const

Modified: trunk/Source/WebCore/Modules/webauthn/AuthenticatorCoordinatorClient.h (251488 => 251489)


--- trunk/Source/WebCore/Modules/webauthn/AuthenticatorCoordinatorClient.h	2019-10-23 19:34:32 UTC (rev 251488)
+++ trunk/Source/WebCore/Modules/webauthn/AuthenticatorCoordinatorClient.h	2019-10-23 19:36:43 UTC (rev 251489)
@@ -36,6 +36,7 @@
 
 class DeferredPromise;
 class Frame;
+class SecurityOrigin;
 
 struct PublicKeyCredentialCreationOptions;
 struct PublicKeyCredentialData;
@@ -51,8 +52,8 @@
     AuthenticatorCoordinatorClient() = default;
     virtual ~AuthenticatorCoordinatorClient() = default;
 
-    virtual void makeCredential(const Frame&, const Vector<uint8_t>&, const PublicKeyCredentialCreationOptions&, RequestCompletionHandler&&) { };
-    virtual void getAssertion(const Frame&, const Vector<uint8_t>&, const PublicKeyCredentialRequestOptions&, RequestCompletionHandler&&) { };
+    virtual void makeCredential(const Frame&, const SecurityOrigin&, const Vector<uint8_t>&, const PublicKeyCredentialCreationOptions&, RequestCompletionHandler&&) { };
+    virtual void getAssertion(const Frame&, const SecurityOrigin&, const Vector<uint8_t>&, const PublicKeyCredentialRequestOptions&, RequestCompletionHandler&&) { };
     virtual void isUserVerifyingPlatformAuthenticatorAvailable(QueryCompletionHandler&&) { };
 };
 

Modified: trunk/Source/WebKit/ChangeLog (251488 => 251489)


--- trunk/Source/WebKit/ChangeLog	2019-10-23 19:34:32 UTC (rev 251488)
+++ trunk/Source/WebKit/ChangeLog	2019-10-23 19:36:43 UTC (rev 251489)
@@ -1,3 +1,35 @@
+2019-10-22  Jiewen Tan  <[email protected]>
+
+        [WebAuthn] Supply FrameInfo in -[WKUIDelegatePrivate _webView:runWebAuthenticationPanel:initiatedByFrame:completionHandler:]
+        https://bugs.webkit.org/show_bug.cgi?id=202563
+        <rdar://problem/55973968>
+
+        Reviewed by Brent Fulgham.
+
+        This patch makes WKFrameInfo available to clients via the above SPI. To do so,
+        SecuirtyOrigin of the caller document is passed from WebContent Process.
+
+        * UIProcess/API/APIUIClient.h:
+        (API::UIClient::runWebAuthenticationPanel):
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageSetPageUIClient):
+        * UIProcess/Cocoa/UIDelegate.h:
+        * UIProcess/Cocoa/UIDelegate.mm:
+        (WebKit::UIDelegate::UIClient::runWebAuthenticationPanel):
+        * UIProcess/WebAuthentication/AuthenticatorManager.cpp:
+        (WebKit::AuthenticatorManager::runPanel):
+        * UIProcess/WebAuthentication/WebAuthenticationRequestData.h:
+        * UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp:
+        (WebKit::WebAuthenticatorCoordinatorProxy::makeCredential):
+        (WebKit::WebAuthenticatorCoordinatorProxy::getAssertion):
+        (WebKit::WebAuthenticatorCoordinatorProxy::handleRequest):
+        * UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.h:
+        * UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.messages.in:
+        * WebProcess/WebAuthentication/WebAuthenticatorCoordinator.cpp:
+        (WebKit::WebAuthenticatorCoordinator::makeCredential):
+        (WebKit::WebAuthenticatorCoordinator::getAssertion):
+        * WebProcess/WebAuthentication/WebAuthenticatorCoordinator.h:
+
 2019-10-23  Andy Estes  <[email protected]>
 
         [Quick Look] Rename PreviewLoader{,Client} to LegacyPreviewLoader{,Client}

Modified: trunk/Source/WebKit/UIProcess/API/APIUIClient.h (251488 => 251489)


--- trunk/Source/WebKit/UIProcess/API/APIUIClient.h	2019-10-23 19:34:32 UTC (rev 251488)
+++ trunk/Source/WebKit/UIProcess/API/APIUIClient.h	2019-10-23 19:36:43 UTC (rev 251489)
@@ -197,7 +197,7 @@
     virtual void didShowSafeBrowsingWarning() { }
 
 #if ENABLE(WEB_AUTHN)
-    virtual void runWebAuthenticationPanel(WebKit::WebPageProxy&, WebAuthenticationPanel&, CompletionHandler<void(WebKit::WebAuthenticationPanelResult)>&& completionHandler) { completionHandler(WebKit::WebAuthenticationPanelResult::Unavailable); }
+    virtual void runWebAuthenticationPanel(WebKit::WebPageProxy&, WebAuthenticationPanel&, WebKit::WebFrameProxy&, const WebCore::SecurityOriginData&, CompletionHandler<void(WebKit::WebAuthenticationPanelResult)>&& completionHandler) { completionHandler(WebKit::WebAuthenticationPanelResult::Unavailable); }
 #endif
 };
 

Modified: trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp (251488 => 251489)


--- trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp	2019-10-23 19:34:32 UTC (rev 251488)
+++ trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp	2019-10-23 19:36:43 UTC (rev 251489)
@@ -2076,7 +2076,7 @@
 
 #if ENABLE(WEB_AUTHN)
         // The current method is specialized for WebKitTestRunner.
-        void runWebAuthenticationPanel(WebPageProxy&, API::WebAuthenticationPanel&, CompletionHandler<void(WebKit::WebAuthenticationPanelResult)>&& completionHandler) final
+        void runWebAuthenticationPanel(WebPageProxy&, API::WebAuthenticationPanel&, WebFrameProxy&, const WebCore::SecurityOriginData&, CompletionHandler<void(WebKit::WebAuthenticationPanelResult)>&& completionHandler) final
         {
             if (!m_client.runWebAuthenticationPanel) {
                 completionHandler(WebKit::WebAuthenticationPanelResult::Unavailable);

Modified: trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h (251488 => 251489)


--- trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h	2019-10-23 19:34:32 UTC (rev 251488)
+++ trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h	2019-10-23 19:36:43 UTC (rev 251489)
@@ -155,7 +155,7 @@
         void imageOrMediaDocumentSizeChanged(const WebCore::IntSize&) final;
         void didShowSafeBrowsingWarning() final;
 #if ENABLE(WEB_AUTHN)
-        void runWebAuthenticationPanel(WebPageProxy&, API::WebAuthenticationPanel&, CompletionHandler<void(WebAuthenticationPanelResult)>&&) final;
+        void runWebAuthenticationPanel(WebPageProxy&, API::WebAuthenticationPanel&, WebFrameProxy&, const WebCore::SecurityOriginData&, CompletionHandler<void(WebAuthenticationPanelResult)>&&) final;
 #endif
 
         UIDelegate& m_uiDelegate;

Modified: trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm (251488 => 251489)


--- trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm	2019-10-23 19:34:32 UTC (rev 251488)
+++ trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm	2019-10-23 19:36:43 UTC (rev 251489)
@@ -1281,7 +1281,7 @@
     return WebAuthenticationPanelResult::Unavailable;
 }
 
-void UIDelegate::UIClient::runWebAuthenticationPanel(WebPageProxy&, API::WebAuthenticationPanel& panel, CompletionHandler<void(WebAuthenticationPanelResult)>&& completionHandler)
+void UIDelegate::UIClient::runWebAuthenticationPanel(WebPageProxy&, API::WebAuthenticationPanel& panel, WebFrameProxy& webFrameProxy, const WebCore::SecurityOriginData& origin, CompletionHandler<void(WebAuthenticationPanelResult)>&& completionHandler)
 {
     if (!m_uiDelegate.m_delegateMethods.webViewRunWebAuthenticationPanelInitiatedByFrameCompletionHandler) {
         completionHandler(WebAuthenticationPanelResult::Unavailable);
@@ -1295,7 +1295,7 @@
     }
 
     auto checker = CompletionHandlerCallChecker::create(delegate.get(), @selector(_webView:runWebAuthenticationPanel:initiatedByFrame:completionHandler:));
-    [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView runWebAuthenticationPanel:wrapper(panel) initiatedByFrame:nil completionHandler:makeBlockPtr([completionHandler = WTFMove(completionHandler), checker = WTFMove(checker)] (_WKWebAuthenticationPanelResult result) mutable {
+    [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView runWebAuthenticationPanel:wrapper(panel) initiatedByFrame:wrapper(API::FrameInfo::create(webFrameProxy, origin.securityOrigin())) completionHandler:makeBlockPtr([completionHandler = WTFMove(completionHandler), checker = WTFMove(checker)] (_WKWebAuthenticationPanelResult result) mutable {
         if (checker->completionHandlerHasBeenCalled())
             return;
         checker->didCallCompletionHandler();

Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.cpp (251488 => 251489)


--- trunk/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.cpp	2019-10-23 19:34:32 UTC (rev 251488)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.cpp	2019-10-23 19:36:43 UTC (rev 251489)
@@ -291,10 +291,14 @@
     auto* page = m_pendingRequestData.page.get();
     if (!page)
         return;
+    ASSERT(m_pendingRequestData.frameID && page->webPageID() == m_pendingRequestData.frameID->pageID);
+    auto* frame = page->process().webFrame(m_pendingRequestData.frameID->frameID);
+    if (!frame)
+        return;
 
     m_pendingRequestData.panel = API::WebAuthenticationPanel::create(*this, getRpId(m_pendingRequestData.options));
     auto& panel = *m_pendingRequestData.panel;
-    page->uiClient().runWebAuthenticationPanel(*page, panel, [weakPanel = makeWeakPtr(panel), weakThis = makeWeakPtr(*this), this] (WebAuthenticationPanelResult result) {
+    page->uiClient().runWebAuthenticationPanel(*page, panel, *frame, m_pendingRequestData.origin, [weakPanel = makeWeakPtr(panel), weakThis = makeWeakPtr(*this), this] (WebAuthenticationPanelResult result) {
         // The panel address is used to determine if the current pending request is still the same.
         if (!weakThis || !weakPanel
             || (result == WebAuthenticationPanelResult::DidNotPresent)

Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticationRequestData.h (251488 => 251489)


--- trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticationRequestData.h	2019-10-23 19:34:32 UTC (rev 251488)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticationRequestData.h	2019-10-23 19:36:43 UTC (rev 251489)
@@ -32,6 +32,7 @@
 #include <WebCore/GlobalFrameIdentifier.h>
 #include <WebCore/PublicKeyCredentialCreationOptions.h>
 #include <WebCore/PublicKeyCredentialRequestOptions.h>
+#include <WebCore/SecurityOriginData.h>
 #include <wtf/Variant.h>
 #include <wtf/Vector.h>
 #include <wtf/WeakPtr.h>
@@ -47,6 +48,7 @@
     WebAuthenticationPanelResult panelResult { WebAuthenticationPanelResult::Unavailable };
     RefPtr<API::WebAuthenticationPanel> panel;
     WTF::Optional<WebCore::GlobalFrameIdentifier> frameID;
+    WebCore::SecurityOriginData origin;
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp (251488 => 251489)


--- trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp	2019-10-23 19:34:32 UTC (rev 251488)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp	2019-10-23 19:36:43 UTC (rev 251489)
@@ -37,10 +37,12 @@
 #include "WebsiteDataStore.h"
 #include <WebCore/ExceptionData.h>
 #include <WebCore/PublicKeyCredentialData.h>
+#include <WebCore/SecurityOriginData.h>
 #include <wtf/MainThread.h>
 #include <wtf/RunLoop.h>
 
 namespace WebKit {
+using namespace WebCore;
 
 WebAuthenticatorCoordinatorProxy::WebAuthenticatorCoordinatorProxy(WebPageProxy& webPageProxy)
     : m_webPageProxy(webPageProxy)
@@ -53,23 +55,23 @@
     m_webPageProxy.process().removeMessageReceiver(Messages::WebAuthenticatorCoordinatorProxy::messageReceiverName(), m_webPageProxy.webPageID());
 }
 
-void WebAuthenticatorCoordinatorProxy::makeCredential(FrameIdentifier frameId, const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialCreationOptions& options, RequestCompletionHandler&& handler)
+void WebAuthenticatorCoordinatorProxy::makeCredential(FrameIdentifier frameId, SecurityOriginData&& origin, Vector<uint8_t>&& hash, PublicKeyCredentialCreationOptions&& options, RequestCompletionHandler&& handler)
 {
-    handleRequest({ hash, options, makeWeakPtr(m_webPageProxy), WebAuthenticationPanelResult::Unavailable, nullptr, GlobalFrameIdentifier { m_webPageProxy.webPageID(), frameId } }, WTFMove(handler));
+    handleRequest({ WTFMove(hash), WTFMove(options), makeWeakPtr(m_webPageProxy), WebAuthenticationPanelResult::Unavailable, nullptr, GlobalFrameIdentifier { m_webPageProxy.webPageID(), frameId }, WTFMove(origin) }, WTFMove(handler));
 }
 
-void WebAuthenticatorCoordinatorProxy::getAssertion(FrameIdentifier frameId, const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialRequestOptions& options, RequestCompletionHandler&& handler)
+void WebAuthenticatorCoordinatorProxy::getAssertion(FrameIdentifier frameId, SecurityOriginData&& origin, Vector<uint8_t>&& hash, PublicKeyCredentialRequestOptions&& options, RequestCompletionHandler&& handler)
 {
-    handleRequest({ hash, options, makeWeakPtr(m_webPageProxy), WebAuthenticationPanelResult::Unavailable, nullptr, GlobalFrameIdentifier { m_webPageProxy.webPageID(), frameId } }, WTFMove(handler));
+    handleRequest({ WTFMove(hash), WTFMove(options), makeWeakPtr(m_webPageProxy), WebAuthenticationPanelResult::Unavailable, nullptr, GlobalFrameIdentifier { m_webPageProxy.webPageID(), frameId }, WTFMove(origin) }, WTFMove(handler));
 }
 
 void WebAuthenticatorCoordinatorProxy::handleRequest(WebAuthenticationRequestData&& data, RequestCompletionHandler&& handler)
 {
-    auto callback = [handler = WTFMove(handler)] (Variant<WebCore::PublicKeyCredentialData, WebCore::ExceptionData>&& result) mutable {
+    auto callback = [handler = WTFMove(handler)] (Variant<PublicKeyCredentialData, ExceptionData>&& result) mutable {
         ASSERT(RunLoop::isMain());
-        WTF::switchOn(result, [&](const WebCore::PublicKeyCredentialData& data) {
+        WTF::switchOn(result, [&](const PublicKeyCredentialData& data) {
             handler(data, { });
-        }, [&](const  WebCore::ExceptionData& exception) {
+        }, [&](const ExceptionData& exception) {
             handler({ }, exception);
         });
     };

Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.h (251488 => 251489)


--- trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.h	2019-10-23 19:34:32 UTC (rev 251488)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.h	2019-10-23 19:36:43 UTC (rev 251489)
@@ -37,6 +37,7 @@
 struct PublicKeyCredentialCreationOptions;
 struct PublicKeyCredentialData;
 struct PublicKeyCredentialRequestOptions;
+struct SecurityOriginData;
 }
 
 namespace WebKit {
@@ -60,8 +61,8 @@
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
 
     // Receivers.
-    void makeCredential(WebCore::FrameIdentifier, const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialCreationOptions&, RequestCompletionHandler&&);
-    void getAssertion(WebCore::FrameIdentifier, const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialRequestOptions&, RequestCompletionHandler&&);
+    void makeCredential(WebCore::FrameIdentifier, WebCore::SecurityOriginData&&, Vector<uint8_t>&& hash, WebCore::PublicKeyCredentialCreationOptions&&, RequestCompletionHandler&&);
+    void getAssertion(WebCore::FrameIdentifier, WebCore::SecurityOriginData&&, Vector<uint8_t>&& hash, WebCore::PublicKeyCredentialRequestOptions&&, RequestCompletionHandler&&);
     void isUserVerifyingPlatformAuthenticatorAvailable(QueryCompletionHandler&&);
 
     void handleRequest(WebAuthenticationRequestData&&, RequestCompletionHandler&&);

Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.messages.in (251488 => 251489)


--- trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.messages.in	2019-10-23 19:34:32 UTC (rev 251488)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.messages.in	2019-10-23 19:36:43 UTC (rev 251489)
@@ -26,8 +26,8 @@
 
 messages -> WebAuthenticatorCoordinatorProxy {
 
-    MakeCredential(WebCore::FrameIdentifier frameID, Vector<uint8_t> hash, struct WebCore::PublicKeyCredentialCreationOptions options) -> (struct WebCore::PublicKeyCredentialData data, struct WebCore::ExceptionData exception) Async
-    GetAssertion(WebCore::FrameIdentifier frameID, Vector<uint8_t> hash, struct WebCore::PublicKeyCredentialRequestOptions options) -> (struct WebCore::PublicKeyCredentialData data, struct WebCore::ExceptionData exception) Async
+    MakeCredential(WebCore::FrameIdentifier frameID, struct WebCore::SecurityOriginData origin, Vector<uint8_t> hash, struct WebCore::PublicKeyCredentialCreationOptions options) -> (struct WebCore::PublicKeyCredentialData data, struct WebCore::ExceptionData exception) Async
+    GetAssertion(WebCore::FrameIdentifier frameID, struct WebCore::SecurityOriginData origin, Vector<uint8_t> hash, struct WebCore::PublicKeyCredentialRequestOptions options) -> (struct WebCore::PublicKeyCredentialData data, struct WebCore::ExceptionData exception) Async
     IsUserVerifyingPlatformAuthenticatorAvailable() -> (bool result) Async
 }
 

Modified: trunk/Source/WebKit/WebProcess/WebAuthentication/WebAuthenticatorCoordinator.cpp (251488 => 251489)


--- trunk/Source/WebKit/WebProcess/WebAuthentication/WebAuthenticatorCoordinator.cpp	2019-10-23 19:34:32 UTC (rev 251488)
+++ trunk/Source/WebKit/WebProcess/WebAuthentication/WebAuthenticatorCoordinator.cpp	2019-10-23 19:36:43 UTC (rev 251489)
@@ -34,6 +34,7 @@
 #include <WebCore/PublicKeyCredentialCreationOptions.h>
 #include <WebCore/PublicKeyCredentialData.h>
 #include <WebCore/PublicKeyCredentialRequestOptions.h>
+#include <WebCore/SecurityOrigin.h>
 
 namespace WebKit {
 using namespace WebCore;
@@ -43,20 +44,20 @@
 {
 }
 
-void WebAuthenticatorCoordinator::makeCredential(const Frame& frame, const Vector<uint8_t>& hash, const PublicKeyCredentialCreationOptions& options, RequestCompletionHandler&& handler)
+void WebAuthenticatorCoordinator::makeCredential(const Frame& frame, const SecurityOrigin& origin, const Vector<uint8_t>& hash, const PublicKeyCredentialCreationOptions& options, RequestCompletionHandler&& handler)
 {
     auto* webFrame = WebFrame::fromCoreFrame(frame);
     if (!webFrame)
         return;
-    m_webPage.sendWithAsyncReply(Messages::WebAuthenticatorCoordinatorProxy::MakeCredential(webFrame->frameID(), hash, options), WTFMove(handler));
+    m_webPage.sendWithAsyncReply(Messages::WebAuthenticatorCoordinatorProxy::MakeCredential(webFrame->frameID(), origin.data(), hash, options), WTFMove(handler));
 }
 
-void WebAuthenticatorCoordinator::getAssertion(const Frame& frame, const Vector<uint8_t>& hash, const PublicKeyCredentialRequestOptions& options, RequestCompletionHandler&& handler)
+void WebAuthenticatorCoordinator::getAssertion(const Frame& frame, const SecurityOrigin& origin, const Vector<uint8_t>& hash, const PublicKeyCredentialRequestOptions& options, RequestCompletionHandler&& handler)
 {
     auto* webFrame = WebFrame::fromCoreFrame(frame);
     if (!webFrame)
         return;
-    m_webPage.sendWithAsyncReply(Messages::WebAuthenticatorCoordinatorProxy::GetAssertion(webFrame->frameID(), hash, options), WTFMove(handler));
+    m_webPage.sendWithAsyncReply(Messages::WebAuthenticatorCoordinatorProxy::GetAssertion(webFrame->frameID(), origin.data(), hash, options), WTFMove(handler));
 }
 
 void WebAuthenticatorCoordinator::isUserVerifyingPlatformAuthenticatorAvailable(QueryCompletionHandler&& handler)

Modified: trunk/Source/WebKit/WebProcess/WebAuthentication/WebAuthenticatorCoordinator.h (251488 => 251489)


--- trunk/Source/WebKit/WebProcess/WebAuthentication/WebAuthenticatorCoordinator.h	2019-10-23 19:34:32 UTC (rev 251488)
+++ trunk/Source/WebKit/WebProcess/WebAuthentication/WebAuthenticatorCoordinator.h	2019-10-23 19:36:43 UTC (rev 251489)
@@ -39,8 +39,8 @@
 
 private:
     // WebCore::AuthenticatorCoordinatorClient
-    void makeCredential(const WebCore::Frame&, const Vector<uint8_t>&, const WebCore::PublicKeyCredentialCreationOptions&, WebCore::RequestCompletionHandler&&) final;
-    void getAssertion(const WebCore::Frame&, const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialRequestOptions&, WebCore::RequestCompletionHandler&&) final;
+    void makeCredential(const WebCore::Frame&, const WebCore::SecurityOrigin&, const Vector<uint8_t>&, const WebCore::PublicKeyCredentialCreationOptions&, WebCore::RequestCompletionHandler&&) final;
+    void getAssertion(const WebCore::Frame&, const WebCore::SecurityOrigin&, const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialRequestOptions&, WebCore::RequestCompletionHandler&&) final;
     void isUserVerifyingPlatformAuthenticatorAvailable(WebCore::QueryCompletionHandler&&) final;
 
     WebPage& m_webPage;

Modified: trunk/Tools/ChangeLog (251488 => 251489)


--- trunk/Tools/ChangeLog	2019-10-23 19:34:32 UTC (rev 251488)
+++ trunk/Tools/ChangeLog	2019-10-23 19:36:43 UTC (rev 251489)
@@ -1,3 +1,19 @@
+2019-10-22  Jiewen Tan  <[email protected]>
+
+        [WebAuthn] Supply FrameInfo in -[WKUIDelegatePrivate _webView:runWebAuthenticationPanel:initiatedByFrame:completionHandler:]
+        https://bugs.webkit.org/show_bug.cgi?id=202563
+        <rdar://problem/55973968>
+
+        Reviewed by Brent Fulgham.
+
+        Adds new test contents into existing tests.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm:
+        (-[TestWebAuthenticationPanelUIDelegate init]):
+        (-[TestWebAuthenticationPanelUIDelegate _webView:runWebAuthenticationPanel:initiatedByFrame:completionHandler:]):
+        (-[TestWebAuthenticationPanelUIDelegate frame]):
+        (TestWebKitAPI::TEST):
+
 2019-10-23  Wenson Hsieh  <[email protected]>
 
         Unreviewed, fix tvOS and watchOS engineering builds after r251377

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm (251488 => 251489)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm	2019-10-23 19:34:32 UTC (rev 251488)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm	2019-10-23 19:36:43 UTC (rev 251489)
@@ -89,12 +89,16 @@
 @implementation TestWebAuthenticationPanelUIDelegate {
     RetainPtr<NSObject<_WKWebAuthenticationPanelDelegate>> _delegate;
     BlockPtr<void(_WKWebAuthenticationPanelResult)> _callback;
+    RetainPtr<WKFrameInfo> _frameInfo;
 }
 
 - (instancetype)init
 {
-    if (self = [super init])
+    if (self = [super init]) {
         self.isRacy = false;
+        self.isFake = false;
+        self.isNull = false;
+    }
     return self;
 }
 
@@ -101,6 +105,7 @@
 - (void)_webView:(WKWebView *)webView runWebAuthenticationPanel:(_WKWebAuthenticationPanel *)panel initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(_WKWebAuthenticationPanelResult))completionHandler
 {
     webAuthenticationPanelRan = true;
+    _frameInfo = frame;
 
     if (!_isNull) {
         if (!_isFake)
@@ -124,6 +129,11 @@
     completionHandler(_WKWebAuthenticationPanelResultPresented);
 }
 
+- (WKFrameInfo *)frame
+{
+    return _frameInfo.get();
+}
+
 @end
 
 namespace TestWebKitAPI {
@@ -172,6 +182,16 @@
     gPanel = nullptr;
 }
 
+static void checkFrameInfo(WKFrameInfo *frame, bool isMainFrame, NSString *url, NSString *protocol, NSString *host, int port, WKWebView *webView)
+{
+    EXPECT_EQ(frame.mainFrame, isMainFrame);
+    EXPECT_TRUE([frame.request.URL.absoluteString isEqual:url]);
+    EXPECT_WK_STREQ(frame.securityOrigin.protocol, protocol);
+    EXPECT_WK_STREQ(frame.securityOrigin.host, host);
+    EXPECT_EQ(frame.securityOrigin.port, port);
+    EXPECT_EQ(frame.webView, webView);
+}
+
 } // namesapce;
 
 TEST(WebAuthenticationPanel, NoPanelTimeout)
@@ -232,6 +252,9 @@
     [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
     Util::run(&webAuthenticationPanelRan);
     Util::run(&webAuthenticationPanelSucceded);
+
+    // A bit of extra checks.
+    checkFrameInfo([delegate frame], true, [testURL absoluteString], @"file", @"", 0, webView.get());
 }
 
 #if HAVE(NEAR_FIELD)
@@ -409,10 +432,15 @@
     auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
     [webView setUIDelegate:delegate.get()];
 
-    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:(id)makeString("http://localhost:", static_cast<unsigned>(server.port()))]]];
+    auto port = static_cast<unsigned>(server.port());
+    auto url = "" port);
+    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:(id)url]]];
     Util::run(&webAuthenticationPanelRan);
     [webView evaluateJavaScript:@"theFrame.src = ''" completionHandler:nil];
     Util::run(&webAuthenticationPanelFailed);
+
+    // A bit of extra checks.
+    checkFrameInfo([delegate frame], false, (id)makeString(url, "/iFrame.html"), @"http", @"localhost", port, webView.get());
 }
 
 TEST(WebAuthenticationPanel, SubFrameDestructionHidCancel)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to