tor-browser

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

mediasource-invalid-codec.html (1976B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4    <meta charset="utf-8">
      5    <title>SourceBuffer handling of invalid codecs in the initialization segment</title>
      6    <link rel="author" title="Alicia Boya GarcĂ­a" href="mailto:aboya@igalia.com">
      7    <script src="/resources/testharness.js"></script>
      8    <script src="/resources/testharnessreport.js"></script>
      9    <script src="mediasource-util.js"></script>
     10 </head>
     11 <body>
     12 <div id="log"></div>
     13 <script>
     14    function testInvalidCodec(test, mediaElement, mediaSource, mediaType, url) {
     15        assert_true(MediaSource.isTypeSupported(mediaType), `Media type not supported in this browser: isTypeSupported('${mediaType}')`);
     16 
     17        MediaSourceUtil.loadBinaryData(test, url, (mediaData) => {
     18            _testInvalidCodecWithData(test, mediaElement, mediaSource, mediaType, mediaData);
     19        });
     20    }
     21 
     22    function _testInvalidCodecWithData(test, mediaElement, mediaSource, mediaType, mediaData) {
     23        const sourceBuffer = mediaSource.addSourceBuffer(mediaType);
     24        sourceBuffer.appendBuffer(mediaData);
     25        test.expectEvent(sourceBuffer, 'error', 'Append ended with error');
     26        test.waitForExpectedEvents(() => {
     27            test.done();
     28        })
     29    }
     30 
     31    // These test cases provide a typical media MIME type, but the actual files have been mangled to declare a different,
     32    // unsupported, fictitious codec (MP4 fourcc: 'zzzz', WebM codec id 'V_ZZZ'). The browser should report a parsing
     33    // error.
     34 
     35    mediasource_test((test, mediaElement, mediaSource) => {
     36        testInvalidCodec(test, mediaElement, mediaSource, 'video/mp4;codecs="avc1.4D4001"', 'mp4/invalid-codec.mp4');
     37    }, 'Test an MP4 with an invalid codec results in an error.');
     38 
     39    mediasource_test((test, mediaElement, mediaSource) => {
     40        testInvalidCodec(test, mediaElement, mediaSource, 'video/webm; codecs="vp8"', 'webm/invalid-codec.webm');
     41    }, 'Test a WebM with an invalid codec results in an error.');
     42 
     43 </script>
     44 </body>
     45 </html>