<!DOCTYPE HTML>
<html>
    <head>
        <script src="../../resources/js-test-pre.js"></script>
        <script>
            var mediaStream;

            function testWhenEnabled(nextTest)
            {
                navigator.mediaDevices
                    .getUserMedia({audio:{}, video:{}})
                    .then(function(stream) {
                        mediaStream = stream;
                        shouldBeType("mediaStream", "Object");
                        shouldBe("mediaStream.getTracks().length", "2");

                        if (nextTest)
                            nextTest();
                        else
                            finishJSTest();
                    })
                    .catch(function(err) {
                        testFailed(`mediaDevices.getUserMedia() failed with ${err.name}`);
                        finishJSTest();
                    });
            }

            function start()
            {
                debug(`<br>*** Mock capture devices should be enabled by default`);
                testWhenEnabled();
            }

        </script>
    </head>

    <body onload="start()">
        <p id="description"></p>
        <div id="console"></div>
        <script>
            description("Test mock media capture devices");
            window.jsTestIsAsync = true;

            window.successfullyParsed = true;
        </script>
        <script src="../../resources/js-test-post.js"></script>
    </body>
</html>
