Changeset 251498 in webkit
- Timestamp:
- Oct 23, 2019 1:59:52 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r251495 r251498 1 2019-10-22 Jiewen Tan <jiewen_tan@apple.com> 2 3 [WebAuthn] Add more information to _WKWebAuthenticationPanel 4 https://bugs.webkit.org/show_bug.cgi?id=202561 5 <rdar://problem/55973910> 6 7 Reviewed by Youenn Fablet. 8 9 Covered by new tests within existing test files. 10 11 * Modules/webauthn/AuthenticatorCoordinator.cpp: 12 * Modules/webauthn/WebAuthenticationConstants.h: 13 1 14 2019-10-23 Chris Dumez <cdumez@apple.com> 2 15 -
trunk/Source/WebCore/Modules/webauthn/AuthenticatorCoordinator.cpp
r251489 r251498 43 43 #include "LegacySchemeRegistry.h" 44 44 #include "SecurityOrigin.h" 45 #include "WebAuthenticationConstants.h" 45 46 #include <pal/crypto/CryptoDigest.h> 46 47 #include <wtf/JSONValues.h> … … 51 52 52 53 namespace AuthenticatorCoordinatorInternal { 53 54 enum class ClientDataType {55 Create,56 Get57 };58 54 59 55 // FIXME(181948): Add token binding ID. -
trunk/Source/WebCore/Modules/webauthn/WebAuthenticationConstants.h
r245638 r251498 71 71 const char noneAttestationValue[] = "none"; 72 72 73 // https://www.w3.org/TR/webauthn-1/#dom-collectedclientdata-type 74 enum class ClientDataType : bool { 75 Create, 76 Get 77 }; 78 73 79 } // namespace WebCore -
trunk/Source/WebKit/ChangeLog
r251494 r251498 1 2019-10-22 Jiewen Tan <jiewen_tan@apple.com> 2 3 [WebAuthn] Add more information to _WKWebAuthenticationPanel 4 https://bugs.webkit.org/show_bug.cgi?id=202561 5 <rdar://problem/55973910> 6 7 Reviewed by Youenn Fablet. 8 9 This change adds transports and type to _WKWebAuthenticationPanel such that 10 clients can know what transport the current ceremony demands and the type of 11 the current ceremony. These extra information allow clients to give users 12 more specific instructions to interact with authenticators. 13 14 To pass transports to client, the way how them is collected is changed significantly: 15 1) The timing is moved to runPanel before the client delegate call. 16 2) NfcService::isAvailable is added for AuthenticatorManager to determine if NFC 17 is available in the current device. 18 3) AuthenticatorManager::filterTransports is added to filter transports requested 19 by RP to ones that are available. This process is handled by each service naturally 20 before. 21 4) AuthenticatorManager::startRequest is now being splitted into AuthenticatorManager::handleRequest, 22 AuthenticatorManager::runPanel and AuthenticatorManager::getTransports. 23 24 To pass type to _WKWebAuthenticationPanel, ClientDataType is moved from 25 WebCore::AuthenticatorCoordinator to WebCore::WebAuthenticationConstants in 26 order to be reused to indicate the ceremony type. 27 28 * UIProcess/API/APIWebAuthenticationPanel.cpp: 29 (API::WebAuthenticationPanel::create): 30 (API::WebAuthenticationPanel::WebAuthenticationPanel): 31 * UIProcess/API/APIWebAuthenticationPanel.h: 32 * UIProcess/API/Cocoa/_WKWebAuthenticationPanel.h: 33 * UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm: 34 (-[_WKWebAuthenticationPanel relyingPartyID]): 35 (wkWebAuthenticationTransport): 36 (-[_WKWebAuthenticationPanel transports]): 37 (wkWebAuthenticationType): 38 (-[_WKWebAuthenticationPanel type]): 39 * UIProcess/WebAuthentication/AuthenticatorManager.cpp: 40 (WebKit::WebCore::collectTransports): 41 (WebKit::WebCore::getClientDataType): 42 (WebKit::AuthenticatorManager::handleRequest): 43 (WebKit::AuthenticatorManager::filterTransports const): 44 (WebKit::AuthenticatorManager::startDiscovery): 45 (WebKit::AuthenticatorManager::initTimeOutTimer): 46 (WebKit::AuthenticatorManager::runPanel): 47 (WebKit::AuthenticatorManager::getTransports const): 48 (WebKit::AuthenticatorManager::respondReceivedInternal): Deleted. 49 (WebKit::AuthenticatorManager::startRequest): Deleted. 50 * UIProcess/WebAuthentication/AuthenticatorManager.h: 51 (WebKit::AuthenticatorManager::respondReceivedInternal): 52 * UIProcess/WebAuthentication/Cocoa/NfcService.h: 53 * UIProcess/WebAuthentication/Cocoa/NfcService.mm: 54 (WebKit::NfcService::isAvailable): 55 (WebKit::NfcService::platformStartDiscovery): 56 * UIProcess/WebAuthentication/Mock/MockAuthenticatorManager.cpp: 57 (WebKit::MockAuthenticatorManager::filterTransports const): 58 * UIProcess/WebAuthentication/Mock/MockAuthenticatorManager.h: 59 1 60 2019-10-23 Yury Semikhatsky <yurys@chromium.org> 2 61 -
trunk/Source/WebKit/UIProcess/API/APIWebAuthenticationPanel.cpp
r251494 r251498 31 31 #include "APIWebAuthenticationPanelClient.h" 32 32 #include "AuthenticatorManager.h" 33 #include <WebCore/WebAuthenticationConstants.h> 33 34 34 35 namespace API { 36 using namespace WebCore; 35 37 using namespace WebKit; 36 38 37 Ref<WebAuthenticationPanel> WebAuthenticationPanel::create(const AuthenticatorManager& manager, const WTF::String& rpId )39 Ref<WebAuthenticationPanel> WebAuthenticationPanel::create(const AuthenticatorManager& manager, const WTF::String& rpId, const TransportSet& transports, ClientDataType type) 38 40 { 39 return adoptRef(*new WebAuthenticationPanel(manager, rpId ));41 return adoptRef(*new WebAuthenticationPanel(manager, rpId, transports, type)); 40 42 } 41 43 42 WebAuthenticationPanel::WebAuthenticationPanel(const AuthenticatorManager& manager, const WTF::String& rpId )44 WebAuthenticationPanel::WebAuthenticationPanel(const AuthenticatorManager& manager, const WTF::String& rpId, const TransportSet& transports, ClientDataType type) 43 45 : m_manager(makeWeakPtr(manager)) 44 46 , m_rpId(rpId) 45 47 , m_client(WTF::makeUniqueRef<WebAuthenticationPanelClient>()) 48 , m_clientDataType(type) 46 49 { 50 m_transports = Vector<AuthenticatorTransport>(); 51 m_transports.reserveInitialCapacity(AuthenticatorManager::maxTransportNumber); 52 if (transports.contains(AuthenticatorTransport::Usb)) 53 m_transports.uncheckedAppend(AuthenticatorTransport::Usb); 54 if (transports.contains(AuthenticatorTransport::Nfc)) 55 m_transports.uncheckedAppend(AuthenticatorTransport::Nfc); 47 56 } 48 57 -
trunk/Source/WebKit/UIProcess/API/APIWebAuthenticationPanel.h
r251494 r251498 29 29 30 30 #include "APIObject.h" 31 #include <WebCore/AuthenticatorTransport.h> 31 32 #include <wtf/UniqueRef.h> 32 33 #include <wtf/WeakPtr.h> 33 34 #include <wtf/text/WTFString.h> 35 36 namespace WebCore { 37 enum class ClientDataType : bool; 38 } 34 39 35 40 namespace WebKit { … … 43 48 class WebAuthenticationPanel final : public ObjectImpl<Object::Type::WebAuthenticationPanel>, public CanMakeWeakPtr<WebAuthenticationPanel> { 44 49 public: 45 static Ref<WebAuthenticationPanel> create(const WebKit::AuthenticatorManager&, const WTF::String& rpId); 50 using TransportSet = HashSet<WebCore::AuthenticatorTransport, WTF::IntHash<WebCore::AuthenticatorTransport>, WTF::StrongEnumHashTraits<WebCore::AuthenticatorTransport>>; 51 52 static Ref<WebAuthenticationPanel> create(const WebKit::AuthenticatorManager&, const WTF::String& rpId, const TransportSet&, WebCore::ClientDataType); 46 53 ~WebAuthenticationPanel(); 47 54 48 55 WTF::String rpId() const { return m_rpId; } 56 const Vector<WebCore::AuthenticatorTransport>& transports() const { return m_transports; } 57 WebCore::ClientDataType clientDataType() const { return m_clientDataType; } 49 58 void cancel() const; 50 59 … … 53 62 54 63 private: 55 WebAuthenticationPanel(const WebKit::AuthenticatorManager&, const WTF::String& rpId );64 WebAuthenticationPanel(const WebKit::AuthenticatorManager&, const WTF::String& rpId, const TransportSet&, WebCore::ClientDataType); 56 65 57 66 WeakPtr<WebKit::AuthenticatorManager> m_manager; 58 67 WTF::String m_rpId; 59 68 UniqueRef<WebAuthenticationPanelClient> m_client; 69 Vector<WebCore::AuthenticatorTransport> m_transports; 70 WebCore::ClientDataType m_clientDataType; 60 71 }; 61 72 -
trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.h
r250658 r251498 50 50 } WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); 51 51 52 typedef NS_ENUM(NSInteger, _WKWebAuthenticationTransport) { 53 _WKWebAuthenticationTransportUSB, 54 _WKWebAuthenticationTransportNFC, 55 } WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); 56 57 typedef NS_ENUM(NSInteger, _WKWebAuthenticationType) { 58 _WKWebAuthenticationTypeCreate, 59 _WKWebAuthenticationTypeGet, 60 } WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); 61 52 62 @protocol _WKWebAuthenticationPanelDelegate <NSObject> 53 63 … … 64 74 @property (nullable, nonatomic, weak) id <_WKWebAuthenticationPanelDelegate> delegate; 65 75 @property (nonatomic, readonly, copy) NSString *relyingPartyID; 76 @property (nonatomic, readonly, copy) NSArray *transports; 77 @property (nonatomic, readonly) _WKWebAuthenticationType type; 66 78 67 79 - (void)cancel; -
trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm
r251295 r251498 27 27 #import "WebAuthenticationPanelClient.h" 28 28 #import "_WKWebAuthenticationPanelInternal.h" 29 #import <WebCore/WebAuthenticationConstants.h> 29 30 30 31 #import <wtf/RetainPtr.h> … … 34 35 WeakPtr<WebKit::WebAuthenticationPanelClient> _client; 35 36 #endif 37 RetainPtr<NSMutableArray> _transports; 36 38 } 37 39 … … 43 45 44 46 [super dealloc]; 45 }46 47 - (NSString *)relyingPartyID48 {49 return _panel->rpId();50 47 } 51 48 … … 62 59 _client = makeWeakPtr(client.get()); 63 60 _panel->setClient(WTFMove(client)); 61 } 62 63 64 - (NSString *)relyingPartyID 65 { 66 return _panel->rpId(); 67 } 68 69 static _WKWebAuthenticationTransport wkWebAuthenticationTransport(WebCore::AuthenticatorTransport transport) 70 { 71 switch (transport) { 72 case WebCore::AuthenticatorTransport::Usb: 73 return _WKWebAuthenticationTransportUSB; 74 case WebCore::AuthenticatorTransport::Nfc: 75 return _WKWebAuthenticationTransportNFC; 76 default: 77 ASSERT_NOT_REACHED(); 78 return _WKWebAuthenticationTransportUSB; 79 } 80 } 81 82 - (NSArray *)transports 83 { 84 if (_transports) 85 return _transports.get(); 86 87 auto& transports = _panel->transports(); 88 _transports = [[NSMutableArray alloc] initWithCapacity:transports.size()]; 89 for (auto& transport : transports) 90 [_transports addObject:adoptNS([[NSNumber alloc] initWithInt:wkWebAuthenticationTransport(transport)]).get()]; 91 return _transports.get(); 92 } 93 94 static _WKWebAuthenticationType wkWebAuthenticationType(WebCore::ClientDataType type) 95 { 96 switch (type) { 97 case WebCore::ClientDataType::Create: 98 return _WKWebAuthenticationTypeCreate; 99 case WebCore::ClientDataType::Get: 100 return _WKWebAuthenticationTypeGet; 101 default: 102 ASSERT_NOT_REACHED(); 103 return _WKWebAuthenticationTypeCreate; 104 } 105 } 106 107 - (_WKWebAuthenticationType)type 108 { 109 return wkWebAuthenticationType(_panel->clientDataType()); 64 110 } 65 111 -
trunk/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.cpp
r251489 r251498 32 32 #include "APIWebAuthenticationPanel.h" 33 33 #include "APIWebAuthenticationPanelClient.h" 34 #include "LocalService.h" 35 #include "NfcService.h" 34 36 #include "WebPageProxy.h" 35 37 #include "WebPreferencesKeys.h" 36 38 #include <WebCore/AuthenticatorTransport.h> 37 39 #include <WebCore/PublicKeyCredentialCreationOptions.h> 40 #include <WebCore/WebAuthenticationConstants.h> 38 41 #include <wtf/MonotonicTime.h> 39 42 … … 42 45 43 46 namespace { 44 45 const size_t maxTransportNumber = 3;46 47 47 48 // Suggested by WebAuthN spec as of 7 August 2018. … … 109 110 continue; 110 111 result.add(transport); 111 if (result.size() >= maxTransportNumber)112 if (result.size() >= AuthenticatorManager::maxTransportNumber) 112 113 return result; 113 114 } 114 115 } 115 116 116 ASSERT(result.size() < maxTransportNumber);117 ASSERT(result.size() < AuthenticatorManager::maxTransportNumber); 117 118 return result; 118 119 } … … 142 143 } 143 144 145 static ClientDataType getClientDataType(const Variant<PublicKeyCredentialCreationOptions, PublicKeyCredentialRequestOptions>& options) 146 { 147 if (WTF::holds_alternative<PublicKeyCredentialCreationOptions>(options)) 148 return ClientDataType::Create; 149 return ClientDataType::Get; 150 } 151 144 152 } // namespace 153 154 const size_t AuthenticatorManager::maxTransportNumber = 3; 145 155 146 156 AuthenticatorManager::AuthenticatorManager() … … 162 172 163 173 // 2. Ask clients to show appropriate UI if any and then start the request. 174 initTimeOutTimer(); 164 175 runPanel(); 165 176 } … … 255 266 } 256 267 257 void AuthenticatorManager::respondReceivedInternal(Respond&&) 258 { 268 void AuthenticatorManager::filterTransports(TransportSet& transports) const 269 { 270 if (!NfcService::isAvailable()) 271 transports.remove(AuthenticatorTransport::Nfc); 272 if (!LocalService::isAvailable()) 273 transports.remove(AuthenticatorTransport::Internal); 259 274 } 260 275 261 276 void AuthenticatorManager::startDiscovery(const TransportSet& transports) 262 277 { 278 ASSERT(RunLoop::isMain()); 263 279 ASSERT(m_services.isEmpty() && transports.size() <= maxTransportNumber); 264 280 for (auto& transport : transports) { 265 if (transport == AuthenticatorTransport::Internal && !isFeatureEnabled(m_pendingRequestData.page.get(), WebPreferencesKey::webAuthenticationLocalAuthenticatorEnabledKey()))266 continue;267 281 // Only allow USB authenticators when clients don't have dedicated UI. 268 282 if (transport != AuthenticatorTransport::Usb && (m_pendingRequestData.panelResult == WebAuthenticationPanelResult::Unavailable)) … … 274 288 } 275 289 276 void AuthenticatorManager::initTimeOutTimer(const Optional<unsigned>& timeOutInMs) 277 { 290 void AuthenticatorManager::initTimeOutTimer() 291 { 292 Optional<unsigned> timeOutInMs; 293 WTF::switchOn(m_pendingRequestData.options, [&](const PublicKeyCredentialCreationOptions& options) { 294 timeOutInMs = options.timeout; 295 }, [&](const PublicKeyCredentialRequestOptions& options) { 296 timeOutInMs = options.timeout; 297 }); 298 278 299 unsigned timeOutInMsValue = std::min(maxTimeOutValue, timeOutInMs.valueOr(maxTimeOutValue)); 279 300 m_requestTimeOutTimer.startOneShot(Seconds::fromMilliseconds(timeOutInMsValue)); … … 297 318 return; 298 319 299 m_pendingRequestData.panel = API::WebAuthenticationPanel::create(*this, getRpId(m_pendingRequestData.options)); 320 // Get available transports and start discovering authenticators on them. 321 auto& options = m_pendingRequestData.options; 322 auto transports = getTransports(); 323 m_pendingRequestData.panel = API::WebAuthenticationPanel::create(*this, getRpId(options), transports, getClientDataType(options)); 300 324 auto& panel = *m_pendingRequestData.panel; 301 page->uiClient().runWebAuthenticationPanel(*page, panel, *frame, m_pendingRequestData.origin, [ weakPanel = makeWeakPtr(panel), weakThis = makeWeakPtr(*this), this] (WebAuthenticationPanelResult result) {325 page->uiClient().runWebAuthenticationPanel(*page, panel, *frame, m_pendingRequestData.origin, [transports = WTFMove(transports), weakPanel = makeWeakPtr(panel), weakThis = makeWeakPtr(*this), this] (WebAuthenticationPanelResult result) { 302 326 // The panel address is used to determine if the current pending request is still the same. 303 327 if (!weakThis || !weakPanel … … 306 330 return; 307 331 m_pendingRequestData.panelResult = result; 308 startRequest(); 309 }); 310 } 311 312 void AuthenticatorManager::startRequest() 313 { 314 ASSERT(RunLoop::isMain()); 315 // Get available transports and start discovering authenticators on them. 316 WTF::switchOn(m_pendingRequestData.options, [&](const PublicKeyCredentialCreationOptions& options) { 317 initTimeOutTimer(options.timeout); 318 319 auto transports = collectTransports(options.authenticatorSelection); 320 processGoogleLegacyAppIdSupportExtension(options.extensions, transports); 321 startDiscovery(collectTransports(options.authenticatorSelection)); 322 }, [&](const PublicKeyCredentialRequestOptions& options) { 323 initTimeOutTimer(options.timeout); 324 startDiscovery(collectTransports(options.allowCredentials)); 332 startDiscovery(transports); 325 333 }); 326 334 } … … 331 339 WTF::switchOn(respond, [&](const WebCore::PublicKeyCredentialData&) { 332 340 panel->client().dismissPanel(WebAuthenticationResult::Succeeded); 333 }, [&](const 341 }, [&](const WebCore::ExceptionData&) { 334 342 panel->client().dismissPanel(WebAuthenticationResult::Failed); 335 343 }); … … 346 354 } 347 355 356 auto AuthenticatorManager::getTransports() const -> TransportSet 357 { 358 TransportSet transports; 359 WTF::switchOn(m_pendingRequestData.options, [&](const PublicKeyCredentialCreationOptions& options) { 360 transports = collectTransports(options.authenticatorSelection); 361 processGoogleLegacyAppIdSupportExtension(options.extensions, transports); 362 }, [&](const PublicKeyCredentialRequestOptions& options) { 363 transports = collectTransports(options.allowCredentials); 364 }); 365 if (!isFeatureEnabled(m_pendingRequestData.page.get(), WebPreferencesKey::webAuthenticationLocalAuthenticatorEnabledKey())) 366 transports.remove(AuthenticatorTransport::Internal); 367 filterTransports(transports); 368 return transports; 369 } 370 348 371 } // namespace WebKit 349 372 -
trunk/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.h
r251317 r251498 56 56 using WeakValueType = AuthenticatorTransportService::Observer::WeakValueType; 57 57 58 const static size_t maxTransportNumber; 59 58 60 AuthenticatorManager(); 59 61 virtual ~AuthenticatorManager() = default; … … 83 85 virtual UniqueRef<AuthenticatorTransportService> createService(WebCore::AuthenticatorTransport, AuthenticatorTransportService::Observer&) const; 84 86 // Overriden to return every exception for tests to confirm. 85 virtual void respondReceivedInternal(Respond&&); 87 virtual void respondReceivedInternal(Respond&&) { } 88 virtual void filterTransports(TransportSet&) const; 86 89 87 90 void startDiscovery(const TransportSet&); 88 void initTimeOutTimer( const Optional<unsigned>& timeOutInMs);91 void initTimeOutTimer(); 89 92 void timeOutTimerFired(); 90 93 void runPanel(); 91 void startRequest();92 94 void resetState(); 95 TransportSet getTransports() const; 93 96 94 97 // Request: We only allow one request per time. A new request will cancel any pending ones. -
trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/NfcService.h
r249059 r251498 41 41 ~NfcService(); 42 42 43 static bool isAvailable(); 44 43 45 // For NfcConnection. 44 46 void didConnectTag(); -
trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/NfcService.mm
r250729 r251498 49 49 } 50 50 51 bool NfcService::isAvailable() 52 { 53 #if HAVE(NEAR_FIELD) 54 return [[getNFHardwareManagerClass() sharedHardwareManager] areFeaturesSupported:NFFeatureReaderMode outError:nil]; 55 #else 56 return false; 57 #endif 58 } 59 51 60 void NfcService::didConnectTag() 52 61 { … … 71 80 { 72 81 #if HAVE(NEAR_FIELD) 73 if (! [[getNFHardwareManagerClass() sharedHardwareManager] areFeaturesSupported:NFFeatureReaderMode outError:nil])82 if (!isAvailable()) 74 83 return; 75 84 -
trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockAuthenticatorManager.cpp
r250940 r251498 51 51 } 52 52 53 void MockAuthenticatorManager::filterTransports(TransportSet& transports) const 54 { 55 if (!m_testConfiguration.nfc) 56 transports.remove(AuthenticatorTransport::Nfc); 57 if (!m_testConfiguration.local) 58 transports.remove(AuthenticatorTransport::Internal); 59 } 60 53 61 } // namespace WebKit 54 62 -
trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockAuthenticatorManager.h
r250940 r251498 43 43 UniqueRef<AuthenticatorTransportService> createService(WebCore::AuthenticatorTransport, AuthenticatorTransportService::Observer&) const final; 44 44 void respondReceivedInternal(Respond&&) final; 45 void filterTransports(TransportSet&) const; 45 46 46 47 WebCore::MockWebAuthenticationConfiguration m_testConfiguration; -
trunk/Tools/ChangeLog
r251497 r251498 1 2019-10-22 Jiewen Tan <jiewen_tan@apple.com> 2 3 [WebAuthn] Add more information to _WKWebAuthenticationPanel 4 https://bugs.webkit.org/show_bug.cgi?id=202561 5 <rdar://problem/55973910> 6 7 Reviewed by Youenn Fablet. 8 9 Adds new API tests. 10 11 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 12 * TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm: 13 (-[TestWebAuthenticationPanelUIDelegate _webView:runWebAuthenticationPanel:initiatedByFrame:completionHandler:]): 14 (-[TestWebAuthenticationPanelUIDelegate panel]): 15 (TestWebKitAPI::TEST): 16 * TestWebKitAPI/Tests/WebKitCocoa/web-authentication-make-credential-hid.html: Added. 17 1 18 2019-10-23 Aakash Jain <aakash_jain@apple.com> 2 19 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r251384 r251498 351 351 5797FE311EB15A6800B2F4A0 /* NavigationClientDefaultCrypto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5797FE2F1EB15A5F00B2F4A0 /* NavigationClientDefaultCrypto.cpp */; }; 352 352 5797FE331EB15AB100B2F4A0 /* navigation-client-default-crypto.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5797FE321EB15A8900B2F4A0 /* navigation-client-default-crypto.html */; }; 353 5798337E236019A4008E5547 /* web-authentication-make-credential-hid.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5798337D2360196D008E5547 /* web-authentication-make-credential-hid.html */; }; 353 354 57A79857224AB34E00A7F6F1 /* WebCryptoMasterKey.mm in Sources */ = {isa = PBXBuildFile; fileRef = 57A79856224AB34E00A7F6F1 /* WebCryptoMasterKey.mm */; }; 354 355 57C3FA661F7C248F009D4B80 /* WeakPtr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1CB9BC371A67482300FE5678 /* WeakPtr.cpp */; }; … … 1127 1128 dstSubfolderSpec = 7; 1128 1129 files = ( 1130 5798337E236019A4008E5547 /* web-authentication-make-credential-hid.html in Copy Resources */, 1129 1131 55A817FF2181021A0004A39A /* 100x100-red.tga in Copy Resources */, 1130 1132 1A9E52C913E65EF4006917F5 /* 18-characters.html in Copy Resources */, … … 1888 1890 5797FE2F1EB15A5F00B2F4A0 /* NavigationClientDefaultCrypto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NavigationClientDefaultCrypto.cpp; sourceTree = "<group>"; }; 1889 1891 5797FE321EB15A8900B2F4A0 /* navigation-client-default-crypto.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "navigation-client-default-crypto.html"; sourceTree = "<group>"; }; 1892 5798337D2360196D008E5547 /* web-authentication-make-credential-hid.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "web-authentication-make-credential-hid.html"; sourceTree = "<group>"; }; 1890 1893 5798E2AF1CAF5C2800C5CBA0 /* ProvisionalURLNotChange.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ProvisionalURLNotChange.mm; sourceTree = "<group>"; }; 1891 1894 57A79856224AB34E00A7F6F1 /* WebCryptoMasterKey.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCryptoMasterKey.mm; sourceTree = "<group>"; }; … … 3412 3415 577454D12359BAD5008E1ED7 /* web-authentication-get-assertion-u2f-no-credentials.html */, 3413 3416 57C6244F2346C1EC00383FE7 /* web-authentication-get-assertion.html */, 3417 5798337D2360196D008E5547 /* web-authentication-make-credential-hid.html */, 3414 3418 51714EB21CF8C761004723C4 /* WebProcessKillIDBCleanup-1.html */, 3415 3419 51714EB31CF8C761004723C4 /* WebProcessKillIDBCleanup-2.html */, -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm
r251489 r251498 44 44 static bool webAuthenticationPanelSucceded = false; 45 45 static bool webAuthenticationPanelUpdateNoCredentialsFound = false; 46 static RetainPtr<_WKWebAuthenticationPanel> gPanel;47 46 48 47 @interface TestWebAuthenticationPanelDelegate : NSObject <_WKWebAuthenticationPanelDelegate> … … 91 90 BlockPtr<void(_WKWebAuthenticationPanelResult)> _callback; 92 91 RetainPtr<WKFrameInfo> _frameInfo; 92 RetainPtr<_WKWebAuthenticationPanel> _panel; 93 93 } 94 94 … … 115 115 } 116 116 ASSERT_NE(panel, nil); 117 gPanel = panel; 118 [gPanel setDelegate:_delegate.get()]; 119 120 EXPECT_TRUE([[gPanel relyingPartyID] isEqual:@""] || [[gPanel relyingPartyID] isEqual:@"localhost"]); 117 _panel = panel; 118 [_panel setDelegate:_delegate.get()]; 121 119 122 120 if (_isRacy) { … … 133 131 { 134 132 return _frameInfo.get(); 133 } 134 135 - (_WKWebAuthenticationPanel *)panel 136 { 137 return _panel.get(); 135 138 } 136 139 … … 180 183 webAuthenticationPanelFailed = false; 181 184 webAuthenticationPanelSucceded = false; 182 gPanel = nullptr; 185 } 186 187 static void checkPanel(_WKWebAuthenticationPanel *panel, NSString *relyingPartyID, NSArray *transports, _WKWebAuthenticationType type) 188 { 189 EXPECT_WK_STREQ(panel.relyingPartyID, relyingPartyID); 190 191 // Brute force given the maximum size of the array is 4. 192 auto *theTransports = panel.transports; 193 EXPECT_EQ(theTransports.count, transports.count); 194 size_t count = 0; 195 for (NSNumber *transport : transports) { 196 for (NSNumber *theTransport : theTransports) { 197 if (transport == theTransport) { 198 count++; 199 break; 200 } 201 } 202 } 203 EXPECT_EQ(count, transports.count); 204 205 EXPECT_EQ(panel.type, type); 183 206 } 184 207 … … 238 261 } 239 262 240 TEST(WebAuthenticationPanel, PanelHidSuccess )263 TEST(WebAuthenticationPanel, PanelHidSuccess1) 241 264 { 242 265 reset(); … … 256 279 // A bit of extra checks. 257 280 checkFrameInfo([delegate frame], true, [testURL absoluteString], @"file", @"", 0, webView.get()); 281 checkPanel([delegate panel], @"", @[adoptNS([[NSNumber alloc] initWithInt:_WKWebAuthenticationTransportUSB]).get()], _WKWebAuthenticationTypeGet); 282 } 283 284 TEST(WebAuthenticationPanel, PanelHidSuccess2) 285 { 286 reset(); 287 RetainPtr<NSURL> testURL = [[NSBundle mainBundle] URLForResource:@"web-authentication-make-credential-hid" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]; 288 289 auto *configuration = [WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"WebProcessPlugInWithInternals" configureJSCForTesting:YES]; 290 [[configuration preferences] _setEnabled:YES forExperimentalFeature:webAuthenticationExperimentalFeature()]; 291 292 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]); 293 auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]); 294 [webView setUIDelegate:delegate.get()]; 295 296 [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]]; 297 Util::run(&webAuthenticationPanelRan); 298 Util::run(&webAuthenticationPanelSucceded); 299 300 // A bit of extra checks. 301 checkPanel([delegate panel], @"", @[adoptNS([[NSNumber alloc] initWithInt:_WKWebAuthenticationTransportUSB]).get()], _WKWebAuthenticationTypeCreate); 258 302 } 259 303 … … 280 324 [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]]; 281 325 [webView waitForMessage:@"Succeeded!"]; 326 327 // A bit of extra checks. 328 checkPanel([delegate panel], @"", @[adoptNS([[NSNumber alloc] initWithInt:_WKWebAuthenticationTransportNFC]).get()], _WKWebAuthenticationTypeGet); 282 329 } 283 330 … … 442 489 // A bit of extra checks. 443 490 checkFrameInfo([delegate frame], false, (id)makeString(url, "/iFrame.html"), @"http", @"localhost", port, webView.get()); 491 checkPanel([delegate panel], @"localhost", @[adoptNS([[NSNumber alloc] initWithInt:_WKWebAuthenticationTransportUSB]).get()], _WKWebAuthenticationTypeGet); 444 492 } 445 493 … … 495 543 [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]]; 496 544 Util::run(&webAuthenticationPanelRan); 497 [ gPanelcancel];545 [[delegate panel] cancel]; 498 546 [webView waitForMessage:@"Operation timed out."]; 499 547 EXPECT_FALSE(webAuthenticationPanelFailed);
Note: See TracChangeset
for help on using the changeset viewer.