286ad37951b9a90b7700753a647a2e84ded96e93
[WebKit-https.git] / LayoutTests / http / tests / media / media-source / mediasource-is-type-supported.html
1 <!DOCTYPE html>
2 <html>
3     <head>
4         <script src="/w3c/resources/testharness.js"></script>
5         <script src="/w3c/resources/testharnessreport.js"></script>
6     </head>
7     <body>
8         <div id="log"></div>
9         <script>
10           // Generate a distinct test for each type in types
11           function test_type_support(types, expectation, description)
12           {
13               for (var i = 0; i < types.length; ++i) {
14                   test(function()
15                   {
16                       assert_equals(MediaSource.isTypeSupported(types[i]),
17                                     expectation, 'supported');
18                   },  description + ' "' + types[i] + '"');
19               }
20           };
21
22           test_type_support([
23               'video',
24               'video/',
25               'video/webm',
26               'video/webm;',
27               'video/webm;codecs',
28               'video/webm;codecs=',
29               'video/webm;codecs="',
30               'video/webm;codecs=""',
31               'video/webm;codecs=","',
32           ], false, 'Test invalid MIME format');
33
34           test_type_support([
35               'audio/webm;codecs="vp8"',
36               'audio/mp4;codecs="avc1.4d001e"',
37           ], false, 'Test invalid mismatch between major type and codec ID');
38
39           test_type_support([
40               'audio/mp4;codecs="vorbis"',
41               'audio/webm;codecs="mp4a.40.2"',
42               'video/mp4;codecs="vp8"',
43               'video/webm;codecs="mp4a.40.2"',
44               'video/mp4;codecs="vorbis"',
45               'video/webm;codecs="mp4a.40.2"',
46           ], false, 'Test invalid mismatch between minor type and codec ID');
47
48           test_type_support([
49               'audio/mp4;codecs="mp4a"',
50               'audio/mp4;codecs="mp4a.40"',
51               'audio/mp4;codecs="mp4a.40."',
52               'audio/mp4;codecs="mp4a.67.3"'
53           ], false, 'Test invalid codec ID');
54
55           test_type_support([
56               'video/webm;codecs="vp8"',
57               'video/webm;codecs="vorbis"',
58               'video/webm;codecs="vp8,vorbis"',
59               'video/webm;codecs="vorbis, vp8"',
60               'audio/webm;codecs="vorbis"',
61           ], true, 'Test valid WebM type');
62
63           test_type_support([
64               'video/mp4;codecs="avc1.4d001e"', // H.264 Main Profile level 3.0
65               'video/mp4;codecs="avc1.42001e"', // H.264 Baseline Profile level 3.0
66               'audio/mp4;codecs="mp4a.40.2"',   // MPEG4 AAC-LC
67               'audio/mp4;codecs="mp4a.40.5"',   // MPEG4 HE-AAC
68               'audio/mp4;codecs="mp4a.67"',     // MPEG2 AAC-LC
69               'video/mp4;codecs="mp4a.40.2"',
70               'video/mp4;codecs="avc1.4d001e,mp4a.40.2"',
71               'video/mp4;codecs="mp4a.40.2 , avc1.4d001e "',
72               'video/mp4;codecs="avc1.4d001e,mp4a.40.5"',
73           ], true, 'Test valid MP4 type');
74         </script>
75     </body>
76 </html>