blob: 2e5ec88213c6e64e73f6c25e28bfa0dd73fd1cf4 [file] [log] [blame]
jiewen_tan@apple.com3ca06422018-01-25 01:28:47 +00001<!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.com11cf65d2018-02-15 19:02:50 +000014 // A mock assertion return bundle.
15 internals.mockCredentialsMessenger.setAssertionReturnBundle(hexStringToUint8Array('00'), hexStringToUint8Array('01'), hexStringToUint8Array('02'), hexStringToUint8Array('03'));
jiewen_tan@apple.com3ca06422018-01-25 01:28:47 +000016
17 return navigator.credentials.get(options).then(function(credential) {
jiewen_tan@apple.com11cf65d2018-02-15 19:02:50 +000018 assert_equals(credential.id, 'AA');
jiewen_tan@apple.com3ca06422018-01-25 01:28:47 +000019 assert_equals(credential.type, 'public-key');
jiewen_tan@apple.com11cf65d2018-02-15 19:02:50 +000020 assert_equals(bytesToHexString(credential.rawId), '00');
jiewen_tan@apple.com3ca06422018-01-25 01:28:47 +000021 assert_equals(bytesToASCIIString(credential.response.clientDataJSON), '{"type":"webauthn.get","challenge":"MTIzNDU2","origin":"https://localhost:9443","hashAlgorithm":"SHA-256"}');
jiewen_tan@apple.com11cf65d2018-02-15 19:02:50 +000022 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.com3ca06422018-01-25 01:28:47 +000025 try {
26 assert_throws("NotSupportedError", credential.getClientExtensionResults());
27 } catch(error) { }
28 });
29 }, "PublicKeyCredential's [[get]] with minimum options");
30</script>