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

Side by Side Diff: LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeysession-release.html

Issue 209103002: Add lifetime tests for MediaKeySession (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Simplified one test 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>Test MediaKeySession lifetime</title>
5 <script src="../w3c-media-utils.js"></script>
6 <script src="../../resources/testharness.js"></script>
7 <script src="../../resources/testharnessreport.js"></script>
8 <script src="../../resources/gc.js"></script>
9 </head>
10 <body>
11 <div id="log"></div>
12 <script>
13 setup({ timeout: 60000 }); // Timeout for all tests to run.
14
15 // Since MediaKeySession (but not MediaKeys) are ActiveDOMObjects,
16 // we can determine when they are garbage collected.
17 // MediaKeySessions remain as long as:
18 // JavaScript has a reference to it
19 // OR (MediaKeys is around AND the session is not CLOSED)
20 async_test(function(test)
21 {
22 var startingActiveDOMObjectsCreated = window.internals.activeDOM ObjectCount(document);
xhwang 2014/03/26 22:59:09 ditto
jrummell 2014/03/26 23:32:09 Done.
23
24 function numActiveDOMObjectsCreated()
25 {
26 return window.internals.activeDOMObjectCount(document) - sta rtingActiveDOMObjectsCreated;
27 }
28
29 var mediaKeys = new MediaKeys("org.w3.clearkey");
30 var audioMediaKeySession = null;
31 var videoMediaKeySession = null;
32 var sessionsCreated = 0;
33
34 function onMessage(event)
35 {
36 event.target.release();
37 waitForEventAndRunStep("close", event.target, onClose, test) ;
38 }
39
40 function onClose(event)
41 {
42 --sessionsCreated;
43 if (sessionsCreated > 0)
44 return;
45
46 // Delay to give time for close to complete.
47 setTimeout(finish, 250);
xhwang 2014/03/26 22:59:09 Why do we need this?
jrummell 2014/03/26 23:32:09 The onClose() event is fired against the MediaKeyS
48 }
49
50 function finish()
51 {
52 // Since both sessions have been released, dropping the
53 // reference to them from JS will result in the session
54 // being garbage-collected.
55 consoleWrite("Finish");
xhwang 2014/03/26 22:59:09 Do we need this?
xhwang 2014/03/26 22:59:09 Double check that mediaKeys is not null here?
jrummell 2014/03/26 23:32:09 No more than we need the EVENT(xx) messages. This
jrummell 2014/03/26 23:32:09 Done.
56 assert_equals(numActiveDOMObjectsCreated(), 2);
57
58 videoMediaKeySession = null;
59 gc();
60 assert_equals(numActiveDOMObjectsCreated(), 1, "videoMediaKe ySession not collected");
61
62 audioMediaKeySession = null;
63 gc();
64 assert_equals(numActiveDOMObjectsCreated(), 0, "audioMediaKe ySession not collected");
65
66 test.done();
67 }
68
69 // Create 2 sessions.
70 audioMediaKeySession = mediaKeys.createSession('video/webm', new Uint8Array([1, 2, 3]));
71 waitForEventAndRunStep("message", audioMediaKeySession, onMessag e, test);
xhwang 2014/03/26 22:59:09 Double checked. We actually don't need to wait for
jrummell 2014/03/26 23:32:09 Done.
72 videoMediaKeySession = mediaKeys.createSession('video/webm', new Uint8Array([4, 5]));
xhwang 2014/03/26 22:59:09 Just use mediaKeySession1 and mediaKeySession2 to
jrummell 2014/03/26 23:32:09 Done.
73 waitForEventAndRunStep("message", videoMediaKeySession, onMessag e, test);
74 sessionsCreated = 2;
75 }, "MediaKeySession lifetime after release()", { timeout: 60000 });
76 </script>
77 </body>
78 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698