tor-browser

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

autoplay-with-slow-text-tracks.html (1376B)


      1 <!doctype html>
      2 <title>autoplay with slow text tracks</title>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <script src="/common/media.js"></script>
      6 <div id="log"></div>
      7 <script>
      8 setup({ single_test: true });
      9 // https://html.spec.whatwg.org/#ready-states says:
     10 //
     11 // HAVE_FUTURE_DATA: "the text tracks are ready".
     12 // HAVE_ENOUGH_DATA: All the conditions described for the HAVE_FUTURE_DATA state are met, ...
     13 //
     14 // When the ready state of a media element whose networkState is not NETWORK_EMPTY changes,
     15 // the user agent must follow the steps given below:
     16 // If the new ready state is HAVE_ENOUGH_DATA
     17 // (autoplay)
     18 //
     19 // So if the text tracks are not yet ready, we can't autoplay.
     20 
     21 var started = 0;
     22 var numOfTests = 5;
     23 
     24 function createTest() {
     25  var video = document.createElement('video');
     26  video.src = getVideoURI('/media/movie_5');
     27  video.autoplay = true;
     28  video.muted = true;
     29  video.controls = true;
     30  video.onplaying = function() {
     31    started++;
     32    assert_equals(track.track.cues.length, 1);
     33    if (started === numOfTests) {
     34      done();
     35    }
     36  };
     37  var track = document.createElement('track');
     38  track.src = '/media/foo.vtt?pipe=trickle(d2)';
     39  track.default = true;
     40  video.appendChild(track);
     41  document.body.appendChild(video);
     42 }
     43 for (var i = 0; i < numOfTests; ++i) {
     44  createTest();
     45 }
     46 </script>