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

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

Issue 783423003: Make ScriptPromiseResolver RefCountedWillBeRefCountedGarbageCollected. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years 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
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Test MediaKeys lifetime when adding a session</title> 4 <title>Test MediaKeys lifetime when adding a session</title>
5 <script src="encrypted-media-utils.js"></script> 5 <script src="encrypted-media-utils.js"></script>
6 <script src="../../resources/testharness.js"></script> 6 <script src="../../resources/testharness.js"></script>
7 <script src="../../resources/testharnessreport.js"></script> 7 <script src="../../resources/testharnessreport.js"></script>
8 </head> 8 </head>
9 <body> 9 <body>
10 <div id="log"></div> 10 <div id="log"></div>
(...skipping 24 matching lines...) Expand all
35 } 35 }
36 36
37 // Create a MediaKeys object with a session. 37 // Create a MediaKeys object with a session.
38 navigator.requestMediaKeySystemAccess('org.w3.clearkey').then(fu nction(access) { 38 navigator.requestMediaKeySystemAccess('org.w3.clearkey').then(fu nction(access) {
39 assert_equals(access.keySystem, 'org.w3.clearkey'); 39 assert_equals(access.keySystem, 'org.w3.clearkey');
40 return access.createMediaKeys(); 40 return access.createMediaKeys();
41 }).then(function(result) { 41 }).then(function(result) {
42 mediaKeys = result; 42 mediaKeys = result;
43 43
44 // Verify MediaKeys are not an ActiveDOMObject. 44 // Verify MediaKeys are not an ActiveDOMObject.
45 assert_equals(numActiveDOMObjectsCreated(), 0, 'MediaKeys.cr eate()'); 45 // MediaKeys are not an ActiveDOMObject, but when creating M ediaKeys,
46 // creating ScriptPromiseResolvers, which are ActiveDOMObjec ts.
47 // so numActiveDOMObjetsCreated() <= 2 (1 is MediaKeysInitia lizer and
48 // the other is MediaKeySystemAccessInitializer).
49 // When enabling oilpan, the ScriptPromiseResolvers are not destroyed
50 // immediately. So numActiveDOMObjectsCreate() <= 2.
haraken 2014/12/16 13:52:45 Simplify the comment. // In non-Oilpan, numActive
tasak 2014/12/17 08:40:08 Done.
51 assert_less_than_equal(numActiveDOMObjectsCreated(), 2, 'Med iaKeys.create()');
46 52
47 var initDataType = getInitDataType(); 53 var initDataType = getInitDataType();
48 var mediaKeySession = mediaKeys.createSession(); 54 var mediaKeySession = mediaKeys.createSession();
49 return mediaKeySession.generateRequest(initDataType, getInit Data(initDataType)); 55 return mediaKeySession.generateRequest(initDataType, getInit Data(initDataType));
50 }).then(function() { 56 }).then(function() {
51 // 1 MediaKeySession. 57 // 1 MediaKeySession.
52 assert_equals(numActiveDOMObjectsCreated(), 1, 'MediaKeys.cr eateSession()'); 58 // numActiveDOMObjectsCreated() <= 4 (1 is a ScriptPromiseRe solver owned by
59 // ContentDecryptionModuleResultPromise and the other is Med iaKeySession).
60 assert_less_than_equal(numActiveDOMObjectsCreated(), 4, 'Med iaKeys.createSession(1)');
53 61
54 // Run gc(), should not affect MediaKeys object nor the 62 // Run gc(), should not affect MediaKeys object nor the
55 // session since we still have a reference to it. 63 // session since we still have a reference to it.
64
65 // When enabling oilpan GC, the in-active ScriptPromiseResol vers will be
66 // destroyed.
56 return createGCPromise(); 67 return createGCPromise();
57 }).then(function(result) { 68 }).then(function(result) {
58 assert_equals(typeof mediaKeys.createSession, 'function'); 69 assert_equals(typeof mediaKeys.createSession, 'function');
59 // Ensure that MediaKeySession (but not PromiseResolver) is 70 // Ensure that MediaKeySession (but not PromiseResolver) is
60 // still around. 71 // still around.
61 assert_equals(numActiveDOMObjectsCreated(), 1, 'After gc()') ; 72 assert_equals(numActiveDOMObjectsCreated(), 1, 'After gc()') ;
62 73
63 // Drop reference to the MediaKeys object and run gc() 74 // Drop reference to the MediaKeys object and run gc()
64 // again. Object should be collected this time. Since 75 // again. Object should be collected this time. Since
65 // MediaKeySessions remain alive as long as MediaKeys is 76 // MediaKeySessions remain alive as long as MediaKeys is
66 // around, it is possible that gc() checks the 77 // around, it is possible that gc() checks the
67 // MediaKeySession object first, and doesn't collect it 78 // MediaKeySession object first, and doesn't collect it
68 // since MediaKeys hasn't been collected yet. Thus run gc() 79 // since MediaKeys hasn't been collected yet. Thus run gc()
69 // twice, to ensure that the unreferenced MediaKeySession 80 // twice, to ensure that the unreferenced MediaKeySession
70 // object get collected. 81 // object get collected.
71 mediaKeys = null; 82 mediaKeys = null;
72 return createGCPromise(); 83 return createGCPromise();
73 }).then(function(result) { 84 }).then(function(result) {
74 return createGCPromise(); 85 return createGCPromise();
75 }).then(function(result) { 86 }).then(function(result) {
76 assert_equals(numActiveDOMObjectsCreated(), 0); 87 assert_equals(numActiveDOMObjectsCreated(), 0);
77 test.done(); 88 test.done();
78 }).catch(function(error) { 89 }).catch(function(error) {
79 forceTestFailureFromPromise(test, error); 90 forceTestFailureFromPromise(test, error);
80 }); 91 });
81 }, 'MediaKeys lifetime with session'); 92 }, 'MediaKeys lifetime with session');
82 </script> 93 </script>
83 </body> 94 </body>
84 </html> 95 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698