tor-browser

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

test_WaitingOnMissingData_mp4.html (2538B)


      1 <!DOCTYPE html>
      2 <html><head>
      3 <meta http-equiv="content-type" content="text/html; charset=windows-1252">
      4  <title>MSE: |waiting| event when source data is missing</title>
      5  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      6  <script type="text/javascript" src="mediasource.js"></script>
      7  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
      8 </head>
      9 <body>
     10 <pre id="test"><script class="testbody" type="text/javascript">
     11 
     12 SimpleTest.waitForExplicitFinish();
     13 
     14 runWithMSE(async (ms, el) => {
     15  el.controls = true;
     16  await once(ms, "sourceopen");
     17  ok(true, "Receive a sourceopen event");
     18  const audiosb = ms.addSourceBuffer("audio/mp4");
     19  const videosb = ms.addSourceBuffer("video/mp4");
     20  await fetchAndLoad(audiosb, "bipbop/bipbop_audio", ["init"], ".mp4");
     21  await fetchAndLoad(audiosb, "bipbop/bipbop_audio", range(1, 5), ".m4s");
     22  await fetchAndLoad(audiosb, "bipbop/bipbop_audio", range(6, 12), ".m4s");
     23  await fetchAndLoad(videosb, "bipbop/bipbop_video", ["init"], ".mp4");
     24  await fetchAndLoad(videosb, "bipbop/bipbop_video", range(1, 6), ".m4s");
     25  await fetchAndLoad(videosb, "bipbop/bipbop_video", range(7, 14), ".m4s");
     26  // HTMLMediaElement fires "waiting" if somebody invokes |play()| before the MDSM
     27  // has notified it of available data. Make sure that we get "playing" before
     28  // we starting waiting for "waiting".
     29  info("Invoking play()");
     30  let p = once(el, "playing");
     31  el.play();
     32  await p;
     33  ok(true, "Video playing. It should play for a bit, then fire 'waiting'");
     34  p = once(el, "waiting");
     35  el.play();
     36  await p;
     37  // currentTime is based on the current video frame, so if the audio ends just before
     38  // the next video frame, currentTime can be up to 1 frame's worth earlier than
     39  // min(audioEnd, videoEnd).
     40  // 0.0465 is the length of the last audio frame.
     41  ok(el.currentTime >= (Math.min(audiosb.buffered.end(0), videosb.buffered.end(0)) - 0.0465),
     42     `Got a waiting event at ${el.currentTime}`);
     43  info("Loading more data");
     44  p = once(el, "ended");
     45  await Promise.all([
     46    fetchAndLoad(audiosb, "bipbop/bipbop_audio", [5], ".m4s"),
     47    fetchAndLoad(videosb, "bipbop/bipbop_video", [6], ".m4s"),
     48  ]);
     49  ms.endOfStream();
     50  await p;
     51  // These fuzz factors are bigger than they should be. We should investigate
     52  // and fix them in bug 1137574.
     53  isfuzzy(el.duration, 10.1, 0.1, "Video has correct duration: " + el.duration);
     54  isfuzzy(el.currentTime, el.duration, 0.1, "Video has correct currentTime.");
     55  SimpleTest.finish();
     56 });
     57 
     58 </script>
     59 </pre>
     60 </body>
     61 </html>