| 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 testDOMException('mediaKeys.createSession("")', "DOMException.IN
VALID_ACCESS_ERR"); |
| 29 testDOMException('mediaKeys.createSession("", new Uint8Array(1))
', "DOMException.INVALID_ACCESS_ERR"); | 31 testDOMException('mediaKeys.createSession("", new Uint8Array(1))
', "DOMException.INVALID_ACCESS_ERR"); |
| 30 testDOMException('mediaKeys.createSession("unsupported/type")',
"DOMException.NOT_SUPPORTED_ERR"); | 32 testDOMException('mediaKeys.createSession("video/webm", null)',
"DOMException.INVALID_ACCESS_ERR"); |
| 33 testDOMException('mediaKeys.createSession("unsupported/type", ne
w Uint8Array(1))', "DOMException.NOT_SUPPORTED_ERR"); |
| 31 consoleWrite(""); | 34 consoleWrite(""); |
| 32 | 35 |
| 33 consoleWrite("Test MediaKeySession."); | 36 consoleWrite("Test MediaKeySession."); |
| 34 run('mediaKeySession = mediaKeys.createSession("video/webm", ini
tData)'); | 37 run('mediaKeySession = mediaKeys.createSession("video/webm", ini
tData)'); |
| 35 testExpected('typeof mediaKeySession', 'object'); | 38 testExpected('typeof mediaKeySession', 'object'); |
| 36 testExpected('typeof mediaKeySession.addEventListener', 'functio
n'); | 39 testExpected('typeof mediaKeySession.addEventListener', 'functio
n'); |
| 37 testExpected('typeof mediaKeySession.update', 'function'); | 40 testExpected('typeof mediaKeySession.update', 'function'); |
| 38 testExpected('mediaKeySession.error', null); | 41 testExpected('mediaKeySession.error', null); |
| 39 testExpected('mediaKeySession.keySystem', 'org.w3.clearkey'); | 42 testExpected('mediaKeySession.keySystem', 'org.w3.clearkey'); |
| 40 testExpected('mediaKeySession.sessionId', null, '!='); | 43 testExpected('mediaKeySession.sessionId', null, '!='); |
| 41 testExpected('mediaKeySession.onwebkitkeyadded', null); | 44 testExpected('mediaKeySession.onwebkitkeyadded', null); |
| 42 testExpected('mediaKeySession.onwebkitkeyerror', null); | 45 testExpected('mediaKeySession.onwebkitkeyerror', null); |
| 43 testExpected('mediaKeySession.onwebkitkeymessage', null); | 46 testExpected('mediaKeySession.onwebkitkeymessage', null); |
| 44 testDOMException('mediaKeySession.update(null)', "DOMException.I
NVALID_ACCESS_ERR"); | 47 testDOMException('mediaKeySession.update(null)', "DOMException.I
NVALID_ACCESS_ERR"); |
| 45 endTest(); | 48 endTest(); |
| 46 } | 49 } |
| 47 </script> | 50 </script> |
| 48 </head> | 51 </head> |
| 49 <body onload="runTest()"> | 52 <body onload="runTest()"> |
| 50 <p>This tests the basic API of MediaKeys and MediaKeySession.</p> | 53 <p>This tests the basic API of MediaKeys and MediaKeySession.</p> |
| 51 </body> | 54 </body> |
| 52 </html> | 55 </html> |
| OLD | NEW |