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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Clear Key Playback with Multiple Sessions</title>
5 <script src="encrypted-media-utils.js"></script>
6 <script src="../w3c-media-utils.js"></script>
7 <script src="../../resources/testharness.js"></script>
8 <script src="../../resources/testharnessreport.js"></script>
9 </head>
10 <body>
11 <video id="testVideo"></video>
12 <div id="log"></div>
13 <p>Test playback of encrypted media using Clear Key key system with mult iple sessions.</p>
14 <script>
15 setup({ timeout: 60000 }); // Timeout for all tests to run.
16
17 async_test(function(test)
18 {
19 var video = document.getElementById("testVideo");
20 var mediaKeys = new MediaKeys("org.w3.clearkey");
21 var audioMediaKeySession = null;
22 var videoMediaKeySession = null;
23 var audioSessionReadyReceived = false;
24 var videoSessionReadyReceived = false;
25
26 // The 2 streams use different key ids and different keys.
27 var audioKeyId = "1234567890123456";
28 var audioKey = new Uint8Array([0x30, 0x30, 0x62, 0xF1, 0x68, 0x1 4, 0xD2, 0x7B,
29 0x68, 0xEF, 0x12, 0x2A, 0xFC, 0xE 4, 0xAE, 0x0A]);
30 var videoKeyId = "0123456789012345";
31 var videoKey = new Uint8Array([0x7A, 0x7A, 0x62, 0xF1, 0x68, 0x1 4, 0xD2, 0x7B,
32 0x68, 0xEF, 0x12, 0x2A, 0xFC, 0xE 4, 0xAE, 0x0A]);
33
34 function onNeedKey(event)
35 {
36 var keyId = String.fromCharCode.apply(null, event.initData);
37 var newSession = mediaKeys.createSession(event.contentType, event.initData);
38 if (keyId == videoKeyId) {
39 assert_equals(videoMediaKeySession, null);
40 videoMediaKeySession = newSession;
41 } else {
42 assert_equals(keyId, audioKeyId);
43 assert_equals(audioMediaKeySession, null);
44 audioMediaKeySession = newSession;
45 }
46 waitForEventAndRunStep("message", newSession, onMessage, tes t);
47 }
48
49 function onMessage(event)
50 {
51 var keyId = event.message;
52 if (event.target == videoMediaKeySession) {
53 assert_equals(String.fromCharCode.apply(null, keyId), vi deoKeyId);
54 var jwkSet = stringToUint8Array(createJWKSet(createJWK(k eyId, videoKey)));
55 videoMediaKeySession.update(jwkSet);
56 waitForEventAndRunStep("ready", videoMediaKeySession, on Ready, test);
57 } else {
58 assert_equals(event.target, audioMediaKeySession);
59 assert_equals(String.fromCharCode.apply(null, keyId), au dioKeyId);
60 var jwkSet = stringToUint8Array(createJWKSet(createJWK(k eyId, audioKey)));
61 audioMediaKeySession.update(jwkSet);
62 waitForEventAndRunStep("ready", audioMediaKeySession, on Ready, test);
63 }
64 }
65
66 function onReady(event)
67 {
68 if (event.target == videoMediaKeySession) {
69 videoSessionReadyReceived = true;
70 } else {
71 assert_equals(event.target, audioMediaKeySession);
72 audioSessionReadyReceived = true;
73 }
74 }
75
76 function onPlaying(event)
77 {
78 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.
79 assert_true(videoSessionReadyReceived);
80 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
81
82 // Not using waitForEventAndRunStep() to avoid too many EVEN T(onTimeUpdate) logs.
83 video.addEventListener("timeupdate", onTimeUpdate, true);
84 }
85
86 function onTimeUpdate(event)
87 {
88 if (event.target.currentTime < 0.2)
89 return;
90
91 test.done();
92 }
93
94 waitForEventAndRunStep("needkey", video, onNeedKey, test);
95 waitForEventAndRunStep("playing", video, onPlaying, test);
96
97 video.src = "../content/test-encrypted-different-av-keys.webm";
98 video.setMediaKeys(mediaKeys);
99 video.play();
100 }, "Playback using Clear Key key system with multiple sessions.",
101 { timeout: 60000 });
102 </script>
103 </body>
104 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698