Chromium Code Reviews| Index: LayoutTests/media/encrypted-media/encrypted-media-playback-multiple-sessions.html |
| diff --git a/LayoutTests/media/encrypted-media/encrypted-media-playback-multiple-sessions.html b/LayoutTests/media/encrypted-media/encrypted-media-playback-multiple-sessions.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..df4931bc148b1bb3fceb50a7646f32de8497b765 |
| --- /dev/null |
| +++ b/LayoutTests/media/encrypted-media/encrypted-media-playback-multiple-sessions.html |
| @@ -0,0 +1,115 @@ |
| +<!DOCTYPE html> |
| +<html> |
| + <head> |
| + <title>Clear Key Playback with Multiple Sessions</title> |
| + <script src="encrypted-media-utils.js"></script> |
| + <script src="../w3c-media-utils.js"></script> |
| + <script src="../../resources/testharness.js"></script> |
| + <script src="../../resources/testharnessreport.js"></script> |
| + </head> |
| + <body> |
| + <video id="testVideo"></video> |
| + <div id="log"></div> |
| + <p>Test playback of encrypted media using Clear Key key system with multiple sessions.</p> |
| + <script> |
| + // Timeout for all tests to run. |
|
ddorwin
2014/03/21 06:00:20
It would be nice to have a single line for this ti
jrummell
2014/03/21 17:23:01
Done.
|
| + setup({ timeout: 60000 }); |
|
ddorwin
2014/03/21 06:00:20
Oh, maybe this is from other files that ran multip
jrummell
2014/03/21 17:23:01
The testharness has 2 timeouts -- 1 for the timeou
ddorwin
2014/03/21 17:36:49
:(
Thanks for the explanation.
|
| + |
| + async_test(function(test) |
| + { |
| + var video = document.getElementById("testVideo"); |
| + var mediaKeys = new MediaKeys("org.w3.clearkey"); |
| + var audioMediaKeySession = null; |
| + var videoMediaKeySession = null; |
| + var audioSessionReadyReceived = false; |
| + var videoSessionReadyReceived = false; |
| + |
| + // The 2 streams use different key ids and different keys. |
| + var audioKeyId = "1234567890123456"; |
| + var audioKey = new Uint8Array([0x30, 0x30, 0x62, 0xF1, 0x68, 0x14, 0xD2, 0x7B, |
| + 0x68, 0xEF, 0x12, 0x2A, 0xFC, 0xE4, 0xAE, 0x0A]); |
| + var videoKeyId = "0123456789012345"; |
| + var videoKey = new Uint8Array([0x7A, 0x7A, 0x62, 0xF1, 0x68, 0x14, 0xD2, 0x7B, |
| + 0x68, 0xEF, 0x12, 0x2A, 0xFC, 0xE4, 0xAE, 0x0A]); |
| + |
| + function onNeedKey(event) |
| + { |
| + assert_equals(event.target, video); |
|
ddorwin
2014/03/21 06:00:20
We're not specifically testing the events, so we p
jrummell
2014/03/21 17:23:01
Sure. I just copied the regular playback test and
|
| + assert_true(event instanceof window.MediaKeyNeededEvent); |
| + assert_equals(event.type, "needkey"); |
| + |
| + // Ideally we could just look at event.contentType, but it |
|
ddorwin
2014/03/21 06:00:20
This comment is unnecessary - the spec says you ca
jrummell
2014/03/21 17:23:01
Done.
|
| + // is used to specify the encoding format, not the stream |
| + // (and both streams are webm). |
| + var keyId = String.fromCharCode.apply(null, event.initData); |
| + if (keyId == videoKeyId) { |
| + assert_equals(videoMediaKeySession, null); |
| + videoMediaKeySession = mediaKeys.createSession(event.contentType, event.initData); |
|
ddorwin
2014/03/21 06:00:20
nit: We could share a bit more code by creating th
jrummell
2014/03/21 17:23:01
Done.
|
| + waitForEventAndRunStep("message", videoMediaKeySession, onMessage, test); |
| + } else { |
| + assert_equals(keyId, audioKeyId); |
| + assert_equals(audioMediaKeySession, null); |
| + audioMediaKeySession = mediaKeys.createSession(event.contentType, event.initData); |
| + waitForEventAndRunStep("message", audioMediaKeySession, onMessage, test); |
| + } |
| + } |
| + |
| + function onMessage(event) |
| + { |
| + assert_true(event instanceof window.MediaKeyMessageEvent); |
| + assert_equals(event.type, "message"); |
| + var keyId = event.message; |
| + |
| + if (event.target == videoMediaKeySession) { |
| + assert_equals(String.fromCharCode.apply(null, keyId), videoKeyId); |
| + var jwkSet = stringToUint8Array(createJWKSet(createJWK(keyId, videoKey))); |
| + videoMediaKeySession.update(jwkSet); |
| + waitForEventAndRunStep("ready", videoMediaKeySession, onReady, test); |
| + } else { |
| + assert_equals(event.target, audioMediaKeySession); |
| + assert_equals(String.fromCharCode.apply(null, keyId), audioKeyId); |
| + var jwkSet = stringToUint8Array(createJWKSet(createJWK(keyId, audioKey))); |
| + audioMediaKeySession.update(jwkSet); |
| + waitForEventAndRunStep("ready", audioMediaKeySession, onReady, test); |
| + } |
| + } |
| + |
| + function onReady(event) |
| + { |
| + assert_true(event instanceof window.Event); |
| + assert_equals(event.type, "ready"); |
| + if (event.target == videoMediaKeySession) { |
| + videoSessionReadyReceived = true; |
| + } else { |
| + assert_equals(event.target, audioMediaKeySession); |
| + audioSessionReadyReceived = true; |
| + } |
| + } |
| + |
| + function onPlaying(event) |
|
ddorwin
2014/03/21 06:00:20
OOC, could we just register the timeupdate event d
jrummell
2014/03/21 17:23:01
I'm not sure it makes any difference. We still wan
ddorwin
2014/03/21 17:36:49
Do we really not get a playing event until the key
jrummell
2014/03/21 18:03:59
Test that Ready received for both audio and video
|
| + { |
| + // Not using waitForEventAndRunStep() to avoid too many EVENT(onTimeUpdate) logs. |
| + video.addEventListener("timeupdate", onTimeUpdate, true); |
| + } |
| + |
| + function onTimeUpdate(event) |
| + { |
| + if (!audioSessionReadyReceived || !videoSessionReadyReceived) |
| + return; |
| + if (event.target.currentTime < 0.2) |
|
ddorwin
2014/03/21 06:00:20
FYI: I think this only works as a test if the play
jrummell
2014/03/21 17:23:01
If I remove either of the update() calls in onMess
ddorwin
2014/03/21 17:36:49
Okay. We should have a test like this when we star
jrummell
2014/03/21 18:03:59
Done.
|
| + return; |
| + |
| + test.done(); |
| + } |
| + |
| + waitForEventAndRunStep("needkey", video, onNeedKey, test); |
| + waitForEventAndRunStep("playing", video, onPlaying, test); |
| + |
| + video.src = "../content/test-encrypted-2-keys.webm"; |
|
ddorwin
2014/03/21 06:00:20
nit: We should name it different-av-keys or someth
jrummell
2014/03/21 17:23:01
Done.
|
| + video.setMediaKeys(mediaKeys); |
| + video.play(); |
| + }, "Playback using Clear Key key system with multiple sessions.", |
| + { timeout: 60000 }); |
| + </script> |
| + </body> |
| +</html> |