tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

MediaRecorder-error.html (3629B)


      1 <!doctype html>
      2 <html>
      3 <head>
      4    <title>MediaRecorder Error</title>
      5    <link rel="help" href="https://w3c.github.io/mediacapture-record/MediaRecorder.html#mediarecorder">
      6    <script src="/resources/testharness.js"></script>
      7    <script src="/resources/testharnessreport.js"></script>
      8    <script src="utils/sources.js"></script>
      9 </head>
     10 <body>
     11 <script>
     12    async_test(t => {
     13        const {stream: video, control} = createVideoStream(t);
     14        const {stream: audio} = createAudioStream(t);
     15        const recorder = new MediaRecorder(video);
     16        recorder.onerror = t.step_func(event => {
     17            assert_true(event instanceof ErrorEvent, 'the type of event should be ErrorEvent');
     18            assert_equals(event.error.name, 'InvalidModificationError', 'the type of error should be InvalidModificationError when track has been added or removed');
     19            assert_true(event.isTrusted, 'isTrusted should be true when the event is created by C++');
     20            assert_equals(recorder.state, "inactive", "MediaRecorder has been stopped after adding a track to stream");
     21            t.done();
     22        });
     23        recorder.start();
     24        assert_equals(recorder.state, "recording", "MediaRecorder has been started successfully");
     25        video.addTrack(audio.getAudioTracks()[0]);
     26        control.addVideoFrame();
     27        t.step_timeout(() => {
     28            assert_unreached("error event is not fired after 2 seconds");
     29        }, 2000);
     30    }, "MediaRecorder will stop recording when any of track is added and error event will be fired");
     31 
     32    async_test(t => {
     33      const {stream: video, control} = createVideoStream(t);
     34        const recorder = new MediaRecorder(video);
     35        recorder.onerror = t.step_func(event => {
     36            assert_true(event instanceof ErrorEvent, 'the type of event should be ErrorEvent');
     37            assert_equals(event.error.name, 'InvalidModificationError', 'the type of error should be InvalidModificationError when track has been added or removed');
     38            assert_true(event.isTrusted, 'isTrusted should be true when the event is created by C++');
     39            assert_equals(recorder.state, "inactive", "MediaRecorder has been stopped after removing a track from stream");
     40            t.done();
     41        });
     42        recorder.start();
     43        assert_equals(recorder.state, "recording", "MediaRecorder has been started successfully");
     44        video.removeTrack(video.getVideoTracks()[0]);
     45        control.addVideoFrame();
     46        t.step_timeout(() => {
     47            assert_unreached("error event is not fired after 2 seconds");
     48        }, 2000);
     49    }, "MediaRecorder will stop recording when any of track is removed and error event will be fired");
     50 
     51    test(t => {
     52        const {stream: video} = createVideoStream(t);
     53        const recorder = new MediaRecorder(video);
     54        recorder.start();
     55        assert_equals(recorder.state, "recording", "MediaRecorder has been started successfully");
     56        assert_throws_dom("InvalidStateError", function() {
     57            recorder.start();
     58        });
     59    }, "MediaRecorder cannot start recording when MediaRecorder' state is not inactive and an InvalidStateError should be thrown");
     60    test(t => {
     61        const { stream: video } = createVideoStream(t);
     62        assert_throws_dom("NotSupportedError", function () {
     63            new MediaRecorder(video, {
     64                videoKeyFrameIntervalDuration: 10,
     65                videoKeyFrameIntervalCount: 10,
     66            });
     67        });
     68    }, "MediaRecorder throws NotSupportedError when given both videoKeyFrameIntervalDuration and videoKeyFrameIntervalCount");
     69 </script>
     70 </body>
     71 </html>