Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / media / encrypted-media / encrypted-media-encrypted-event-same-origin.html
blob775221275d9f6dcae89ba8673de7471c9117addd
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Initialization Data returned when using same origin</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="testVideo"></video>
10 <div id="log"></div>
11 <script>
12 async_test(function(test)
14 var video = document.getElementById('testVideo');
15 var encryptedEventCount = 0;
17 function onEncrypted(event)
19 assert_equals(event.target, video);
20 assert_true(event instanceof window.MediaEncryptedEvent);
21 assert_equals(event.type, 'encrypted');
23 // Since the .src is in the same origin as this test,
24 // both initDataType and initData should contain something.
25 assert_equals(event.initDataType, 'webm');
26 assert_greater_than(event.initData.byteLength, 0);
28 // Both the audio and the video tracks have initData,
29 // so finish once both events are received.
30 if (++encryptedEventCount == 2)
31 test.done();
34 navigator.requestMediaKeySystemAccess('org.w3.clearkey', [{}]).then(function(access) {
35 return access.createMediaKeys();
36 }).then(function(mediaKeys) {
37 video.addEventListener('encrypted', test.step_func(onEncrypted), true);
38 return video.setMediaKeys(mediaKeys);
39 }).then(function(result) {
40 video.src = 'test-encrypted.webm';
41 video.play();
42 });
43 }, 'Initialization Data returned when using same origin.');
44 </script>
45 </body>
46 </html>