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

Unified 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: count ActiveDOMObjects Created 6 years, 10 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeys.html
diff --git a/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeys.html b/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeys.html
new file mode 100644
index 0000000000000000000000000000000000000000..9921a6dcceefdc28f701b6d5121c72eea44068d0
--- /dev/null
+++ b/LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeys.html
@@ -0,0 +1,74 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Test MediaKeys lifetime</title>
+ <script src="../../resources/testharness.js"></script>
+ <script src="../../resources/testharnessreport.js"></script>
+ <script src="../../resources/gc.js"></script>
+ <script src="encrypted-media-utils.js"></script>
+ </head>
+ <body>
+ <div id="log"></div>
+ <script>
+ // Since MediaKeys are not ActiveDOMObjects, it is hard to
+ // determine when they are garbage collected. For this test, we add
+ // a MediaKeySession (which are ActiveDOMObjects) to each one so
ddorwin 2014/02/27 22:28:17 You should explain why this works and what we assu
jrummell 2014/02/28 00:08:38 Done.
+ // we can count.
+ test(function()
+ {
+ var mediaKeys;
+ var initData = stringToUint8Array("mock");
+ var startingObjects = window.internals.activeDOMObjectCount(document);
+
+ function objectsCreated()
ddorwin 2014/02/27 22:28:17 This sounds like an event handler. :) Maybe numObj
jrummell 2014/02/28 00:08:38 Done.
+ {
+ return window.internals.activeDOMObjectCount(document) - startingObjects;
+ }
+
+ // Create a MediaKeys object.
ddorwin 2014/02/27 22:28:17 We could probably have a simple test that releases
jrummell 2014/02/28 00:08:38 Done.
+ mediaKeys = new MediaKeys("org.w3.clearkey");
+ mediaKeys.createSession("video/webm", initData);
ddorwin 2014/02/27 22:28:17 Maybe this is just testing the rest of Blink, but
jrummell 2014/02/28 00:08:38 Done.
+ assert_not_equals(mediaKeys, null);
ddorwin 2014/02/27 22:28:17 not really necessary.
jrummell 2014/02/28 00:08:38 Done.
+ assert_equals(mediaKeys.keySystem, 'org.w3.clearkey');
ddorwin 2014/02/27 22:28:17 This is probably checking that the mediaKeys is va
jrummell 2014/02/28 00:08:38 Done.
+ assert_equals(objectsCreated(), 1);
+
+ // Run gc(), should not affect MediaKeys object since we have
ddorwin 2014/02/27 22:28:17 This is basically the test in my comment at line 3
jrummell 2014/02/28 00:08:38 Done.
+ // a reference to it.
+ gc();
+ assert_not_equals(mediaKeys, null);
+ assert_equals(mediaKeys.keySystem, 'org.w3.clearkey');
+ assert_equals(objectsCreated(), 1);
+
+ // Drop reference to the MediaKeys object and run gc again.
+ // Object should be collected this time. Running gc() twice
ddorwin 2014/02/27 22:28:17 This is basically my comment at line 28. BUT, we s
jrummell 2014/02/28 00:08:38 Done.
+ // as the first pass may not actually get the created session.
+ mediaKeys = null;
+ gc();
+ gc();
ddorwin 2014/02/27 22:28:17 explain
jrummell 2014/02/28 00:08:38 Expanded comment.
+ assert_equals(objectsCreated(), 0);
+
ddorwin 2014/02/27 22:28:17 We should probably rerun the above tests here but
jrummell 2014/02/28 00:08:38 Not sure the benefit of a separate test.
+ // Create a large number of MediaKeys objects.
ddorwin 2014/02/27 22:28:17 I'm not sure what this does. If we keep it, it sho
jrummell 2014/02/28 00:08:38 ditto.
+ for (var i = 0; i < 100; ++i) {
+ mediaKeys = new MediaKeys("org.w3.clearkey");
+ mediaKeys.createSession("video/webm", initData);
+ }
+ assert_equals(objectsCreated(), 100);
+
+ // All but the last one created should be garbage collected.
+ gc();
+ gc();
+ assert_equals(objectsCreated(), 1);
+
+ // Last MediaKeys object created should still be referenced.
+ assert_not_equals(mediaKeys, null);
+ assert_equals(mediaKeys.keySystem, 'org.w3.clearkey');
+
+ // Release the last MediaKeys object created.
+ mediaKeys = null;
+ gc();
+ gc();
+ assert_equals(objectsCreated(), 0);
+ }, "MediaKeys lifetime");
+ </script>
+ </body>
+</html>
« 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