jiewen_tan@apple.com | 3ca0642 | 2018-01-25 01:28:47 +0000 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <title>Web Authentication API: PublicKeyCredential's [[get]] success cases.</title> |
| 3 | <script src="/resources/testharness.js"></script> |
| 4 | <script src="/resources/testharnessreport.js"></script> |
| 5 | <script src="./resources/util.js"></script> |
| 6 | <script> |
| 7 | // The following test is specifically tuned for current dummy authenticator. |
| 8 | promise_test(function(t) { |
| 9 | const options = { |
| 10 | publicKey: { |
| 11 | challenge: Base64URL.parse("MTIzNDU2"), |
| 12 | } |
| 13 | }; |
jiewen_tan@apple.com | 11cf65d | 2018-02-15 19:02:50 +0000 | [diff] [blame] | 14 | // A mock assertion return bundle. |
| 15 | internals.mockCredentialsMessenger.setAssertionReturnBundle(hexStringToUint8Array('00'), hexStringToUint8Array('01'), hexStringToUint8Array('02'), hexStringToUint8Array('03')); |
jiewen_tan@apple.com | 3ca0642 | 2018-01-25 01:28:47 +0000 | [diff] [blame] | 16 | |
| 17 | return navigator.credentials.get(options).then(function(credential) { |
jiewen_tan@apple.com | 11cf65d | 2018-02-15 19:02:50 +0000 | [diff] [blame] | 18 | assert_equals(credential.id, 'AA'); |
jiewen_tan@apple.com | 3ca0642 | 2018-01-25 01:28:47 +0000 | [diff] [blame] | 19 | assert_equals(credential.type, 'public-key'); |
jiewen_tan@apple.com | 11cf65d | 2018-02-15 19:02:50 +0000 | [diff] [blame] | 20 | assert_equals(bytesToHexString(credential.rawId), '00'); |
jiewen_tan@apple.com | 3ca0642 | 2018-01-25 01:28:47 +0000 | [diff] [blame] | 21 | assert_equals(bytesToASCIIString(credential.response.clientDataJSON), '{"type":"webauthn.get","challenge":"MTIzNDU2","origin":"https://localhost:9443","hashAlgorithm":"SHA-256"}'); |
jiewen_tan@apple.com | 11cf65d | 2018-02-15 19:02:50 +0000 | [diff] [blame] | 22 | assert_equals(bytesToHexString(credential.response.authenticatorData), '01'); |
| 23 | assert_equals(bytesToHexString(credential.response.signature), '02'); |
| 24 | assert_equals(bytesToHexString(credential.response.userHandle), '03'); |
jiewen_tan@apple.com | 3ca0642 | 2018-01-25 01:28:47 +0000 | [diff] [blame] | 25 | try { |
| 26 | assert_throws("NotSupportedError", credential.getClientExtensionResults()); |
| 27 | } catch(error) { } |
| 28 | }); |
| 29 | }, "PublicKeyCredential's [[get]] with minimum options"); |
| 30 | </script> |