tor-browser

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

test_seamless_looping_media_element_state.html (1718B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4 <title>Seamless looping media element state</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 if the media element would change its ready state
     13 * under `HAVE_CURRENT_DATA` when the seamless looping is performed. Because
     14 * during seamless looping, we should always have current frame.
     15 */
     16 add_task(async function testSeamlessLoopingMediaElementState() {
     17  await SpecialPowers.pushPrefEnv({
     18    set: [
     19      ["media.seamless-looping-video", true],
     20    ],
     21  });
     22 
     23  info(`create video`);
     24  let video = document.createElement('video');
     25  video.loop = true;
     26  video.src = "gizmo-short.mp4";
     27  document.body.appendChild(video);
     28  await video.play();
     29 
     30  info(`test seamless looping multiples times`);
     31  let MAX_LOOPING_COUNT = 10;
     32  for (let count = 0; count < MAX_LOOPING_COUNT; count++) {
     33    await once(video, "seeking");
     34    // If the video looping is not seamless, when playback reaches to the end,
     35    // MDSM would trigger a seek in order to get the new frame from the start
     36    // position. That would notify the media element that the status of the next
     37    // frame is not available now due to seeking (NEXT_FRAME_UNAVAILABLE_SEEKING)
     38    // and causes the media element dispatching `waiting` event.
     39    video.onwaiting = () => {
     40      ok(false, "should not get waiting event");
     41    }
     42    await once(video, "seeked");
     43    video.onwaiting = null;
     44    ok(true, `the round ${count} of the seamless looping succeeds`);
     45  }
     46 });
     47 
     48 </script>
     49 <body>
     50 </body>
     51 </html>