Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / media / encrypted-media / encrypted-media-requestmediakeysystemaccess.html
blob713774acb63596c720d8926719629e1bef11e2ad
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Test navigator.requestMediaKeySystemAccess()</title>
5 <script src="encrypted-media-utils.js"></script>
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 function expect_error(keySystem, configurations, expectedError, testName) {
13 promise_test(function(test) {
14 return navigator.requestMediaKeySystemAccess(keySystem, configurations).then(function(a) {
15 assert_unreached('Unexpected requestMediaKeySystemAccess() success.');
16 }, function(e) {
17 assert_equals(e.name, expectedError);
18 });
19 }, testName);
22 function assert_subset(actual, expected, path) {
23 if (typeof expected == 'string') {
24 assert_equals(actual, expected, path);
25 } else {
26 if (expected.hasOwnProperty('length'))
27 assert_equals(actual.length, expected.length, path + '.length');
28 for (property in expected)
29 assert_subset(actual[property], expected[property], path + '.' + property);
33 function expect_config(keySystem, configurations, expectedConfiguration, testName) {
34 promise_test(function(test) {
35 return navigator.requestMediaKeySystemAccess(keySystem, configurations).then(function(a) {
36 assert_subset(a.getConfiguration(), expectedConfiguration, 'getConfiguration()');
37 });
38 }, testName);
41 // Tests for keySystem.
42 expect_error('', [{}], 'InvalidAccessError', 'Empty keySystem');
43 expect_error('com.example.unsupported', [{}], 'NotSupportedError', 'Unsupported keySystem');
44 expect_error('org.w3.clearkey.', [{}], 'NotSupportedError', 'keySystem ends with "."');
45 expect_error('org.w3.ClearKey', [{}], 'NotSupportedError', 'Capitalized keySystem');
46 expect_error('org.w3.clearke\u028F', [{}], 'NotSupportedError', 'Non-ASCII keySystem');
48 // Parent of Clear Key not supported.
49 expect_error('org', [{}], 'NotSupportedError', 'Parent of Clear Key (org)');
50 expect_error('org.', [{}], 'NotSupportedError', 'Parent of Clear Key (org.)');
51 expect_error('org.w3', [{}], 'NotSupportedError', 'Parent of Clear Key (org.w3)');
52 expect_error('org.w3.', [{}], 'NotSupportedError', 'Parent of Clear Key (org.w3.)');
54 // Child of Clear Key not supported.
55 expect_error('org.w3.clearkey.foo', [{}], 'NotSupportedError', 'Child of Clear Key');
57 // Prefixed Clear Key not supported.
58 expect_error('webkit-org.w3.clearkey', [{}], 'NotSupportedError', 'Prefixed Clear Key');
60 // Incomplete names.
61 expect_error('org.w3.learkey', [{}], 'NotSupportedError', 'Incomplete name org.w3.learkey');
62 expect_error('org.w3.clearke', [{}], 'NotSupportedError', 'Incomplete name org.w3.clearke');
63 expect_error('or.w3.clearkey', [{}], 'NotSupportedError', 'Incomplete name or.w3.clearkey');
65 // Spaces in key system name not supported.
66 expect_error(' org.w3.clearkey', [{}], 'NotSupportedError', 'Leading space in key system name');
67 expect_error('org.w3. clearkey', [{}], 'NotSupportedError', 'Extra space in key system name');
68 expect_error('org.w3.clearkey ', [{}], 'NotSupportedError', 'Trailing space in key system name');
70 // Extra dots in key systems names not supported.
71 expect_error('.org.w3.clearkey', [{}], 'NotSupportedError', 'Leading dot in key systems name');
72 expect_error('org.w3.clearkey.', [{}], 'NotSupportedError', 'Trailing dot in key systems name');
73 expect_error('org.w3..clearkey', [{}], 'NotSupportedError', 'Double dot in key systems name');
74 expect_error('org.w3.clear.key', [{}], 'NotSupportedError', 'Extra dot in key systems name');
76 // Key system name is case sensitive.
77 expect_error('org.w3.Clearkey', [{}], 'NotSupportedError', 'Key system name is case sensitive');
78 expect_error('Org.w3.clearkey', [{}], 'NotSupportedError', 'Key system name is case sensitive');
80 // Tests for trivial configurations.
81 expect_error('org.w3.clearkey', [], 'InvalidAccessError', 'Empty supportedConfigurations');
82 expect_config('org.w3.clearkey', [{}], {}, 'Empty configuration');
84 // Various combinations of supportedConfigurations.
85 expect_config('org.w3.clearkey', [{
86 initDataTypes: ['webm'],
87 audioCapabilities: [{contentType: 'audio/webm'}],
88 videoCapabilities: [{contentType: 'video/webm'}],
89 }], {
90 initDataTypes: ['webm'],
91 audioCapabilities: [{contentType: 'audio/webm'}],
92 videoCapabilities: [{contentType: 'video/webm'}],
93 }, 'Basic supported configuration');
95 expect_config('org.w3.clearkey', [{
96 initDataTypes: ['fakeidt', 'webm'],
97 audioCapabilities: [{contentType: 'audio/fake'}, {contentType: 'audio/webm'}],
98 videoCapabilities: [{contentType: 'video/fake'}, {contentType: 'video/webm'}],
99 }], {
100 initDataTypes: ['webm'],
101 audioCapabilities: [{contentType: 'audio/webm'}],
102 videoCapabilities: [{contentType: 'video/webm'}],
103 }, 'Partially supported configuration');
105 expect_config('org.w3.clearkey', [{
106 audioCapabilities: [{contentType: 'audio/webm; codecs=vorbis'}],
107 }], {
108 audioCapabilities: [{contentType: 'audio/webm; codecs=vorbis'}],
109 }, 'Supported audio codec');
111 expect_config('org.w3.clearkey', [{
112 audioCapabilities: [{contentType: 'audio/webm; codecs="vorbis"'}],
113 }], {
114 audioCapabilities: [{contentType: 'audio/webm; codecs="vorbis"'}],
115 }, 'ContentType formatting must be preserved');
117 expect_error('org.w3.clearkey', [{
118 audioCapabilities: [{contentType: 'audio/webm; codecs=fake'}],
119 }], 'NotSupportedError', 'Unsupported audio codec');
121 expect_error('org.w3.clearkey', [{
122 audioCapabilities: [
123 {contentType: 'audio/webm; codecs=mp4a'},
124 {contentType: 'audio/webm; codecs=mp4a.40.2'}
126 }], 'NotSupportedError', 'Mismatched audio container/codec');
128 expect_config('org.w3.clearkey', [{
129 videoCapabilities: [{contentType: 'video/webm; codecs=vp8'}],
130 }], {
131 videoCapabilities: [{contentType: 'video/webm; codecs=vp8'}],
132 }, 'Supported video codec');
134 expect_error('org.w3.clearkey', [{
135 audioCapabilities: [{contentType: 'video/webm; codecs=vp8'}],
136 }], 'NotSupportedError', 'Video codec specified in audio field');
138 expect_error('org.w3.clearkey', [{
139 videoCapabilities: [{contentType: 'audio/webm; codecs=vorbis'}],
140 }], 'NotSupportedError', 'Audio codec specified in video field');
142 expect_error('org.w3.clearkey', [{
143 audioCapabilities: [{contentType: 'video/webm; codecs=fake'}],
144 }], 'NotSupportedError', 'Unsupported video codec');
146 expect_error('org.w3.clearkey', [{
147 audioCapabilities: [
148 {contentType: 'audio/webm; codecs=avc1'},
149 {contentType: 'audio/webm; codecs=avc1.42e01e'}
151 }], 'NotSupportedError', 'Mismatched video container/codec');
153 expect_config('org.w3.clearkey', [
154 {initDataTypes: ['fakeidt']},
155 {initDataTypes: ['webm']}
156 ], {initDataTypes: ['webm']}, 'Two configurations, one supported');
158 expect_config('org.w3.clearkey', [
159 {initDataTypes: ['webm']},
161 ], {initDataTypes: ['webm']}, 'Two configurations, both supported');
163 // Audio MIME type does not support video codecs.
164 expect_error('org.w3.clearkey', [{
165 audioCapabilities: [
166 {contentType: 'audio/webm; codecs="vp8,vorbis"'},
167 {contentType: 'audio/webm; codecs="vorbis, vp8"'},
168 {contentType: 'audio/webm; codecs="vp8"'}
170 }], 'NotSupportedError', 'Audio MIME type does not support video codecs.');
172 // Video MIME type does not support audio codecs.
173 expect_error('org.w3.clearkey', [{
174 videoCapabilities: [
175 {contentType: 'video/webm; codecs="vp8,vorbis"'},
176 {contentType: 'video/webm; codecs="vorbis, vp8"'},
177 {contentType: 'video/webm; codecs="vorbis"'}
179 }], 'NotSupportedError', 'Video MIME type does not support audio codecs.');
181 // WebM does not support AVC1/AAC.
182 expect_error('org.w3.clearkey', [{
183 audioCapabilities: [
184 {contentType: 'audio/webm; codecs="aac"'},
185 {contentType: 'audio/webm; codecs="avc1"'},
186 {contentType: 'audio/webm; codecs="vp8,aac"'}
188 }], 'NotSupportedError', 'WebM audio does not support AVC1/AAC.');
190 expect_error('org.w3.clearkey', [{
191 videoCapabilities: [
192 {contentType: 'video/webm; codecs="aac"'},
193 {contentType: 'video/webm; codecs="avc1"'},
194 {contentType: 'video/webm; codecs="vp8,aac"'}
196 }], 'NotSupportedError', 'WebM video does not support AVC1/AAC.');
198 // Extra space is allowed in contentType.
199 expect_config('org.w3.clearkey', [{
200 videoCapabilities: [{contentType: ' video/webm; codecs="vp8"'}],
201 }], {
202 videoCapabilities: [{contentType: ' video/webm; codecs="vp8"'}],
203 }, 'Leading space in contentType');
205 expect_config('org.w3.clearkey', [{
206 videoCapabilities: [{contentType: 'video/webm ; codecs="vp8"'}],
207 }], {
208 videoCapabilities: [{contentType: 'video/webm ; codecs="vp8"'}],
209 }, 'Space before ; in contentType');
211 expect_config('org.w3.clearkey', [{
212 videoCapabilities: [{contentType: 'video/webm; codecs="vp8"'}],
213 }], {
214 videoCapabilities: [{contentType: 'video/webm; codecs="vp8"'}],
215 }, 'Extra spaces after ; in contentType');
217 // TODO(jrummell): contentType should allow white space at the
218 // end of the string. http://crbug.com/487392
219 // expect_config('org.w3.clearkey', [{
220 // videoCapabilities: [{contentType: 'video/webm; codecs="vp8" '}],
221 // }], {
222 // videoCapabilities: [{contentType: 'video/webm; codecs="vp8" '}],
223 // }, 'Trailing space in contentType');
225 expect_config('org.w3.clearkey', [{
226 videoCapabilities: [{contentType: 'video/webm; codecs=" vp8"'}],
227 }], {
228 videoCapabilities: [{contentType: 'video/webm; codecs=" vp8"'}],
229 }, 'Space at start of codecs parameter');
231 expect_config('org.w3.clearkey', [{
232 videoCapabilities: [{contentType: 'video/webm; codecs="vp8 "'}],
233 }], {
234 videoCapabilities: [{contentType: 'video/webm; codecs="vp8 "'}],
235 }, 'Space at end of codecs parameter');
237 // contentType is not case sensitive (except the codec names).
238 expect_config('org.w3.clearkey', [{
239 videoCapabilities: [{contentType: 'Video/webm; codecs="vp8"'}],
240 }], {
241 videoCapabilities: [{contentType: 'Video/webm; codecs="vp8"'}],
242 }, 'Video/webm');
244 expect_config('org.w3.clearkey', [{
245 videoCapabilities: [{contentType: 'video/Webm; codecs="vp8"'}],
246 }], {
247 videoCapabilities: [{contentType: 'video/Webm; codecs="vp8"'}],
248 }, 'video/Webm');
250 expect_config('org.w3.clearkey', [{
251 videoCapabilities: [{contentType: 'video/webm; Codecs="vp8"'}],
252 }], {
253 videoCapabilities: [{contentType: 'video/webm; Codecs="vp8"'}],
254 }, 'Codecs=');
256 expect_config('org.w3.clearkey', [{
257 videoCapabilities: [{contentType: 'VIDEO/WEBM; CODECS="vp8"'}],
258 }], {
259 videoCapabilities: [{contentType: 'VIDEO/WEBM; CODECS="vp8"'}],
260 }, 'VIDEO/WEBM');
262 // Unrecognized attributes are not allowed.
263 // TODO(jrummell): Unrecognized attributes are ignored currently.
264 // http://crbug.com/449690
265 // expect_error('org.w3.clearkey', [{
266 // videoCapabilities: [{contentType: 'video/webm; foo="bar"'}],
267 // }], 'NotSupportedError', 'Unrecognized foo');
268 // expect_error('org.w3.clearkey', [{
269 // videoCapabilities: [{contentType: 'video/webm; foo="bar"; codecs="vp8"'}],
270 // }], 'NotSupportedError', 'Unrecognized foo with codecs');
272 // Invalid contentTypes.
273 expect_error('org.w3.clearkey', [{
274 videoCapabilities: [{contentType: 'fake'}],
275 }], 'NotSupportedError', 'contentType fake');
277 expect_error('org.w3.clearkey', [{
278 audioCapabilities: [{contentType: 'audio/fake'}],
279 }], 'NotSupportedError', 'contentType audio/fake');
281 expect_error('org.w3.clearkey', [{
282 videoCapabilities: [{contentType: 'video/fake'}],
283 }], 'NotSupportedError', 'contentType video/fake');
285 // The actual codec names are case sensitive.
286 expect_error('org.w3.clearkey', [{
287 videoCapabilities: [{contentType: 'video/webm; codecs="Vp8"'}],
288 }], 'NotSupportedError', 'codecs Vp8');
290 expect_error('org.w3.clearkey', [{
291 videoCapabilities: [{contentType: 'video/webm; codecs="VP8"'}],
292 }], 'NotSupportedError', 'codecs VP8');
294 // Extra comma is not allowed in codecs.
295 expect_error('org.w3.clearkey', [{
296 videoCapabilities: [{contentType: 'video/webm; codecs=",vp8"'}],
297 }], 'NotSupportedError', 'Leading , in codecs');
299 expect_error('org.w3.clearkey', [{
300 videoCapabilities: [{contentType: 'video/webm; codecs="vp8,"'}],
301 }], 'NotSupportedError', 'Trailing , in codecs');
303 expect_error('org.w3.clearkey', [{
304 videoCapabilities: [{contentType: 'video/webm; codecs=",vp8,"'}],
305 }], 'NotSupportedError', 'Leading and trailing , in codecs');
306 </script>
307 </body>
308 </html>