tor-browser

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

test_MultipleInitSegments.html (1592B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <meta http-equiv="content-type" content="text/html; charset=windows-1252">
      5  <title>MSE: Append buffer with multiple init segments</title>
      6  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      7  <script type="text/javascript" src="mediasource.js"></script>
      8  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
      9 </head>
     10 <body>
     11 <pre id="test">
     12 <script class="testbody" type="text/javascript">
     13 
     14 SimpleTest.waitForExplicitFinish();
     15 
     16 runWithMSE(async (ms, v) => {
     17  await once(ms, "sourceopen");
     18  const sb = ms.addSourceBuffer("video/webm");
     19  const seek_lowres = await fetchWithXHR("seek_lowres.webm");
     20  const seek = await fetchWithXHR("seek.webm");
     21  const data = [
     22    [seek_lowres, 0, 438],     // lowres init segment
     23    [seek_lowres, 438, 25950], // lowres media segment 0-1
     24    [seek, 0, 318],            // init segment
     25    [seek, 46712, 67833],       // media segment 0.8-1.201
     26  ];
     27  const length = data.map(d => d[2] - d[1]).reduce((a, b) => a + b, 0);
     28  const arrayBuffer = new Uint8Array(length);
     29  let pos = 0;
     30  for (const d of data) {
     31    const buffer = new Uint8Array(d[0], d[1], d[2] - d[1]);
     32    arrayBuffer.set(buffer, pos);
     33    pos += buffer.byteLength;
     34  }
     35  await loadSegment(sb, arrayBuffer);
     36  // Since we are passing multiple segments in one buffer,
     37  // the first durationchange event from parsing the init
     38  // segment will be fired before updateend.
     39  const p = once(v, "durationchange");
     40  ms.endOfStream();
     41  await p;
     42  ok(v.duration, 1.201);
     43  SimpleTest.finish();
     44 });
     45 
     46 </script>
     47 </pre>
     48 </body>
     49 </html>