Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Unified Diff: LayoutTests/media/encrypted-media/encrypted-media-playback-multiple-sessions.html

Issue 203323006: Add layout test for EME WD using multiple sessions (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..beec54ed9b40e582b5513726111694e8e586bac2
--- /dev/null
+++ b/LayoutTests/media/encrypted-media/encrypted-media-playback-multiple-sessions.html
@@ -0,0 +1,121 @@
+<!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>
+ async_test(function(test)
+ {
+ var video = document.getElementById("testVideo");
+ var mediaKeys = new MediaKeys("org.w3.clearkey");
+ var mediaKeyAudioSession = null;
+ var mediaKeyVideoSession = null;
xhwang 2014/03/19 01:22:00 nit: audioMediaKeySession/videoMediaKeySession ?
jrummell 2014/03/20 22:55:33 Done.
+ var audioSessionReadyReceived = false;
+ var videoSessionReadyReceived = false;
+
+ // The 2 streams use different key ids, but the keys are the
+ // same.
+ var audioKeyId = "0123456789";
+ var audioKey = new Uint8Array([0x7D, 0xE2, 0x6B, 0xE4, 0xD2, 0xC2, 0x2F, 0xD7,
+ 0xD7, 0x7A, 0x1F, 0x4C, 0xA5, 0xA9, 0x97, 0x0F]);
+ var videoKeyId = "0123456789012345";
+ var videoKey = audioKey;
+
+ function onNeedKey(event)
+ {
+ assert_equals(event.target, video);
+ assert_true(event instanceof window.MediaKeyNeededEvent);
+ assert_equals(event.type, "needkey");
+
+ // Ideally we could just look at event.contentType, but it
+ // 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(mediaKeyVideoSession, null);
+ mediaKeyVideoSession = mediaKeys.createSession(event.contentType, event.initData);
+ waitForEventAndRunStep("message", mediaKeyVideoSession, onVideoMessage, test);
+ } else {
+ assert_equals(keyId, audioKeyId);
+ assert_equals(mediaKeyAudioSession, null);
+ mediaKeyAudioSession = mediaKeys.createSession(event.contentType, event.initData);
+ waitForEventAndRunStep("message", mediaKeyAudioSession, onAudioMessage, test);
+ }
+ }
+
+ function onAudioMessage(event)
+ {
+ assert_true(event instanceof window.MediaKeyMessageEvent);
+ assert_equals(event.target, mediaKeyAudioSession);
+ assert_equals(event.type, "message");
+
+ var keyId = event.message;
+ assert_equals(String.fromCharCode.apply(null, keyId), audioKeyId);
+ var jwkSet = stringToUint8Array(createJWKSet(createJWK(keyId, audioKey)));
+ mediaKeyAudioSession.update(jwkSet);
+ waitForEventAndRunStep("ready", mediaKeyAudioSession, onAudioReady, test);
+ }
+
+ function onVideoMessage(event)
+ {
+ assert_true(event instanceof window.MediaKeyMessageEvent);
+ assert_equals(event.target, mediaKeyVideoSession);
+ assert_equals(event.type, "message");
+
+ var keyId = event.message;
+ assert_equals(String.fromCharCode.apply(null, keyId), videoKeyId);
+ var jwkSet = stringToUint8Array(createJWKSet(createJWK(keyId, videoKey)));
+ mediaKeyVideoSession.update(jwkSet);
+ waitForEventAndRunStep("ready", mediaKeyVideoSession, onVideoReady, test);
+ }
xhwang 2014/03/19 01:22:00 It seems we can combine onAudioMessage and onVideo
jrummell 2014/03/20 22:55:33 It doesn't really save that much duplication (most
+
+ function onAudioReady(event)
+ {
+ assert_true(event instanceof window.Event);
+ assert_equals(event.target, mediaKeyAudioSession);
+ assert_equals(event.type, "ready");
+ audioSessionReadyReceived = true;
+ }
+
+ function onVideoReady(event)
+ {
+ assert_true(event instanceof window.Event);
+ assert_equals(event.target, mediaKeyVideoSession);
+ assert_equals(event.type, "ready");
+ videoSessionReadyReceived = true;
+ }
xhwang 2014/03/19 01:22:00 ditto for combining methods to reduce duplicate co
jrummell 2014/03/20 22:55:33 Done.
+
+ function onPlaying(event)
+ {
+ // 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)
+ return;
xhwang 2014/03/19 01:22:00 If audio key is provided but video key is not prov
jrummell 2014/03/20 22:55:33 If I change onVideoMessage() to do nothing, the Pl
+
+ test.done();
+ }
+
+ waitForEventAndRunStep("needkey", video, onNeedKey, test);
+ waitForEventAndRunStep("playing", video, onPlaying, test);
+
+ video.src = "../content/test-encrypted-2-keys.webm";
xhwang 2014/03/19 01:22:00 This file is a bit confusing. It's called 2-keys b
jrummell 2014/03/20 22:55:33 Done.
+ video.setMediaKeys(mediaKeys);
+ video.play();
+ }, "Playback using Clear Key key system with multiple sessions.");
+ </script>
+ </body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698