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