tor-browser

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

test_seamless_looping_duration.html (1905B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4 <title>Seamless looping test duration</title>
      5 <script src="/tests/SimpleTest/SimpleTest.js"></script>
      6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
      7 <script type="text/javascript" src="manifest.js"></script>
      8 </head>
      9 <script type="application/javascript">
     10 
     11 /**
     12 * This test aims to check that the media duration shouldn't be changed during
     13 * seamless looping.
     14 */
     15 add_task(async function testSeamlessLoopingDuration() {
     16  info(`create video and play it`);
     17  let video = document.createElement('video');
     18  video.loop = true;
     19  video.src = "gizmo-short.mp4";
     20  document.body.appendChild(video);
     21  await video.play();
     22 
     23  video.ondurationchange =
     24      _ => ok(false, "shouldn't change duration during looping!");
     25 
     26  info(`test seamless looping multiples times`);
     27  let MAX_LOOPING_COUNT = 10;
     28  for (let count = 0; count < MAX_LOOPING_COUNT; count++) {
     29    await once(video, "seeking");
     30    await once(video, "seeked");
     31    ok(true, `the round ${count} of the seamless looping succeeds`);
     32  }
     33 });
     34 
     35 // This one tests the situation where both tracks reached EOS before entering
     36 // looping state.
     37 add_task(async function testSeamlessLoopingDuration2() {
     38  info(`create video and play it to the end`);
     39  let video = document.createElement('video');
     40  video.src = "gizmo-short.mp4";
     41  document.body.appendChild(video);
     42  await video.play();
     43  await once(video, "ended");
     44 
     45  info(`play video again`);
     46  video.ondurationchange =
     47      _ => ok(false, "shouldn't change duration during looping!");
     48  video.loop = true;
     49  await video.play();
     50 
     51  info(`test seamless looping multiples times`);
     52  let MAX_LOOPING_COUNT = 10;
     53  for (let count = 0; count < MAX_LOOPING_COUNT; count++) {
     54    await once(video, "seeking");
     55    await once(video, "seeked");
     56    ok(true, `the round ${count} of the seamless looping succeeds`);
     57  }
     58 });
     59 
     60 </script>
     61 <body>
     62 </body>
     63 </html>