Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: LayoutTests/media/encrypted-media/encrypted-media-v2-syntax.html

Issue 182453005: Encrypted Media: Convert unprefixed syntax layout test to use testharness.js. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: comments addressed Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | LayoutTests/media/encrypted-media/encrypted-media-v2-syntax-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>MediaKeys</title> 4 <title>Test EME syntax</title>
5 <script src=../video-test.js></script> 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>
6 <script> 11 <script>
7 function stringToUint8Array(str) 12 var typeError = new TypeError();
13 var mediaKeys = null;
14 var mediaKeySession = null;
15 var initData = stringToUint8Array('init data');
16
17 test(function()
8 { 18 {
9 var arr=[]; 19 // Too few parameters.
10 for(var i=0,j=str.length;i<j;++i) 20 assert_throws(typeError, function() { new MediaKeys(); });
11 arr[i]=str.charCodeAt(i); 21 // Invalid parameters.
12 return new Uint8Array(arr); 22 assert_throws('INVALID_ACCESS_ERR', function() { new MediaKeys(' '); });
ddorwin 2014/03/10 20:11:44 This is "just" testing empty string. Add some othe
xhwang 2014/03/10 23:23:21 Done.
13 } 23 // Invalid key systems.
24 assert_throws('NOT_SUPPORTED_ERR', function() { new MediaKeys(nu ll); });
25 assert_throws('NOT_SUPPORTED_ERR', function() { new MediaKeys(un defined); });
26 assert_throws('NOT_SUPPORTED_ERR', function() { new MediaKeys('u nsupported'); });
ddorwin 2014/03/10 20:11:44 integer would go here per order below
xhwang 2014/03/10 23:23:21 Done.
27 }, 'Test MediaKeys constructor exceptions.');
14 28
15 var mediaKeys; 29 test(function()
16 var mediaKeySession; 30 {
17 var initData = stringToUint8Array('mock'); 31 assert_equals(typeof window.MediaKeys, 'function');
32 mediaKeys = new MediaKeys('org.w3.clearkey');
ddorwin 2014/03/10 20:11:44 The result of this line is not checked (other than
xhwang 2014/03/10 23:23:21 Done.
33 mediaKeys = new MediaKeys('org.w3.clearkey', 'extra');
34 assert_equals(typeof mediaKeys, 'object');
35 assert_equals(mediaKeys.keySystem, 'org.w3.clearkey');
36 assert_equals(typeof mediaKeys.createSession, 'function');
37 assert_equals(typeof mediaKeys.addEventListener, 'undefined');
ddorwin 2014/03/10 20:11:44 It would be nice to test that on{open|message|clos
xhwang 2014/03/10 23:23:21 Done.
38 }, 'Test MediaKeys constructor.');
18 39
19 function checkError() 40 test(function()
20 { 41 {
21 testExpected('mediaKeySession.error', null, '!='); 42 // Too few parameters.
22 testExpected('mediaKeySession.error.code', MediaKeyError.MEDIA_K EYERR_UNKNOWN); 43 assert_throws(typeError, function() { mediaKeys.createSession(); });
23 testExpected('mediaKeySession.error.systemCode', 0); 44 assert_throws(typeError, function() { mediaKeys.createSession('' ); });
24 } 45 assert_throws(typeError, function() { mediaKeys.createSession(nu ll); });
46 assert_throws(typeError, function() { mediaKeys.createSession(un defined); });
47 assert_throws(typeError, function() { mediaKeys.createSession('v ideo/webm'); });
48 assert_throws(typeError, function() { mediaKeys.createSession(ne w Uint8Array(0)); });
49 assert_throws(typeError, function() { mediaKeys.createSession(in itData); });
50 // Invalid parameters.
51 assert_throws('InvalidAccessError', function() { mediaKeys.creat eSession('video/webm', ''); });
52 assert_throws('InvalidAccessError', function() { mediaKeys.creat eSession('video/webm', null); });
53 assert_throws('InvalidAccessError', function() { mediaKeys.creat eSession('video/webm', undefined); });
54 assert_throws('InvalidAccessError', function() { mediaKeys.creat eSession('video/webm', 1); });
55 assert_throws('InvalidAccessError', function() { mediaKeys.creat eSession('video/webm', new Uint8Array(0)); });
56 assert_throws('InvalidAccessError', function() { mediaKeys.creat eSession('', initData); });
57 // Not supported contentTypes.
58 assert_throws('NotSupportedError', function() { mediaKeys.create Session(null, initData); });
59 assert_throws('NotSupportedError', function() { mediaKeys.create Session(undefined, initData); });
60 assert_throws('NotSupportedError', function() { mediaKeys.create Session(new Uint8Array(0), initData); });
61 assert_throws('NotSupportedError', function() { mediaKeys.create Session(1, initData); });
62 assert_throws('NotSupportedError', function() { mediaKeys.create Session('unsupported', initData); });
ddorwin 2014/03/10 20:11:44 nit: Add 'video/foo' (something that looks like a
xhwang 2014/03/10 23:23:21 Added.
63 }, 'Test MediaKeys createSession() exceptions.');
25 64
26 function runTest() 65 test(function()
27 { 66 {
28 consoleWrite("Test MediaKeys."); 67 mediaKeySession = mediaKeys.createSession('video/webm', initData );
ddorwin 2014/03/10 20:11:44 ditto - result not checked
xhwang 2014/03/10 23:23:21 Done.
29 testExpected('typeof window.MediaKeys', 'function'); 68 mediaKeySession = mediaKeys.createSession('video/webm', initData , 'extra');
30 testDOMException('new MediaKeys("")', "DOMException.INVALID_ACCE SS_ERR"); 69 assert_equals(typeof mediaKeySession, 'object');
31 testDOMException('new MediaKeys("unsupported")', "DOMException.N OT_SUPPORTED_ERR"); 70 assert_equals(typeof mediaKeySession.addEventListener, 'function ');
32 run('mediaKeys = new MediaKeys("org.w3.clearkey")'); 71 assert_equals(typeof mediaKeySession.update, 'function');
33 testExpected('typeof mediaKeys', 'object'); 72 assert_equals(mediaKeySession.error, null);
34 testExpected('mediaKeys.keySystem', 'org.w3.clearkey'); 73 assert_equals(mediaKeySession.keySystem, 'org.w3.clearkey');
35 testExpected('typeof mediaKeys.createSession', 'function'); 74 assert_equals(typeof mediaKeySession.sessionId, 'string');
75 }, 'Test MediaKeys createSession().');
36 76
37 testException('mediaKeys.createSession()', '"TypeError: Failed t o execute \'createSession\' on \'MediaKeys\': 2 arguments required, but only 0 p resent."'); 77 test(function()
38 testException('mediaKeys.createSession("")', '"TypeError: Failed to execute \'createSession\' on \'MediaKeys\': 2 arguments required, but only 1 present."'); 78 {
39 testException('mediaKeys.createSession("video/webm")', '"TypeErr or: Failed to execute \'createSession\' on \'MediaKeys\': 2 arguments required, but only 1 present."'); 79 // Too few parameters.
40 testDOMException('mediaKeys.createSession("", new Uint8Array(1)) ', "DOMException.INVALID_ACCESS_ERR"); 80 assert_throws(typeError, function() { mediaKeySession.update(); });
41 testDOMException('mediaKeys.createSession("video/webm", null)', "DOMException.INVALID_ACCESS_ERR"); 81 // Invalid parameters.
42 testDOMException('mediaKeys.createSession("video/webm", new Uint 8Array(0))', "DOMException.INVALID_ACCESS_ERR"); 82 assert_throws('InvalidAccessError', function() { mediaKeySession .update(''); });
43 testDOMException('mediaKeys.createSession("unsupported/type", ne w Uint8Array(1))', "DOMException.NOT_SUPPORTED_ERR"); 83 assert_throws('InvalidAccessError', function() { mediaKeySession .update(null); });
44 consoleWrite(""); 84 assert_throws('InvalidAccessError', function() { mediaKeySession .update(undefined); });
85 assert_throws('InvalidAccessError', function() { mediaKeySession .update(new Uint8Array(0)); });
ddorwin 2014/03/10 20:11:44 test integer
xhwang 2014/03/10 23:23:21 Done.
86 }, 'Test MediaKeySession update() exceptions.');
45 87
46 consoleWrite("Test MediaKeySession."); 88 test(function()
47 run('mediaKeySession = mediaKeys.createSession("video/webm", ini tData)'); 89 {
48 testExpected('typeof mediaKeySession', 'object'); 90 mediaKeySession.update(new Uint8Array(1));
49 testExpected('typeof mediaKeySession.addEventListener', 'functio n'); 91 mediaKeySession.update(new Uint8Array(1), 'extra');
50 testExpected('typeof mediaKeySession.update', 'function'); 92 }, 'Test MediaKeySession update().');
51 testExpected('mediaKeySession.error', null);
52 testExpected('mediaKeySession.keySystem', 'org.w3.clearkey');
53 testExpected('mediaKeySession.sessionId', null, '!=');
54 testExpected('mediaKeySession.onwebkitkeyadded', null);
55 testExpected('mediaKeySession.onwebkitkeyerror', null);
56 testExpected('mediaKeySession.onwebkitkeymessage', null);
57 testException('mediaKeySession.update()', '"TypeError: Failed to execute \'update\' on \'MediaKeySession\': 1 argument required, but only 0 pres ent."');
58 testDOMException('mediaKeySession.update(null)', "DOMException.I NVALID_ACCESS_ERR");
59 run('mediaKeySession.update(new Uint8Array(1))');
60 93
61 run('mediaKeySession.release()'); 94 test(function()
95 {
96 mediaKeySession.release();
97 // FIXME: This causes Chromium to crash. Uncomment this once Chr omium is fixed.
98 // mediaKeySession.release('extra');
99 }, 'Test MediaKeySession release().');
62 100
ddorwin 2014/03/10 20:11:44 When/where will isTypeSupported test be added?
xhwang 2014/03/10 23:23:21 Added FIXME.
63 endTest(); 101 // FIXME: Add HTMLMediaElement syntax checks, e.g. setMediaKeys, med iakeys, onneedkey.
64 }
65 </script> 102 </script>
66 </head>
67 <body onload="runTest()">
68 <p>This tests the basic API of MediaKeys and MediaKeySession.</p>
69 </body> 103 </body>
70 </html> 104 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/media/encrypted-media/encrypted-media-v2-syntax-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698