OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <title>NeedKey</title> |
| 5 <script src=../video-test.js></script> |
| 6 <script> |
| 7 function stringToUint8Array(str) |
| 8 { |
| 9 var arr = []; |
| 10 for(var i = 0,j = str.length; i < j; ++i) |
| 11 arr[i] = str.charCodeAt(i); |
| 12 return new Uint8Array(arr); |
| 13 } |
| 14 |
| 15 var mediaKeys; |
| 16 var mediaKeySession; |
| 17 var expectedInitData = stringToUint8Array('0123456789012345'); |
| 18 var validKey = stringToUint8Array( |
| 19 '{"keys":[{"kty":"oct","kid":"691i8WgU0nto7xIq/OSuPA","k":"MDEyM
zQ1Njc4OTAxMjM0"}]}'); |
| 20 |
| 21 // Will get 2 identical events, one for audio, one for video. |
| 22 var expectedEvents = 2; |
| 23 |
| 24 function runTest() |
| 25 { |
| 26 video = document.getElementsByTagName('video')[0]; |
| 27 run('video.src = "../content/test-encrypted.webm"'); |
| 28 waitForEvent('needkey', needKey, false, false, video, false); |
| 29 } |
| 30 |
| 31 function needKey(event) |
| 32 { |
| 33 testExpected("event.target", video); |
| 34 testExpected("event instanceof window.MediaKeyNeededEvent", true
); |
| 35 testExpected("event.type", "needkey"); |
| 36 |
| 37 // FIXME: Enable the following line when contentType set. |
| 38 // testExpected("event.contentType", "video/webm"); |
| 39 testArraysEqual("event.initData", expectedInitData); |
| 40 |
| 41 if (--expectedEvents == 0) |
| 42 endTest(); |
| 43 } |
| 44 </script> |
| 45 </head> |
| 46 <body onload="runTest()"> |
| 47 <p>This tests that the 'needkey' event is generated.</p> |
| 48 <video></video> |
| 49 </body> |
| 50 </html> |
OLD | NEW |