tor-browser

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

test_Eviction_mp4.html (2347B)


      1 <!DOCTYPE html>
      2 <html><head>
      3 <meta http-equiv="content-type" content="text/html; charset=windows-1252">
      4  <title>MSE: QuotaExceededError when source buffer is full</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 // We fill up the source buffer with audio data until the buffer is full.
     14 // We ensure that QuotaExceededError is thrown once the buffer is full.
     15 // We then seek to half the content. By that time, another appendBuffer must succeed
     16 // as the auto-eviction would succeed (removing all data prior currentTime)
     17 
     18 addMSEPrefs(
     19  ["media.mediasource.eviction_threshold.audio", 524288],
     20  ["media.dormant-on-pause-timeout-ms", -1] // FIXME: bug 1319292
     21 );
     22 
     23 runWithMSE(async (ms, el) => {
     24  el.controls = true;
     25  await once(ms, "sourceopen");
     26  ok(true, "Receive a sourceopen event");
     27  const audiosb = ms.addSourceBuffer("audio/mp4");
     28  audiosb.mode = "sequence";
     29  await fetchAndLoad(audiosb, "bipbop/bipbop_audio", ["init"], ".mp4");
     30  const audioBuffer = await fetchWithXHR("bipbop/bipbop_audio1.m4s");
     31 
     32  await must_reject(async () => {
     33    // We are appending data repeatedly in sequence mode, there should be no gaps.
     34    while (true) {
     35      ok(audiosb.buffered.length <= 1, "there should be no gap in buffered ranges.");
     36      audiosb.appendBuffer(audioBuffer);
     37      await once(audiosb, "updateend");
     38    }
     39  },
     40  "Fill up SourceBuffer by appending data until an exception is thrown.",
     41  "QuotaExceededError");
     42 
     43  is(audiosb.buffered.end(0), el.duration, "Duration is end of buffered range");
     44  const seekTime = audiosb.buffered.end(0) / 2;
     45  el.currentTime = seekTime;
     46  await once(el, "seeked");
     47  dump("dump: seeked to " + seekTime);
     48  is(el.currentTime, seekTime, "correctly seeked to " + seekTime);
     49  try {
     50    audiosb.appendBuffer(audioBuffer);
     51    await once(audiosb, "update");
     52    ok(true, "appendBuffer succeeded");
     53  } catch (ex) {
     54    ok(false, "Shouldn't throw another time when data can be evicted");
     55    dump(JSON.stringify(await SpecialPowers.wrap(el).mozRequestDebugInfo()));
     56  }
     57  SimpleTest.finish();
     58 });
     59 
     60 </script>
     61 </pre>
     62 </body>
     63 </html>