<!DOCTYPE html>
<title>Web Authentication API: Invoke PublicKeyCredential in ip addresses.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="util.js"></script>
<script>
    // Default mock configuration. Tests need to override if they need different configuration.
    if (window.internals)
        internals.setMockWebAuthenticationConfiguration({ });

    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 }],
            }
        };

        return promiseRejects(t, "SecurityError",
            navigator.credentials.create(options), "The effective domain of the document is not a valid domain.");
    }, "PublicKeyCredential's [[create]] with ip addresses.");

    promise_test(t => {
        const options = {
            publicKey: {
                challenge: asciiToUint8Array("123456")
            }
        };

        return promiseRejects(t, "SecurityError",
            navigator.credentials.get(options), "The effective domain of the document is not a valid domain.");
    }, "PublicKeyCredential's [[get]] with ip addresses.");
</script>
