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

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: assert_true added 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..354db4ab66e31711a1b88bc618acfd18d187c951
--- /dev/null
+++ b/LayoutTests/media/encrypted-media/encrypted-media-playback-multiple-sessions.html
@@ -0,0 +1,104 @@
+<!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>
+ setup({ timeout: 60000 }); // Timeout for all tests to run.
+
+ 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)
+ {
+ var keyId = String.fromCharCode.apply(null, event.initData);
+ var newSession = mediaKeys.createSession(event.contentType, event.initData);
+ if (keyId == videoKeyId) {
+ assert_equals(videoMediaKeySession, null);
+ videoMediaKeySession = newSession;
+ } else {
+ assert_equals(keyId, audioKeyId);
+ assert_equals(audioMediaKeySession, null);
+ audioMediaKeySession = newSession;
+ }
+ waitForEventAndRunStep("message", newSession, onMessage, test);
+ }
+
+ function onMessage(event)
+ {
+ 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)
+ {
+ if (event.target == videoMediaKeySession) {
+ videoSessionReadyReceived = true;
+ } else {
+ assert_equals(event.target, audioMediaKeySession);
+ audioSessionReadyReceived = true;
+ }
+ }
+
+ function onPlaying(event)
+ {
+ assert_true(audioSessionReadyReceived);
ddorwin 2014/03/21 18:16:38 I'm not sure if there is a guarantee that we will
jrummell 2014/03/21 18:50:18 Done.
+ assert_true(videoSessionReadyReceived);
+ assert_true(event.target.currentTime < 0.2);
ddorwin 2014/03/21 18:16:38 I don't think this is necessary. In theory, the ev
jrummell 2014/03/21 18:50:18 Checking that the video did not play. However, it
+
+ // Not using waitForEventAndRunStep() to avoid too many EVENT(onTimeUpdate) logs.
+ video.addEventListener("timeupdate", onTimeUpdate, true);
+ }
+
+ function onTimeUpdate(event)
+ {
+ if (event.target.currentTime < 0.2)
+ return;
+
+ test.done();
+ }
+
+ waitForEventAndRunStep("needkey", video, onNeedKey, test);
+ waitForEventAndRunStep("playing", video, onPlaying, test);
+
+ video.src = "../content/test-encrypted-different-av-keys.webm";
+ video.setMediaKeys(mediaKeys);
+ video.play();
+ }, "Playback using Clear Key key system with multiple sessions.",
+ { timeout: 60000 });
+ </script>
+ </body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698