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

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
« no previous file with comments | « no previous file | LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeysession-reference.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // In non-Oilpan, numActiveDOMObjectsCreate() == 0.
46 // In Oilpan, numActiveDOMObjectsCreate() <= 2.
47 // (1 MediaKeysInitializer and
48 // 1 MediaKeySystemAccessInitializer).
49 assert_less_than_equal(numActiveDOMObjectsCreated(), 2, 'Med iaKeys.create()');
46 50
47 var initDataType = getInitDataType(); 51 var initDataType = getInitDataType();
48 var mediaKeySession = mediaKeys.createSession(); 52 var mediaKeySession = mediaKeys.createSession();
49 return mediaKeySession.generateRequest(initDataType, getInit Data(initDataType)); 53 return mediaKeySession.generateRequest(initDataType, getInit Data(initDataType));
50 }).then(function() { 54 }).then(function() {
51 // 1 MediaKeySession. 55 // 1 MediaKeySession.
52 assert_equals(numActiveDOMObjectsCreated(), 1, 'MediaKeys.cr eateSession()'); 56 // In non-Oilpan, numActiveDOMObjectsCreate() == 1.
57 // In Oilpan, numActiveDOMObjectsCreate() <= 4.
58 // (1 MediaKeysInitializer,
59 // 1 MediaKeySystemAccessInitializer,
60 // 1 ContentDecryptionModuleResultPromise and
61 // 1 MediaKeySession).
62 assert_less_than_equal(numActiveDOMObjectsCreated(), 4, 'Med iaKeys.createSession(1)');
53 63
54 // Run gc(), should not affect MediaKeys object nor the 64 // Run gc(), should not affect MediaKeys object nor the
55 // session since we still have a reference to it. 65 // session since we still have a reference to it.
66
67 // When enabling oilpan GC, the in-active
68 // ScriptPromiseResolvers will be destroyed.
56 return createGCPromise(); 69 return createGCPromise();
57 }).then(function(result) { 70 }).then(function(result) {
58 assert_equals(typeof mediaKeys.createSession, 'function'); 71 assert_equals(typeof mediaKeys.createSession, 'function');
59 // Ensure that MediaKeySession (but not PromiseResolver) is 72 // Ensure that MediaKeySession (but not PromiseResolver) is
60 // still around. 73 // still around.
61 assert_equals(numActiveDOMObjectsCreated(), 1, 'After gc()') ; 74 assert_equals(numActiveDOMObjectsCreated(), 1, 'After gc()') ;
62 75
63 // Drop reference to the MediaKeys object and run gc() 76 // Drop reference to the MediaKeys object and run gc()
64 // again. Object should be collected this time. Since 77 // again. Object should be collected this time. Since
65 // MediaKeySessions remain alive as long as MediaKeys is 78 // MediaKeySessions remain alive as long as MediaKeys is
66 // around, it is possible that gc() checks the 79 // around, it is possible that gc() checks the
67 // MediaKeySession object first, and doesn't collect it 80 // MediaKeySession object first, and doesn't collect it
68 // since MediaKeys hasn't been collected yet. Thus run gc() 81 // since MediaKeys hasn't been collected yet. Thus run gc()
69 // twice, to ensure that the unreferenced MediaKeySession 82 // twice, to ensure that the unreferenced MediaKeySession
70 // object get collected. 83 // object get collected.
71 mediaKeys = null; 84 mediaKeys = null;
72 return createGCPromise(); 85 return createGCPromise();
73 }).then(function(result) { 86 }).then(function(result) {
74 return createGCPromise(); 87 return createGCPromise();
75 }).then(function(result) { 88 }).then(function(result) {
76 assert_equals(numActiveDOMObjectsCreated(), 0); 89 assert_equals(numActiveDOMObjectsCreated(), 0);
77 test.done(); 90 test.done();
78 }).catch(function(error) { 91 }).catch(function(error) {
79 forceTestFailureFromPromise(test, error); 92 forceTestFailureFromPromise(test, error);
80 }); 93 });
81 }, 'MediaKeys lifetime with session'); 94 }, 'MediaKeys lifetime with session');
82 </script> 95 </script>
83 </body> 96 </body>
84 </html> 97 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/media/encrypted-media/encrypted-media-lifetime-mediakeysession-reference.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698