tor-browser

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

test_WaitingOnMissingData.html (2461B)


      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  await once(ms, "sourceopen");
     16  ok(true, "Receive a sourceopen event");
     17  const sb = ms.addSourceBuffer("video/webm");
     18  sb.addEventListener("error", e => {
     19    ok(false, "Got Error: " + e);
     20    SimpleTest.finish();
     21  });
     22  const arrayBuffer = await fetchWithXHR("seek.webm");
     23  await loadSegment(sb, new Uint8Array(arrayBuffer, 0, 318));
     24  await loadSegment(sb, new Uint8Array(arrayBuffer, 318, 25223 - 318));
     25  await loadSegment(sb, new Uint8Array(arrayBuffer, 25223, 46712 - 25223));
     26  /* Note - Missing |46712, 67833 - 46712| segment here */
     27  await loadSegment(sb, new Uint8Array(arrayBuffer, 67833, 88966 - 67833));
     28  await loadSegment(sb, new Uint8Array(arrayBuffer, 88966));
     29  // HTMLMediaElement fires "waiting" if somebody invokes |play()| before the MDSM
     30  // has notified it of available data. Make sure that we get "playing" before
     31  // we starting waiting for "waiting".
     32  info("Invoking play()");
     33  let p = once(el, "playing");
     34  el.play();
     35  await p;
     36  ok(true, "Video playing. It should play for a bit, then fire 'waiting'");
     37  p = once(el, "waiting");
     38  el.play();
     39  await p;
     40  // currentTime is based on the current video frame, so if the audio ends just before
     41  // the next video frame, currentTime can be up to 1 frame's worth earlier than
     42  // min(audioEnd, videoEnd).
     43  // 0.0465 is the length of the last audio frame.
     44  ok(el.currentTime >= (sb.buffered.end(0) - 0.0465),
     45     `Got a waiting event at ${el.currentTime}`);
     46  info("Loading more data");
     47  p = once(el, "ended");
     48  await loadSegment(sb, new Uint8Array(arrayBuffer, 46712, 67833 - 46712));
     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, 4.001, 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 </script>
     58 </pre>
     59 </body>
     60 </html>