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

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: New test file 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 // 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.
16 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.
17
18 async_test(function(test)
19 {
20 var video = document.getElementById("testVideo");
21 var mediaKeys = new MediaKeys("org.w3.clearkey");
22 var audioMediaKeySession = null;
23 var videoMediaKeySession = null;
24 var audioSessionReadyReceived = false;
25 var videoSessionReadyReceived = false;
26
27 // The 2 streams use different key ids and different keys.
28 var audioKeyId = "1234567890123456";
29 var audioKey = new Uint8Array([0x30, 0x30, 0x62, 0xF1, 0x68, 0x1 4, 0xD2, 0x7B,
30 0x68, 0xEF, 0x12, 0x2A, 0xFC, 0xE 4, 0xAE, 0x0A]);
31 var videoKeyId = "0123456789012345";
32 var videoKey = new Uint8Array([0x7A, 0x7A, 0x62, 0xF1, 0x68, 0x1 4, 0xD2, 0x7B,
33 0x68, 0xEF, 0x12, 0x2A, 0xFC, 0xE 4, 0xAE, 0x0A]);
34
35 function onNeedKey(event)
36 {
37 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
38 assert_true(event instanceof window.MediaKeyNeededEvent);
39 assert_equals(event.type, "needkey");
40
41 // 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.
42 // is used to specify the encoding format, not the stream
43 // (and both streams are webm).
44 var keyId = String.fromCharCode.apply(null, event.initData);
45 if (keyId == videoKeyId) {
46 assert_equals(videoMediaKeySession, null);
47 videoMediaKeySession = mediaKeys.createSession(event.con tentType, 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.
48 waitForEventAndRunStep("message", videoMediaKeySession, onMessage, test);
49 } else {
50 assert_equals(keyId, audioKeyId);
51 assert_equals(audioMediaKeySession, null);
52 audioMediaKeySession = mediaKeys.createSession(event.con tentType, event.initData);
53 waitForEventAndRunStep("message", audioMediaKeySession, onMessage, test);
54 }
55 }
56
57 function onMessage(event)
58 {
59 assert_true(event instanceof window.MediaKeyMessageEvent);
60 assert_equals(event.type, "message");
61 var keyId = event.message;
62
63 if (event.target == videoMediaKeySession) {
64 assert_equals(String.fromCharCode.apply(null, keyId), vi deoKeyId);
65 var jwkSet = stringToUint8Array(createJWKSet(createJWK(k eyId, videoKey)));
66 videoMediaKeySession.update(jwkSet);
67 waitForEventAndRunStep("ready", videoMediaKeySession, on Ready, test);
68 } else {
69 assert_equals(event.target, audioMediaKeySession);
70 assert_equals(String.fromCharCode.apply(null, keyId), au dioKeyId);
71 var jwkSet = stringToUint8Array(createJWKSet(createJWK(k eyId, audioKey)));
72 audioMediaKeySession.update(jwkSet);
73 waitForEventAndRunStep("ready", audioMediaKeySession, on Ready, test);
74 }
75 }
76
77 function onReady(event)
78 {
79 assert_true(event instanceof window.Event);
80 assert_equals(event.type, "ready");
81 if (event.target == videoMediaKeySession) {
82 videoSessionReadyReceived = true;
83 } else {
84 assert_equals(event.target, audioMediaKeySession);
85 audioSessionReadyReceived = true;
86 }
87 }
88
89 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
90 {
91 // Not using waitForEventAndRunStep() to avoid too many EVEN T(onTimeUpdate) logs.
92 video.addEventListener("timeupdate", onTimeUpdate, true);
93 }
94
95 function onTimeUpdate(event)
96 {
97 if (!audioSessionReadyReceived || !videoSessionReadyReceived )
98 return;
99 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.
100 return;
101
102 test.done();
103 }
104
105 waitForEventAndRunStep("needkey", video, onNeedKey, test);
106 waitForEventAndRunStep("playing", video, onPlaying, test);
107
108 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.
109 video.setMediaKeys(mediaKeys);
110 video.play();
111 }, "Playback using Clear Key key system with multiple sessions.",
112 { timeout: 60000 });
113 </script>
114 </body>
115 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698