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

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

Issue 180203002: Add EME content test that forces garbage collection (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Changes 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
« no previous file with comments | « no previous file | LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeys-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Test MediaKeys lifetime</title>
5 <script src="../../resources/testharness.js"></script>
6 <script src="../../resources/testharnessreport.js"></script>
7 <script src="../../resources/gc.js"></script>
8 <script src="encrypted-media-utils.js"></script>
9 </head>
10 <body>
11 <div id="log"></div>
12 <script>
13 // Since MediaKeys are not ActiveDOMObjects, it is hard to
14 // determine when they are garbage collected. For this test, we add
15 // a MediaKeySession (which are ActiveDOMObjects) to each one so
16 // we can count. MediaKeySession objects will not be garbage collect ed
17 // as long as the MediaKeys object is around (or the session gets
18 // closed, which isn't happening in this test).
19 test(function()
20 {
21 var mediaKeys;
22 var initData = stringToUint8Array("mock");
23 var startingObjects = window.internals.activeDOMObjectCount(docu ment);
24
25 function numObjectsCreated()
26 {
27 return window.internals.activeDOMObjectCount(document) - sta rtingObjects;
28 }
29
30 // Create a MediaKeys object and free immediately.
31 mediaKeys = new MediaKeys("org.w3.clearkey");
32 mediaKeys = null;
33 gc();
34
35 // Create a MediaKeys object and make sure gc doesn't free it
36 // as long as we have a reference.
37 mediaKeys = new MediaKeys("org.w3.clearkey");
38 gc();
39 assert_equals(mediaKeys.keySystem, 'org.w3.clearkey');
40 mediaKeys = null;
41 gc();
42
43 // Create a MediaKeys object with a session.
ddorwin 2014/02/28 05:09:38 By using separate test()'s, you can clearly separa
jrummell 2014/04/01 19:06:43 Done.
44 mediaKeys = new MediaKeys("org.w3.clearkey");
45 mediaKeys.createSession("video/webm", initData);
46 assert_equals(numObjectsCreated(), 1);
47
48 // Run gc(), should not affect MediaKeys object since we have
49 // a reference to it, nor the session.
ddorwin 2014/02/28 05:09:38 I think you mean to add the new text after "object
jrummell 2014/04/01 19:06:43 Done.
50 gc();
51 assert_equals(mediaKeys.keySystem, 'org.w3.clearkey');
52 assert_equals(numObjectsCreated(), 1);
53
54 // Drop reference to the MediaKeys object and run gc again.
55 // Object should be collected this time. Running gc() twice
56 // as the first pass may not actually collect the created
57 // session (session is only collected if the MediaKeys object
58 // is gone, which won't happen if the first pass happens to
59 // check the session object first).
60 mediaKeys = null;
61 gc();
62 gc();
63 assert_equals(numObjectsCreated(), 0);
64
65 // Create a few MediaKeys objects. We don't want to trigger
66 // a gc due to memory pressure.
ddorwin 2014/02/28 05:09:38 Is that really likely? I don't think that's enough
jrummell 2014/04/01 19:06:43 Comment updated.
67 for (var i = 0; i < 5; ++i) {
68 mediaKeys = new MediaKeys("org.w3.clearkey");
69 mediaKeys.createSession("video/webm", initData);
70 }
71 assert_equals(numObjectsCreated(), 5);
72
73 // All but the last one created should be garbage collected.
74 gc();
75 gc();
76 assert_equals(numObjectsCreated(), 1);
77
78 // Last MediaKeys object created should still be referenced.
79 assert_equals(mediaKeys.keySystem, 'org.w3.clearkey');
80
81 // Release the last MediaKeys object created.
82 mediaKeys = null;
83 gc();
84 gc();
85 assert_equals(numObjectsCreated(), 0);
86 }, "MediaKeys lifetime");
87 </script>
88 </body>
89 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeys-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698