<!DOCTYPE html>
<title>Web Authentication API: PublicKeyCredential's [[get]] success cases with a mock hid authenticator.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="./resources/util.js"></script>
<script>
    // Default mock configuration. Tests need to override if they need different configuration.
    if (window.internals)
        internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", payloadBase64: [testAssertionMessageBase64] } });

    promise_test(t => {
        const options = {
            publicKey: {
                challenge: Base64URL.parse("MTIzNDU2"),
                timeout: 100
            }
        };

        return navigator.credentials.get(options).then(credential => {
            return checkCtapGetAssertionResult(credential);
        });
    }, "PublicKeyCredential's [[get]] with minimum options in a mock hid authenticator.");

    promise_test(t => {
        const options = {
            publicKey: {
                challenge: Base64URL.parse("MTIzNDU2"),
                allowCredentials: [
                    { type: "public-key", id: Base64URL.parse(testHidCredentialIdBase64), transports: ["usb"] }
                ],
                timeout: 100
            }
        };

        return navigator.credentials.get(options).then(credential => {
            return checkCtapGetAssertionResult(credential);
        });
    }, "PublicKeyCredential's [[get]] with matched allow credentials in a mock hid authenticator.");

    promise_test(t => {
        const options = {
            publicKey: {
                challenge: Base64URL.parse("MTIzNDU2"),
                userVerification: "preferred",
                timeout: 100
            }
        };

        return navigator.credentials.get(options).then(credential => {
            return checkCtapGetAssertionResult(credential);
        });
    }, "PublicKeyCredential's [[get]] with userVerification { preferred } in a mock hid authenticator.");

    promise_test(t => {
        const options = {
            publicKey: {
                challenge: Base64URL.parse("MTIzNDU2"),
                userVerification: "discouraged",
                timeout: 100
            }
        };

        return navigator.credentials.get(options).then(credential => {
            return checkCtapGetAssertionResult(credential);
        });
    }, "PublicKeyCredential's [[get]] with userVerification { discouraged } in a mock hid authenticator.");

    promise_test(t => {
        const options = {
            publicKey: {
                challenge: Base64URL.parse("MTIzNDU2"),
                allowCredentials: [
                    { type: "public-key", id: Base64URL.parse(testHidCredentialIdBase64), transports: ["usb"] }
                ],
                userVerification: "preferred",
                timeout: 100
            }
        };

        return navigator.credentials.get(options).then(credential => {
            return checkCtapGetAssertionResult(credential);
        });
    }, "PublicKeyCredential's [[get]] with mixed options in a mock hid authenticator.");

    promise_test(t => {
        const options = {
            publicKey: {
                challenge: Base64URL.parse("MTIzNDU2"),
                timeout: 100
            }
        };


        // Stall the first request to wait for cancellation.
        if (window.internals)
            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", payloadBase64: [testAssertionMessageBase64], expectCancel: true } });
        promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "This request has been cancelled by a new request.");
        if (window.internals)
            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", payloadBase64: [testAssertionMessageBase64] } });
        return navigator.credentials.get(options).then(credential => {
            return checkCtapGetAssertionResult(credential);
        });
    }, "PublicKeyCredential's [[get]] with two consecutive requests.");

    promise_test(t => {
        const options = {
            publicKey: {
                challenge: Base64URL.parse("MTIzNDU2"),
                timeout: 100
            }
        };

        if (window.internals)
            internals.setMockWebAuthenticationConfiguration({ hid: { stage: "request", subStage: "msg", error: "success", payloadBase64: [testAssertionMessageLongBase64, testAssertionMessageLongBase64] } });
        return navigator.credentials.get(options).then(credential => {
            return checkCtapGetAssertionResult(credential, "MIIBkzCCATigAwIBAjCCAZMwggE4oAMCAQIwggGTMII=");
        });
    }, "PublicKeyCredential's [[get]] with multiple accounts in a mock hid authenticator.");
</script>
