<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <title>OverConstrainedError.constraint testing</title>
        <script src="../../resources/testharness.js"></script>
        <script src="../../resources/testharnessreport.js"></script>
    </head>
    <body>

        <script>
if (window.testRunner)
    testRunner.setUserMediaPermission(true);

promise_test(async () => {
    return navigator.mediaDevices.getUserMedia({audio: {deviceId: {exact:"none"}}}).then(
        () => assert_not_reached("gum should fail"),
        (e) => {
            assert_true(e instanceof OverconstrainedError);
            assert_equals(e.constraint, "", "constraint should be the empty string");
            assert_equals(e.name, "OverconstrainedError", "OverconstrainedError name is correct");
        }
    );
}, "Before grant");

promise_test(async(test) => {
    await navigator.mediaDevices.getUserMedia({audio: true});
    return navigator.mediaDevices.getUserMedia({audio: {deviceId: {exact:"none"}}}).then(
        () => assert_not_reached("gum should fail"),
        (e) => {
            assert_true(e instanceof OverconstrainedError);
            assert_equals(e.constraint, "deviceId", "constraint should be deviceId");
            assert_equals(e.name, "OverconstrainedError", "OverconstrainedError name is correct");
        }
    );
}, "After grant");
        </script>
    </body>
</html>
