blob: ab4fcc082d1a0bcdfba82b0abcec3ff6da170680 [file] [log] [blame]
<!DOCTYPE html>
<title>Web Authentication API: PublicKeyCredential's [[create]] success cases.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="./resources/util.js"></script>
<script>
promise_test(function(t) {
const options = {
publicKey: {
rp: {
name: "localhost",
},
user: {
name: "John Appleseed",
id: asciiToUint8Array("123456"),
displayName: "Appleseed",
},
challenge: Base64URL.parse("MTIzNDU2"),
pubKeyCredParams: [{ type: "public-key", alg: -7 }],
}
};
// A mock attestation object
internals.mockCredentialsMessenger.setCreationReturnBundle(hexStringToUint8Array('00'), hexStringToUint8Array('01'));
return navigator.credentials.create(options).then(function(credential) {
assert_equals(credential.id, 'AA');
assert_equals(credential.type, 'public-key');
assert_equals(bytesToHexString(credential.rawId), '00');
assert_equals(bytesToASCIIString(credential.response.clientDataJSON), '{"type":"webauthn.create","challenge":"MTIzNDU2","origin":"https://localhost:9443","hashAlgorithm":"SHA-256"}');
assert_equals(bytesToHexString(credential.response.attestationObject), '01');
console.log()
try {
assert_throws("NotSupportedError", credential.getClientExtensionResults());
} catch(error) { }
});
}, "PublicKeyCredential's [[create]] with minimum options");
</script>