blob: bb5548c90d0bcd0571b463ceedc987c535541fb3 [file] [log] [blame]
<!DOCTYPE html>
<title>Web Authentication API: PublicKeyCredential's [[create]] failure 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: "example.com"
},
user: {
name: "John Appleseed",
id: asciiToUint8Array("123456"),
displayName: "John",
},
challenge: asciiToUint8Array("123456"),
pubKeyCredParams: [{ type: "public-key", alg: -7 }],
timeout: 0,
}
};
internals.mockCredentialsMessenger.setDidTimeOut();
return promise_rejects(t, "NotAllowedError",
navigator.credentials.create(options));
}, "PublicKeyCredential's [[create]] with timeout");
promise_test(function(t) {
const options = {
publicKey: {
rp: {
name: "example.com",
id: "example.com"
},
user: {
name: "John Appleseed",
id: asciiToUint8Array("123456"),
displayName: "John",
},
challenge: asciiToUint8Array("123456"),
pubKeyCredParams: [{ type: "public-key", alg: -7 }],
}
};
return promise_rejects(t, "SecurityError",
navigator.credentials.create(options));
}, "PublicKeyCredential's [[create]] with a mismatched RP ID");
promise_test(function(t) {
const options = {
publicKey: {
rp: {
name: "localhost",
id: "localhost"
},
user: {
name: "John Appleseed",
id: asciiToUint8Array("123456"),
displayName: "Appleseed",
},
challenge: asciiToUint8Array("123456"),
pubKeyCredParams: [ ],
}
};
return promise_rejects(t, "NotSupportedError",
navigator.credentials.create(options));
}, "PublicKeyCredential's [[create]] with an empty pubKeyCredParams");
promise_test(function(t) {
const options = {
publicKey: {
rp: {
name: "localhost",
id: "localhost"
},
user: {
name: "John Appleseed",
id: asciiToUint8Array("123456"),
displayName: "John",
},
challenge: asciiToUint8Array("123456"),
pubKeyCredParams: [{ type: "public-key", alg: -7 }],
}
};
internals.mockCredentialsMessenger.setDidUserCancel();
return promise_rejects(t, "NotAllowedError",
navigator.credentials.create(options));
}, "PublicKeyCredential's [[create]] with user cancellations");
</script>