tor-browser

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

test_background_video_resume_looping_video_without_audio.html (2256B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <title>Resume suspended looping video which doesn't contain audio track</title>
      5  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      6  <script src="manifest.js"></script>
      7  <script src="background_video.js"></script>
      8  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
      9 </head>
     10 <body>
     11 <script class="testbody" type="text/javascript">
     12 /**
     13 * This test is used to ensure that the looping video (without audio track) which
     14 * has been suspended can continute to playback correctly after we resume video
     15 * decoding.
     16 */
     17 async function startTest() {
     18  const video = await createVisibleVideo();
     19  await startVideo(video);
     20  await suspendVideoDecoding(video);
     21  await resumeVideoDecoding(video);
     22  await checkIfVideoIsStillPlaying(video);
     23  endTestAndClearVideo(video);
     24 }
     25 
     26 SimpleTest.waitForExplicitFinish();
     27 SpecialPowers.pushPrefEnv({ 'set': [
     28    ["media.test.video-suspend", true],
     29    ["media.suspend-background-video.enabled", true],
     30    ["media.suspend-background-video.delay-ms", 0],
     31  ]}, () => {
     32  startTest();
     33 });
     34 
     35 /**
     36 * The following are test helper functions.
     37 */
     38 async function createVisibleVideo() {
     39  let video = document.createElement("video");
     40  video.src = "gizmo-noaudio.webm";
     41  video.controls = true;
     42  video.loop = true;
     43  document.body.appendChild(video);
     44  info(`ensure video becomes visible`);
     45  await waitUntilVisible(video);
     46  return video;
     47 }
     48 
     49 async function startVideo(video) {
     50  info(`start playing video`);
     51  const played = video && await video.play().then(() => true, () => false);
     52  ok(played, "video has started playing");
     53 }
     54 
     55 async function suspendVideoDecoding(video) {
     56  info(`suspend video decoding`);
     57  video.setVisible(false);
     58  await nextVideoSuspends(video);
     59  info(`suspended video decoding`);
     60 }
     61 
     62 async function resumeVideoDecoding(video) {
     63  info(`resume video decoding.`);
     64  video.setVisible(true);
     65  await nextVideoResumes(video);
     66  info(`resumed video decoding`);
     67 }
     68 
     69 async function checkIfVideoIsStillPlaying(video) {
     70  await once(video, "timeupdate");
     71  ok(!video.paused, "video is still playing after resuming video decoding.")
     72 }
     73 
     74 function endTestAndClearVideo(video) {
     75  removeNodeAndSource(video);
     76  SimpleTest.finish();
     77 }
     78 
     79 </script>
     80 </body>
     81 </html>