Bug 1539614 [wpt PR 16077] - HTML: move textarea tests together, a=testonly
[gecko.git] / testing / web-platform / tests / media-source / mediasource-invalid-codec.html
blob19aa00c4d5f4966ef8a5de657341141f69c08ea3
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}')`);
17 MediaSourceUtil.loadBinaryData(test, url, (mediaData) => {
18 _testInvalidCodecWithData(test, mediaElement, mediaSource, mediaType, mediaData);
19 });
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();
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.
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.');
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.');
43 </script>
44 </body>
45 </html>