blob: 09afcb0e16e4738108b5e9c805faf7cb97fe4d98 [file] [log] [blame]
<!doctype html>
<html>
<head>
<meta charset=utf-8>
<title>IDL check of WebAuthN</title>
<link rel="help" href="https://www.w3.org/TR/webauthn/#idl-index">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/resources/WebIDLParser.js></script>
<script src=/resources/idlharness.js></script>
<script src="./resources/util.js"></script>
</head>
<body>
<h1 class="instructions">Description</h1>
<p class="instructions">This test verifies that the implementations of the WebAuthN API match with its WebIDL definition.</p>
<div id='log'></div>
<script>
promise_test(async () => {
const idlURL = ["WebAuthN.idl"];
const idlArray = new IdlArray();
const idlText = await fetch(idlURL).then(r => r.text());
idlArray.add_untested_idls("interface ArrayBuffer {};");
idlArray.add_untested_idls("dictionary CredentialCreationOptions {};");
idlArray.add_untested_idls("dictionary CredentialRequestOptions {};");
idlArray.add_idls(`
[Exposed=Window, SecureContext]
interface Credential {
readonly attribute USVString id;
readonly attribute DOMString type;
};
`);
idlArray.add_idls(idlText);
const creationOptions = {
publicKey: {
rp: {
name: "localhost",
},
user: {
name: testUserhandleBase64,
id: Base64URL.parse(testUserhandleBase64),
displayName: "Appleseed",
},
challenge: Base64URL.parse("MTIzNDU2"),
pubKeyCredParams: [{ type: "public-key", alg: -7 }],
}
};
// A mock attestation object
if (window.internals)
internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", payloadBase64: [testCreationMessageBase64] } });
createdCredential = await navigator.credentials.create(creationOptions);
const requestOptions = {
publicKey: {
challenge: Base64URL.parse("MTIzNDU2"),
}
};
if (window.internals)
internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", payloadBase64: [testAssertionMessageBase64] } });
requestedCredential = await navigator.credentials.get(requestOptions);
idlArray.add_objects({"PublicKeyCredential": ["createdCredential"], "AuthenticatorAttestationResponse": ["createdCredential.response"], "AuthenticatorAssertionResponse": ["requestedCredential.response"]});
idlArray.test();
}, "Setup for WebAuthN API IDL tests.");
</script>