Index: LayoutTests/media/encrypted-media/encrypted-media-needkey.html |
diff --git a/LayoutTests/media/encrypted-media/encrypted-media-needkey.html b/LayoutTests/media/encrypted-media/encrypted-media-needkey.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..66b9b71bd5b62150fba320cb594ab84ae981e83e |
--- /dev/null |
+++ b/LayoutTests/media/encrypted-media/encrypted-media-needkey.html |
@@ -0,0 +1,54 @@ |
+<!DOCTYPE html> |
ddorwin
2014/01/13 19:08:38
We should start writing tests in a W3C test-compat
|
+<html> |
+ <head> |
+ <title>NeedKey</title> |
+ <script src=../video-test.js></script> |
+ <script> |
+ function stringToUint8Array(str) |
+ { |
+ var arr=[]; |
acolwell GONE FROM CHROMIUM
2014/01/13 18:19:04
nit: Add spaces around '=' here and elsewhere
jrummell
2014/01/13 19:01:32
Done. This function (and most of the code) was cop
ddorwin
2014/01/13 19:08:38
add spaces to all of this
jrummell
2014/01/13 22:43:44
Done.
|
+ for(var i=0,j=str.length;i<j;++i) |
acolwell GONE FROM CHROMIUM
2014/01/13 18:19:04
nit: add spaces around '<'
jrummell
2014/01/13 19:01:32
Done.
|
+ arr[i]=str.charCodeAt(i); |
+ return new Uint8Array(arr); |
+ } |
+ |
+ var mediaKeys; |
+ var mediaKeySession; |
+ var initData = stringToUint8Array('mock'); |
ddorwin
2014/01/13 19:08:38
Why "mock"?
jrummell
2014/01/13 22:43:44
Clone from encrypted-media-v2-events.html. Now tha
|
+ var expectedInitData = stringToUint8Array('0123456789012345'); |
+ var validKey = stringToUint8Array( |
+ '{"keys":[{"kty":"oct","kid":"691i8WgU0nto7xIq/OSuPA","k":"MDEyMzQ1Njc4OTAxMjM0"}]}'); |
+ var expectedEvents = 2; |
+ |
+ function runTest() |
+ { |
+ video = document.getElementsByTagName('video')[0]; |
+ run('mediaKeys = new MediaKeys("org.w3.clearkey")'); |
acolwell GONE FROM CHROMIUM
2014/01/13 18:19:04
nit: Why is this and the line below in a run()? Se
jrummell
2014/01/13 19:01:32
run() logs the statement and catches exceptions. I
acolwell GONE FROM CHROMIUM
2014/01/13 19:19:39
Ok. I'm not a fan of this style, but since it appe
|
+ run('mediaKeySession = mediaKeys.createSession("video/webm", initData)'); |
+ video.setMediaKeys(mediaKeys); |
xhwang
2014/01/13 18:42:40
Based on the spec, we don't need a MediaKeys objec
jrummell
2014/01/13 19:01:32
Done.
|
+ video.src="../content/test-encrypted.webm"; |
ddorwin
2014/01/13 19:08:38
spaces
jrummell
2014/01/13 22:43:44
Done.
|
+ |
+ // Will get 2 identical events, one for audio, one for video. |
ddorwin
2014/01/13 19:08:38
Would this comment be better above line 21?
jrummell
2014/01/13 22:43:44
Sure.
|
+ waitForEvent('needkey', needKey, false, false, video, false); |
+ } |
+ |
+ function needKey(event) |
+ { |
+ testExpected("event.target", video); |
+ testExpected("event instanceof window.MediaKeyNeededEvent", true); |
+ testExpected("event.type", "needkey"); |
+ |
+ // Following line commented out as contentType not currently set. |
ddorwin
2014/01/13 19:08:38
FIXME: Enable the following line when...
jrummell
2014/01/13 22:43:44
Done.
|
+ // testExpected("event.contentType", "video/webm"); |
+ testArraysEqual("event.initData", expectedInitData); |
+ |
+ if (--expectedEvents == 0) |
+ endTest(); |
+ } |
+ </script> |
+ </head> |
+ <body onload="runTest()"> |
+ <p>This tests that the 'needkey' event is generated.</p> |
+ <video></video> |
+ </body> |
+</html> |