<!DOCTYPE html><!-- webkit-test-runner -->
<title>Web Authentication API: PublicKeyCredential's [[create]] success cases with a mock ccid 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({ ccid: { payloadBase64: [testCcidNoUidBase64, 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 }]
            }
        };

        return navigator.credentials.create(options).then(credential => {
            checkCtapMakeCredentialResult(credential, true /* isNoneAttestation */, ["smart-card"]);
        });
    }, "PublicKeyCredential's [[create]] with minimum options in a mock ccid authenticator.");

    promise_test(t => {
        if (window.internals)
        internals.setMockWebAuthenticationConfiguration({ ccid: { payloadBase64: [testCcidValidUidBase64, testNfcCtapVersionBase64, testGetInfoResponseApduBase64, testCreationMessageApduBase64] } });
        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 }]
            }
        };

        return navigator.credentials.create(options).then(credential => {
            checkCtapMakeCredentialResult(credential, true /* isNoneAttestation */, ["nfc"]);
        });
    }, "PublicKeyCredential's [[create]] with minimum options in a mock ccid authenticator with contactless.");
</script>
