OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>onencrypted</title> | 4 <title>onencrypted</title> |
5 <script src="encrypted-media-utils.js"></script> | 5 <script src="encrypted-media-utils.js"></script> |
6 <script src="../../resources/testharness.js"></script> | 6 <script src="../../resources/testharness.js"></script> |
7 <script src="../../resources/testharnessreport.js"></script> | 7 <script src="../../resources/testharnessreport.js"></script> |
8 </head> | 8 </head> |
9 <body> | 9 <body> |
10 <video id="testVideo" controls></video> | 10 <video></video> |
11 <div id="log"></div> | |
12 <script> | 11 <script> |
13 var expectedInitData = stringToUint8Array('0123456789012345'); | 12 var expectedInitData = stringToUint8Array('0123456789012345'); |
14 | 13 |
15 // Will get 2 identical events, one for audio, one for video. | 14 // Will get 2 identical events, one for audio, one for video. |
16 var expectedEvents = 2; | 15 var expectedEvents = 2; |
17 | 16 |
18 async_test(function(test) | 17 async_test(function(test) |
19 { | 18 { |
20 var video = document.getElementById('testVideo'); | 19 var video = document.querySelector('video'); |
21 var content = '../content/test-encrypted.webm'; | 20 var content = '../content/test-encrypted.webm'; |
22 | 21 |
23 var onEncrypted = function(event) | 22 var onEncrypted = function(event) |
24 { | 23 { |
25 assert_equals(event.target, video); | 24 assert_equals(event.target, video); |
26 assert_true(event instanceof window.MediaEncryptedEvent); | 25 assert_true(event instanceof window.MediaEncryptedEvent); |
27 assert_equals(event.type, 'encrypted'); | 26 assert_equals(event.type, 'encrypted'); |
28 assert_equals(event.initDataType, 'webm'); | 27 assert_equals(event.initDataType, 'webm'); |
29 assert_array_equals(new Uint8Array(event.initData), expected
InitData); | 28 assert_array_equals(new Uint8Array(event.initData), expected
InitData); |
30 | 29 |
31 if (--expectedEvents == 0) | 30 if (--expectedEvents == 0) |
32 test.done(); | 31 test.done(); |
33 }; | 32 }; |
34 | 33 |
35 waitForEventAndRunStep('encrypted', video, onEncrypted, test); | 34 waitForEventAndRunStep('encrypted', video, onEncrypted, test); |
36 video.src = content; | 35 video.src = content; |
37 }, 'encrypted fired on encrypted media file.'); | 36 }, 'encrypted fired on encrypted media file.'); |
38 </script> | 37 </script> |
39 </body> | 38 </body> |
40 </html> | 39 </html> |
OLD | NEW |