| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>Initialization Data not returned when using different origin</tit
le> | 4 <title>Initialization Data not returned when using different origin</tit
le> |
| 5 <script src="/js-test-resources/testharness.js"></script> | 5 <script src="/js-test-resources/testharness.js"></script> |
| 6 <script src="/js-test-resources/testharnessreport.js"></script> | 6 <script src="/js-test-resources/testharnessreport.js"></script> |
| 7 </head> | 7 </head> |
| 8 <body> | 8 <body> |
| 9 <video id="testVideo"></video> | 9 <video id="testVideo"></video> |
| 10 <div id="log"></div> | 10 <div id="log"></div> |
| 11 <script> | 11 <script> |
| 12 async_test(function(test) | 12 async_test(function(test) |
| 13 { | 13 { |
| 14 var video = document.getElementById('testVideo'); | 14 var video = document.getElementById('testVideo'); |
| 15 var encryptedEventCount = 0; | 15 var encryptedEventCount = 0; |
| 16 | 16 |
| 17 function logMessage(msg) { |
| 18 var date = new Date(); |
| 19 var hours = ('0' + date.getHours()).slice(-2); |
| 20 var minutes = ('0' + date.getMinutes()).slice(-2); |
| 21 var secs = ('0' + date.getSeconds()).slice(-2); |
| 22 var milliSecs = ('00' + date.getMilliseconds()).slice(-3); |
| 23 console.log(hours + ':' + minutes + ':' + secs + '.' + milli
Secs + ': ' + msg); |
| 24 }; |
| 25 |
| 17 function onEncrypted(event) | 26 function onEncrypted(event) |
| 18 { | 27 { |
| 28 logMessage('onEncrypted'); |
| 19 assert_equals(event.target, video); | 29 assert_equals(event.target, video); |
| 20 assert_true(event instanceof window.MediaEncryptedEvent); | 30 assert_true(event instanceof window.MediaEncryptedEvent); |
| 21 assert_equals(event.type, 'encrypted'); | 31 assert_equals(event.type, 'encrypted'); |
| 22 | 32 |
| 23 // Since the .src is in a different origin as this test, | 33 // Since the .src is in a different origin as this test, |
| 24 // both initDataType and initData should be empty. | 34 // both initDataType and initData should be empty. |
| 25 assert_equals(event.initDataType, ''); | 35 assert_equals(event.initDataType, ''); |
| 26 assert_equals(event.initData.byteLength, 0); | 36 assert_equals(event.initData.byteLength, 0); |
| 27 | 37 |
| 28 // Both the audio and the video tracks have initData, | 38 // Both the audio and the video tracks have initData, |
| 29 // so finish once both events are received. | 39 // so finish once both events are received. |
| 30 if (++encryptedEventCount == 2) | 40 if (++encryptedEventCount == 2) { |
| 41 logMessage('done'); |
| 31 test.done(); | 42 test.done(); |
| 43 } |
| 32 } | 44 } |
| 33 | 45 |
| 46 logMessage('starting'); |
| 34 navigator.requestMediaKeySystemAccess('org.w3.clearkey', [{}]).t
hen(function(access) { | 47 navigator.requestMediaKeySystemAccess('org.w3.clearkey', [{}]).t
hen(function(access) { |
| 35 return access.createMediaKeys(); | 48 return access.createMediaKeys(); |
| 36 }).then(function(mediaKeys) { | 49 }).then(function(mediaKeys) { |
| 37 video.addEventListener('encrypted', test.step_func(onEncrypt
ed), true); | 50 video.addEventListener('encrypted', test.step_func(onEncrypt
ed), true); |
| 38 return video.setMediaKeys(mediaKeys); | 51 return video.setMediaKeys(mediaKeys); |
| 39 }).then(function(result) { | 52 }).then(function(result) { |
| 40 // Verify that the current origin is different than what | 53 // Verify that the current origin is different than what |
| 41 // we use for the content. | 54 // we use for the content. |
| 55 logMessage('setting src'); |
| 42 assert_equals(document.origin, 'http://127.0.0.1:8000'); | 56 assert_equals(document.origin, 'http://127.0.0.1:8000'); |
| 43 video.src = 'http://127.0.0.1:8080/media/encrypted-media/tes
t-encrypted.webm'; | 57 video.src = 'http://127.0.0.1:8080/media/encrypted-media/tes
t-encrypted.webm'; |
| 44 video.play(); | 58 video.play(); |
| 45 }); | 59 }); |
| 46 }, 'Initialization Data not returned when using different origin.'); | 60 }, 'Initialization Data not returned when using different origin.'); |
| 47 </script> | 61 </script> |
| 48 </body> | 62 </body> |
| 49 </html> | 63 </html> |
| OLD | NEW |