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

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: remove extra asserts 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 waitForEventAndRunStep("message", videoMediaKeySession, onMessage, test);
ddorwin 2014/03/21 17:36:49 This line can go after the line 47 if we replace v
jrummell 2014/03/21 18:03:59 Done.
42 } else {
43 assert_equals(keyId, audioKeyId);
44 assert_equals(audioMediaKeySession, null);
45 audioMediaKeySession = newSession;
46 waitForEventAndRunStep("message", audioMediaKeySession, onMessage, test);
47 }
48 }
49
50 function onMessage(event)
51 {
52 var keyId = event.message;
53 if (event.target == videoMediaKeySession) {
54 assert_equals(String.fromCharCode.apply(null, keyId), vi deoKeyId);
55 var jwkSet = stringToUint8Array(createJWKSet(createJWK(k eyId, videoKey)));
56 videoMediaKeySession.update(jwkSet);
57 waitForEventAndRunStep("ready", videoMediaKeySession, on Ready, test);
58 } else {
59 assert_equals(event.target, audioMediaKeySession);
60 assert_equals(String.fromCharCode.apply(null, keyId), au dioKeyId);
61 var jwkSet = stringToUint8Array(createJWKSet(createJWK(k eyId, audioKey)));
62 audioMediaKeySession.update(jwkSet);
63 waitForEventAndRunStep("ready", audioMediaKeySession, on Ready, test);
64 }
65 }
66
67 function onReady(event)
68 {
69 if (event.target == videoMediaKeySession) {
70 videoSessionReadyReceived = true;
71 } else {
72 assert_equals(event.target, audioMediaKeySession);
73 audioSessionReadyReceived = true;
74 }
75 }
76
77 function onPlaying(event)
78 {
79 // Not using waitForEventAndRunStep() to avoid too many EVEN T(onTimeUpdate) logs.
80 video.addEventListener("timeupdate", onTimeUpdate, true);
81 }
82
83 function onTimeUpdate(event)
84 {
85 if (!audioSessionReadyReceived || !videoSessionReadyReceived )
86 return;
87 if (event.target.currentTime < 0.2)
88 return;
89
90 test.done();
91 }
92
93 waitForEventAndRunStep("needkey", video, onNeedKey, test);
94 waitForEventAndRunStep("playing", video, onPlaying, test);
95
96 video.src = "../content/test-encrypted-different-av-keys.webm";
97 video.setMediaKeys(mediaKeys);
98 video.play();
99 }, "Playback using Clear Key key system with multiple sessions.",
100 { timeout: 60000 });
101 </script>
102 </body>
103 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698