Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>MediaKeys</title> | 4 <title>MediaKeys</title> |
| 5 <script src=../video-test.js></script> | 5 <script src=../video-test.js></script> |
| 6 <script> | 6 <script> |
| 7 function stringToUint8Array(str) | 7 function stringToUint8Array(str) |
| 8 { | 8 { |
| 9 var arr=[]; | 9 var arr=[]; |
| 10 for(var i=0,j=str.length;i<j;++i) | 10 for(var i=0,j=str.length;i<j;++i) |
| 11 arr[i]=str.charCodeAt(i); | 11 arr[i]=str.charCodeAt(i); |
| 12 return new Uint8Array(arr); | 12 return new Uint8Array(arr); |
| 13 } | 13 } |
| 14 | 14 |
| 15 var mediaKeys; | 15 var mediaKeys; |
| 16 var mediaKeySession; | 16 var mediaKeySession; |
| 17 var initData = stringToUint8Array('mock'); | 17 var initData = stringToUint8Array('mock'); |
| 18 | 18 |
| 19 function runTest() | 19 function runTest() |
| 20 { | 20 { |
| 21 consoleWrite("Test MediaKeys."); | 21 consoleWrite("Test MediaKeys."); |
| 22 testExpected('typeof window.MediaKeys', 'function'); | 22 testExpected('typeof window.MediaKeys', 'function'); |
| 23 testDOMException('new MediaKeys("")', "DOMException.INVALID_ACCE SS_ERR"); | 23 testDOMException('new MediaKeys("")', "DOMException.INVALID_ACCE SS_ERR"); |
| 24 testDOMException('new MediaKeys("unsupported")', "DOMException.N OT_SUPPORTED_ERR"); | 24 testDOMException('new MediaKeys("unsupported")', "DOMException.N OT_SUPPORTED_ERR"); |
| 25 run('mediaKeys = new MediaKeys("org.w3.clearkey")'); | 25 run('mediaKeys = new MediaKeys("org.w3.clearkey")'); |
| 26 testExpected('typeof mediaKeys', 'object'); | 26 testExpected('typeof mediaKeys', 'object'); |
| 27 testExpected('mediaKeys.keySystem', 'org.w3.clearkey'); | 27 testExpected('mediaKeys.keySystem', 'org.w3.clearkey'); |
| 28 testExpected('typeof mediaKeys.createSession', 'function'); | 28 testExpected('typeof mediaKeys.createSession', 'function'); |
| 29 | |
| 30 testException('mediaKeys.createSession()', '"TypeError: Failed t o execute \'createSession\' on \'MediaKeys\': 2 arguments required, but only 0 p resent."'); | |
| 31 testException('mediaKeys.createSession("")', '"TypeError: Failed to execute \'createSession\' on \'MediaKeys\': 2 arguments required, but only 1 present."'); | |
| 32 testException('mediaKeys.createSession("video/webm")', '"TypeErr or: Failed to execute \'createSession\' on \'MediaKeys\': 2 arguments required, but only 1 present."'); | |
| 29 testDOMException('mediaKeys.createSession("", new Uint8Array(1)) ', "DOMException.INVALID_ACCESS_ERR"); | 33 testDOMException('mediaKeys.createSession("", new Uint8Array(1)) ', "DOMException.INVALID_ACCESS_ERR"); |
| 30 testDOMException('mediaKeys.createSession("unsupported/type")', "DOMException.NOT_SUPPORTED_ERR"); | 34 testDOMException('mediaKeys.createSession("video/webm", null)', "DOMException.INVALID_ACCESS_ERR"); |
| 35 testDOMException('mediaKeys.createSession("video/webm", new Uint 8Array(0))', "DOMException.INVALID_ACCESS_ERR"); | |
| 36 testDOMException('mediaKeys.createSession("unsupported/type", ne w Uint8Array(1))', "DOMException.NOT_SUPPORTED_ERR"); | |
| 31 consoleWrite(""); | 37 consoleWrite(""); |
| 32 | 38 |
| 33 consoleWrite("Test MediaKeySession."); | 39 consoleWrite("Test MediaKeySession."); |
| 34 run('mediaKeySession = mediaKeys.createSession("video/webm", ini tData)'); | 40 run('mediaKeySession = mediaKeys.createSession("video/webm", ini tData)'); |
| 35 testExpected('typeof mediaKeySession', 'object'); | 41 testExpected('typeof mediaKeySession', 'object'); |
| 36 testExpected('typeof mediaKeySession.addEventListener', 'functio n'); | 42 testExpected('typeof mediaKeySession.addEventListener', 'functio n'); |
| 37 testExpected('typeof mediaKeySession.update', 'function'); | 43 testExpected('typeof mediaKeySession.update', 'function'); |
| 38 testExpected('mediaKeySession.error', null); | 44 testExpected('mediaKeySession.error', null); |
| 39 testExpected('mediaKeySession.keySystem', 'org.w3.clearkey'); | 45 testExpected('mediaKeySession.keySystem', 'org.w3.clearkey'); |
| 40 testExpected('mediaKeySession.sessionId', null, '!='); | 46 testExpected('mediaKeySession.sessionId', null, '!='); |
| 41 testExpected('mediaKeySession.onwebkitkeyadded', null); | 47 testExpected('mediaKeySession.onwebkitkeyadded', null); |
| 42 testExpected('mediaKeySession.onwebkitkeyerror', null); | 48 testExpected('mediaKeySession.onwebkitkeyerror', null); |
| 43 testExpected('mediaKeySession.onwebkitkeymessage', null); | 49 testExpected('mediaKeySession.onwebkitkeymessage', null); |
| 50 testException('mediaKeySession.update()', '"TypeError: Failed to execute \'update\' on \'MediaKeySession\': 1 argument required, but only 0 pres ent."'); | |
| 44 testDOMException('mediaKeySession.update(null)', "DOMException.I NVALID_ACCESS_ERR"); | 51 testDOMException('mediaKeySession.update(null)', "DOMException.I NVALID_ACCESS_ERR"); |
| 52 | |
| 53 // FIXME: Update this after MediaKeySession.error is hooked up. | |
| 54 run('mediaKeySession.update(new Uint8Array(1))'); | |
| 55 testExpected('mediaKeySession.error', null); | |
|
xhwang
2014/01/15 01:33:08
Actually this doesn't work. We need to wait for th
ddorwin
2014/01/15 01:41:01
Should it really be null or is that just the curre
| |
| 56 | |
| 57 // FIXME: Test MediaKeySession.release(). | |
| 58 | |
| 45 endTest(); | 59 endTest(); |
| 46 } | 60 } |
| 47 </script> | 61 </script> |
| 48 </head> | 62 </head> |
| 49 <body onload="runTest()"> | 63 <body onload="runTest()"> |
| 50 <p>This tests the basic API of MediaKeys and MediaKeySession.</p> | 64 <p>This tests the basic API of MediaKeys and MediaKeySession.</p> |
| 51 </body> | 65 </body> |
| 52 </html> | 66 </html> |
| OLD | NEW |