https://github.com/web-platform-tests/wpt
Revision 9454b8e581454d3bf0dabb368f4cf90c8e3dcc6c authored by Geoffrey Sneddon on 27 August 2018, 16:01:41 UTC, committed by James Graham on 14 November 2018, 11:37:48 UTC
1 parent beb9940
Raw File
Tip revision: 9454b8e581454d3bf0dabb368f4cf90c8e3dcc6c authored by Geoffrey Sneddon on 27 August 2018, 16:01:41 UTC
Fix #12578: make SeleniumExecutor/WebDriverExecutor use the right size for reftests
Tip revision: 9454b8e
MediaRecorder-stop.html
<!doctype html>
<html>
<head>
    <title>MediaRecorder Stop</title>
    <link rel="help" href="https://w3c.github.io/mediacapture-record/MediaRecorder.html#mediarecorder">
    <script src="/resources/testharness.js"></script>
    <script src="/resources/testharnessreport.js"></script>
</head>
<body>
<canvas id="canvas" width="200" height="200">
</canvas>
<script>
    function createVideoStream() {
        let canvas = document.getElementById("canvas");
        canvas.getContext('2d');
        return canvas.captureStream();
    }

    async_test(t => {
        let video = createVideoStream();
        let recorder = new MediaRecorder(video);
        recorder.onstop = t.step_func(errorEvent => {
            assert_equals(errorEvent.type, 'stop', 'the error type should be stop');
            assert_true(errorEvent.isTrusted, 'isTrusted should be true when the event is created by C++');
            assert_equals(recorder.state, "inactive", "MediaRecorder has been stopped when all tracks are ended");
            t.done();
        });
        assert_equals(video.getVideoTracks().length, 1, "video mediastream starts with one track");
        recorder.start();
        assert_equals(recorder.state, "recording", "MediaRecorder has been started successfully");
        video.getVideoTracks()[0].stop();
    }, "MediaRecorder will stop recording and fire a stop event when all tracks are ended");

    async_test(t => {
        let video = createVideoStream();
        let recorder = new MediaRecorder(video);
        recorder.onstop = t.step_func(errorEvent => {
            assert_equals(errorEvent.type, 'stop', 'the error type should be stop');
            assert_true(errorEvent.isTrusted, 'isTrusted should be true when the event is created by C++');
            assert_equals(recorder.state, "inactive", "MediaRecorder has been stopped when stop() is called");
            t.done();
        });
        recorder.start();
        assert_equals(recorder.state, "recording", "MediaRecorder has been started successfully");
        recorder.stop();
        assert_equals(recorder.state, "recording", "State should remain the same until stop event is fired");
    }, "MediaRecorder will stop recording and fire a stop event when stop() is called");
</script>
</body>
</html>
back to top