tor-browser

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

SourceBuffer-abort-removed.html (1808B)


      1 <!doctype html>
      2 <html>
      3 <head>
      4  <meta charset='utf-8'>
      5  <title>SourceBuffer#abort() for already removed buffer from parent media source</title>
      6  <script src="/resources/testharness.js"></script>
      7  <script src="/resources/testharnessreport.js"></script>
      8 </head>
      9 <body>
     10 <div id="log"></div>
     11 
     12 <script>
     13 var mimes = ['video/webm; codecs="vorbis,vp8"', 'video/mp4'];
     14 
     15 //check the browser supports the MIME used in this test
     16 function isTypeSupported(mime) {
     17    if(!MediaSource.isTypeSupported(mime)) {
     18        this.step(function() {
     19            assert_unreached("Browser doesn't support the MIME used in this test: " + mime);
     20        });
     21        this.done();
     22        return false;
     23    }
     24    return true;
     25 }
     26 function mediaTest(mime) {
     27    async_test(function(t) {
     28        if(!isTypeSupported.bind(t)(mime)) {
     29            return;
     30        }
     31        var mediaSource = new MediaSource();
     32        mediaSource.addEventListener('sourceopen', t.step_func_done(function(e) {
     33            var sourceBuffer = mediaSource.addSourceBuffer(mime);
     34            mediaSource.removeSourceBuffer(sourceBuffer);
     35            assert_throws_dom('InvalidStateError',
     36                              function() {
     37                                  sourceBuffer.abort();
     38                              },
     39                              'SourceBuffer#abort() after removing the SourceBuffer object');
     40        }), false);
     41        var video = document.createElement('video');
     42        video.src = window.URL.createObjectURL(mediaSource);
     43    }, 'SourceBuffer#abort (' + mime + ') : ' +
     44       'if this object has been removed from the sourceBuffers attribute of the parent media source, ' +
     45       'then throw an INVALID_STATE_ERR exception and abort these steps.');
     46 }
     47 mimes.forEach(function(mime) {
     48    mediaTest(mime);
     49 });
     50 </script>
     51 </body>
     52 </html>