OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
ddorwin
2015/02/06 21:41:33
For full coverage of this complex issue, we should
jrummell
2015/02/07 00:12:26
Opened http://crbug.com/456358
| |
2 <html> | |
3 <head> | |
4 <title>InitDataType returned properly</title> | |
5 <script src="/js-test-resources/testharness.js"></script> | |
6 <script src="/js-test-resources/testharnessreport.js"></script> | |
7 </head> | |
8 <body> | |
9 <video id="testVideo1"></video> | |
10 <video id="testVideo2"></video> | |
11 <div id="log"></div> | |
12 <script> | |
13 async_test(function(test) | |
14 { | |
15 var video = document.getElementById('testVideo1'); | |
16 var encryptedEventCount = 0; | |
17 | |
18 function onEncrypted(event) | |
19 { | |
20 assert_equals(event.target, video); | |
21 assert_true(event instanceof window.MediaEncryptedEvent); | |
22 assert_equals(event.type, 'encrypted'); | |
23 | |
24 // Since the .src is in the same origin as this test, | |
25 // both initDataType and initData should contain something. | |
26 assert_equals(event.initDataType, 'webm'); | |
27 assert_greater_than(event.initData.byteLength, 0); | |
28 | |
29 // The same decryption key is used by both the audio and | |
ddorwin
2015/02/06 21:41:33
Is this really relevant? It's the fact that both t
jrummell
2015/02/07 00:12:25
Done.
| |
30 // the video streams so finish once both events are | |
31 // received. | |
32 if (++encryptedEventCount == 2) | |
33 test.done(); | |
34 } | |
35 | |
36 navigator.requestMediaKeySystemAccess('org.w3.clearkey', [{}]).t hen(function(access) { | |
37 return access.createMediaKeys(); | |
38 }).then(function(mediaKeys) { | |
39 video.addEventListener('encrypted', test.step_func(onEncrypt ed), true); | |
40 return video.setMediaKeys(mediaKeys); | |
41 }).then(function(result) { | |
42 video.src = 'test-encrypted.webm'; | |
43 video.play(); | |
44 }); | |
45 }, 'InitDataType returned when using same origin.'); | |
ddorwin
2015/02/06 21:41:33
It's not really the "Type" that is important here.
jrummell
2015/02/07 00:12:25
Done.
| |
46 | |
47 async_test(function(test) | |
ddorwin
2015/02/06 21:41:33
I wonder whether we should break this up into sepa
jrummell
2015/02/07 00:12:25
Done.
| |
48 { | |
49 var video = document.getElementById('testVideo2'); | |
50 var encryptedEventCount = 0; | |
51 | |
52 function onEncrypted(event) | |
53 { | |
54 assert_equals(event.target, video); | |
55 assert_true(event instanceof window.MediaEncryptedEvent); | |
56 assert_equals(event.type, 'encrypted'); | |
57 | |
58 // Since the .src is in a different origin as this test, | |
59 // both initDataType and initData should be empty. | |
60 assert_equals(event.initDataType, ''); | |
61 assert_equals(event.initData.byteLength, 0); | |
62 | |
63 // The same decryption key is used by both the audio and | |
64 // the video streams so finish once both events are | |
65 // received. | |
66 if (++encryptedEventCount == 2) | |
67 test.done(); | |
68 } | |
69 | |
70 navigator.requestMediaKeySystemAccess('org.w3.clearkey', [{}]).t hen(function(access) { | |
71 return access.createMediaKeys(); | |
72 }).then(function(mediaKeys) { | |
73 video.addEventListener('encrypted', test.step_func(onEncrypt ed), true); | |
74 return video.setMediaKeys(mediaKeys); | |
75 }).then(function(result) { | |
76 // Verify that the current origin is different than what | |
77 // we use for the content. | |
78 assert_equals(document.origin, 'http://127.0.0.1:8000'); | |
79 video.src = 'http://127.0.0.1:8080/media/encrypted-media/tes t-encrypted.webm'; | |
80 video.play(); | |
81 }); | |
82 }, 'InitDataType not returned when using different origin.'); | |
83 | |
84 </script> | |
85 </body> | |
86 </html> | |
OLD | NEW |