Index: LayoutTests/http/tests/media/encrypted-media/encrypted-media-encrypted-event.html |
diff --git a/LayoutTests/http/tests/media/encrypted-media/encrypted-media-encrypted-event.html b/LayoutTests/http/tests/media/encrypted-media/encrypted-media-encrypted-event.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..46e2120783ce58c0f922d8e8839219c544464d10 |
--- /dev/null |
+++ b/LayoutTests/http/tests/media/encrypted-media/encrypted-media-encrypted-event.html |
@@ -0,0 +1,86 @@ |
+<!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
|
+<html> |
+ <head> |
+ <title>InitDataType returned properly</title> |
+ <script src="/js-test-resources/testharness.js"></script> |
+ <script src="/js-test-resources/testharnessreport.js"></script> |
+ </head> |
+ <body> |
+ <video id="testVideo1"></video> |
+ <video id="testVideo2"></video> |
+ <div id="log"></div> |
+ <script> |
+ async_test(function(test) |
+ { |
+ var video = document.getElementById('testVideo1'); |
+ var encryptedEventCount = 0; |
+ |
+ function onEncrypted(event) |
+ { |
+ assert_equals(event.target, video); |
+ assert_true(event instanceof window.MediaEncryptedEvent); |
+ assert_equals(event.type, 'encrypted'); |
+ |
+ // Since the .src is in the same origin as this test, |
+ // both initDataType and initData should contain something. |
+ assert_equals(event.initDataType, 'webm'); |
+ assert_greater_than(event.initData.byteLength, 0); |
+ |
+ // 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.
|
+ // the video streams so finish once both events are |
+ // received. |
+ if (++encryptedEventCount == 2) |
+ test.done(); |
+ } |
+ |
+ navigator.requestMediaKeySystemAccess('org.w3.clearkey', [{}]).then(function(access) { |
+ return access.createMediaKeys(); |
+ }).then(function(mediaKeys) { |
+ video.addEventListener('encrypted', test.step_func(onEncrypted), true); |
+ return video.setMediaKeys(mediaKeys); |
+ }).then(function(result) { |
+ video.src = 'test-encrypted.webm'; |
+ video.play(); |
+ }); |
+ }, '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.
|
+ |
+ 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.
|
+ { |
+ var video = document.getElementById('testVideo2'); |
+ var encryptedEventCount = 0; |
+ |
+ function onEncrypted(event) |
+ { |
+ assert_equals(event.target, video); |
+ assert_true(event instanceof window.MediaEncryptedEvent); |
+ assert_equals(event.type, 'encrypted'); |
+ |
+ // Since the .src is in a different origin as this test, |
+ // both initDataType and initData should be empty. |
+ assert_equals(event.initDataType, ''); |
+ assert_equals(event.initData.byteLength, 0); |
+ |
+ // The same decryption key is used by both the audio and |
+ // the video streams so finish once both events are |
+ // received. |
+ if (++encryptedEventCount == 2) |
+ test.done(); |
+ } |
+ |
+ navigator.requestMediaKeySystemAccess('org.w3.clearkey', [{}]).then(function(access) { |
+ return access.createMediaKeys(); |
+ }).then(function(mediaKeys) { |
+ video.addEventListener('encrypted', test.step_func(onEncrypted), true); |
+ return video.setMediaKeys(mediaKeys); |
+ }).then(function(result) { |
+ // Verify that the current origin is different than what |
+ // we use for the content. |
+ assert_equals(document.origin, 'http://127.0.0.1:8000'); |
+ video.src = 'http://127.0.0.1:8080/media/encrypted-media/test-encrypted.webm'; |
+ video.play(); |
+ }); |
+ }, 'InitDataType not returned when using different origin.'); |
+ |
+ </script> |
+ </body> |
+</html> |