blob: 82d070618b3e033c348a7742c10af6ec11c66356 [file] [log] [blame]
<!DOCTYPE html>
<title>Web Authentication API: PublicKeyCredential's [[create]] success cases with a mock nfc authenticator.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="./resources/util.js"></script>
<script src="./resources/cbor.js"></script>
<script>
// Default mock configuration. Tests need to override if they need different configuration.
if (window.internals)
internals.setMockWebAuthenticationConfiguration({ nfc: { error: "success", payloadBase64: [testNfcCtapVersionBase64, testGetInfoResponseApduBase64, testCreationMessageApduBase64] } });
promise_test(t => {
const options = {
publicKey: {
rp: {
name: "localhost",
},
user: {
name: "John Appleseed",
id: Base64URL.parse(testUserhandleBase64),
displayName: "Appleseed",
},
challenge: Base64URL.parse("MTIzNDU2"),
pubKeyCredParams: [{ type: "public-key", alg: -7 }],
timeout: 100
}
};
return navigator.credentials.create(options).then(credential => {
checkCtapMakeCredentialResult(credential);
});
}, "PublicKeyCredential's [[create]] with minimum options in a mock nfc authenticator.");
promise_test(t => {
const options = {
publicKey: {
rp: {
name: "localhost",
},
user: {
name: "John Appleseed",
id: Base64URL.parse(testUserhandleBase64),
displayName: "Appleseed",
},
challenge: Base64URL.parse("MTIzNDU2"),
pubKeyCredParams: [{ type: "public-key", alg: -7 }],
authenticatorSelection: { authenticatorAttachment: "cross-platform" },
timeout: 100
}
};
return navigator.credentials.create(options).then(credential => {
checkCtapMakeCredentialResult(credential);
});
}, "PublicKeyCredential's [[create]] with authenticatorSelection { 'cross-platform' } in a mock nfc authenticator.");
promise_test(t => {
const options = {
publicKey: {
rp: {
name: "localhost",
},
user: {
name: "John Appleseed",
id: Base64URL.parse(testUserhandleBase64),
displayName: "Appleseed",
},
challenge: Base64URL.parse("MTIzNDU2"),
pubKeyCredParams: [{ type: "public-key", alg: -7 }],
timeout: 100
}
};
if (window.internals)
internals.setMockWebAuthenticationConfiguration({ nfc: { error: "success", payloadBase64: [testNfcCtapVersionBase64, testGetInfoResponseApduBase64, testCreationMessageApduBase64], multipleTags: true } });
return navigator.credentials.create(options).then(credential => {
checkCtapMakeCredentialResult(credential);
});
}, "PublicKeyCredential's [[create]] with multiple tags in a mock nfc authenticator.");
promise_test(t => {
const options = {
publicKey: {
rp: {
name: "localhost",
},
user: {
name: "John Appleseed",
id: Base64URL.parse(testUserhandleBase64),
displayName: "Appleseed",
},
challenge: Base64URL.parse("MTIzNDU2"),
pubKeyCredParams: [{ type: "public-key", alg: -7 }],
timeout: 100
}
};
if (window.internals)
internals.setMockWebAuthenticationConfiguration({ nfc: { error: "success", payloadBase64: [testNfcU2fVersionBase64, testU2fApduInsNotSupportedOnlyResponseBase64, testU2fRegisterResponse] } });
return navigator.credentials.create(options).then(credential => {
checkU2fMakeCredentialResult(credential);
});
}, "PublicKeyCredential's [[create]] with U2F in a mock nfc authenticator.");
</script>