tor-browser

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

MediaRecorder-destroy-script-execution.html (4101B)


      1 <!doctype html>
      2 <meta charset="utf-8">
      3 <html>
      4 <title>MediaRecorder destroy script execution context</title>
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <body>
      8 <iframe src="support/MediaRecorder-iframe.html" id="subFrame-start" name="subFrameStart"></iframe>
      9 <iframe src="support/MediaRecorder-iframe.html" id="subFrame-stop" name="subFrameStop"></iframe>
     10 <iframe src="support/MediaRecorder-iframe.html" id="subFrame-allTrackEnded" name="subFrameAllTrackEnded"></iframe>
     11 <iframe src="support/MediaRecorder-iframe.html" id="subFrame-audioBitrateMode" name="subFrameAudioBitrateMode"></iframe>
     12 <script>
     13    var iframeForCallingStart = document.getElementById('subFrame-start');
     14    var iframeForCallingStop = document.getElementById('subFrame-stop');
     15    var iframeForAllTrackEnded = document.getElementById('subFrame-allTrackEnded');
     16    var iframeForAudioBitrateMode = document.getElementById('subFrame-audioBitrateMode');
     17 
     18    var testForCallingStart = async_test('MediaRecorder will throw when start() is called and the script execution context is going away');
     19    var testForCallingStop = async_test('MediaRecorder will not fire the stop event when stop() is called and the script execution context is going away');
     20    var testForAllTrackEnded = async_test('MediaRecorder will not fire the stop event when all tracks are ended and the script execution context is going away');
     21    var testForAudioBitrateMode = async_test('MediaRecorder will not crash on accessing audioBitrateMode when the script execution context is going away');
     22 
     23 
     24    iframeForCallingStart.onload = function(e) {
     25      let testWindow = subFrameStart.window;
     26      testWindow.prepareForTest(testForCallingStart);
     27      let exceptionCtor = testWindow.DOMException;
     28      const recorder = subFrameStart.window.recorder;
     29      iframeForCallingStart.remove();
     30      testForCallingStart.step(function() {
     31        assert_throws_dom('NotSupportedError', exceptionCtor, () => recorder.start(),
     32                         "MediaRecorder.start() should throw");
     33      });;
     34      testForCallingStart.done();
     35    };
     36 
     37    iframeForCallingStop.onload = function(e) {
     38        subFrameStop.window.prepareForTest(testForCallingStop);
     39        const recorder = subFrameStop.window.recorder;
     40        recorder.ondataavailable = testForCallingStop.step_func(blobEvent => {
     41            iframeForCallingStop.remove();
     42            testForCallingStop.step_timeout(testForCallingStop.step_func_done(), 0);
     43        });
     44        recorder.onstop = testForCallingStop.unreached_func('Unexpected stop event');
     45        recorder.start();
     46        testForCallingStop.step(function() {
     47          assert_equals(recorder.state, 'recording', 'MediaRecorder has been started successfully');
     48        });
     49        subFrameStop.window.control.addVideoFrame();
     50        recorder.stop();
     51    };
     52 
     53    iframeForAllTrackEnded.onload = function(e) {
     54        subFrameAllTrackEnded.window.prepareForTest(testForAllTrackEnded);
     55        const recorder = subFrameAllTrackEnded.window.recorder;
     56        recorder.ondataavailable = testForAllTrackEnded.step_func(blobEvent => {
     57            iframeForAllTrackEnded.remove();
     58            testForAllTrackEnded.step_timeout(testForAllTrackEnded.step_func_done(), 0);
     59        });
     60        recorder.onstop = testForAllTrackEnded.unreached_func('Unexpected stop event');
     61        recorder.start();
     62        testForAllTrackEnded.step(function() {
     63          assert_equals(recorder.state, 'recording', 'MediaRecorder has been started successfully');
     64        });
     65        subFrameAllTrackEnded.window.control.addVideoFrame();
     66        subFrameAllTrackEnded.window.video.getVideoTracks()[0].stop();
     67    };
     68 
     69    iframeForAudioBitrateMode.onload = testForAudioBitrateMode.step_func(function(e) {
     70        subFrameAudioBitrateMode.window.prepareForTest(testForAudioBitrateMode);
     71        const recorder = subFrameAudioBitrateMode.window.recorder;
     72        iframeForAudioBitrateMode.remove();
     73        recorder.audioBitrateMode;
     74        testForAudioBitrateMode.done();
     75    });
     76 
     77 </script>
     78 </body>
     79 </html>