tor-browser

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

missing-sinf.html (2517B)


      1 <!doctype html>
      2 <html>
      3  <head>
      4    <meta charset=utf-8>
      5    <title>Missing scheme information box in protected sample entry</title>
      6    <link rel="help" href="https://w3c.github.io/encrypted-media/">
      7 
      8    <!-- Web Platform Test Harness scripts -->
      9    <script src=/resources/testharness.js></script>
     10    <script src=/resources/testharnessreport.js></script>
     11 
     12    <!-- Content metadata -->
     13    <script src=/encrypted-media/content/content-metadata.js></script>
     14  </head>
     15  <body>
     16    <div id='log'></div>
     17    <div id='audio'>
     18      <audio id="audioelement" width="200px"></video>
     19    </div>
     20  </body>
     21  <script>
     22 const contentItem = content['mp4-av-multikey'];
     23 const audio = document.getElementById('audioelement');
     24 
     25 // Test that a non conforming mp4 protected sample entry triggers the append
     26 // error algorithm.
     27 // https://w3c.github.io/media-source/#sourcebuffer-segment-parser-loop
     28 // 2. If the [[input buffer]] contains bytes that violate the SourceBuffer
     29 //    byte stream format specification, then run the append error algorithm and
     30 //    abort this algorithm.
     31 promise_test(async t => {
     32  audio.watcher = new EventWatcher(t, audio, ['error']);
     33 
     34  const response = await fetch(contentItem.audio.path);
     35  assert_true(response.ok, 'response.ok');
     36  const audioMedia = new Uint8Array(await response.arrayBuffer());
     37 
     38  const source = new MediaSource();
     39  source.watcher = new EventWatcher(t, source, ['sourceopen']);
     40  audio.src = URL.createObjectURL(source);
     41  await source.watcher.wait_for('sourceopen');
     42 
     43  const mediaType = contentItem.audio.type;
     44  assert_implements_optional(MediaSource.isTypeSupported(mediaType),
     45                             `${mediaType} supported`);
     46  const buffer = source.addSourceBuffer(mediaType);
     47  buffer.watcher = new EventWatcher(t, buffer, ['error', 'updateend']);
     48 
     49  // ISO/IEC 14496-12:2015(E)
     50  // 8.12.1 Protection Scheme Information Box
     51  // 8.12.1.1 Definition
     52  // "At least one protection scheme information box must occur in a protected
     53  //  sample entry."
     54  //
     55  // Change the 'sinf' box type to 'sin ' so that there is no protection
     56  // scheme information box in the protected sample entry.
     57  // 4-byte offset for the `type` field after `size` and 3 bytes to index the
     58  // last character of the type.
     59  audioMedia[contentItem.audio.sinfStart + 4 + 3] = ' '.charCodeAt();
     60 
     61  buffer.appendBuffer(audioMedia);
     62  await Promise.all([
     63    buffer.watcher.wait_for(['error', 'updateend']),
     64    audio.watcher.wait_for('error'),
     65  ]);
     66 }, 'missing-sinf');
     67  </script>
     68 </html>