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

Side by Side Diff: LayoutTests/media/encrypted-media/encrypted-media-lifetime-multiple-mediakeys.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 multiple MediaKeys lifetimes</title> 4 <title>Test multiple MediaKeys lifetimes</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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 return mediaKeySession.generateRequest(initDataType, ini tData).then(function() { 52 return mediaKeySession.generateRequest(initDataType, ini tData).then(function() {
53 return mediaKeySession; 53 return mediaKeySession;
54 }); 54 });
55 }); 55 });
56 } 56 }
57 57
58 // Create a few MediaKeys + MediaKeySession objects. Only keep 58 // Create a few MediaKeys + MediaKeySession objects. Only keep
59 // a reference to the last one created. 59 // a reference to the last one created.
60 createMediaKeyWithMediaKeySession().then(function(mediaKeySessio n) { 60 createMediaKeyWithMediaKeySession().then(function(mediaKeySessio n) {
61 // Should be 1 MediaKeySession. 61 // Should be 1 MediaKeySession.
62 assert_equals(numActiveDOMObjectsCreated(), 1); 62 // Since ScriptPromiseResolver is an ActiveDOMObject,
63 // MediaKeysInitializer, MediaKeySystemAccessInitializer, an d
64 // ScriptPromiseResolver owned by ContentDecryptionModuleRes ultPromise are
65 // also counted. So numActiveDOMObjectsCreated() is 4 when e nabling oilpan.
66 assert_less_than_equal(numActiveDOMObjectsCreated(), 4);
63 return createMediaKeyWithMediaKeySession(); 67 return createMediaKeyWithMediaKeySession();
64 }).then(function(mediaKeySession) { 68 }).then(function(mediaKeySession) {
65 // Should be 2 MediaKeySessions. 69 // Should be 2 MediaKeySessions.
66 assert_equals(numActiveDOMObjectsCreated(), 2); 70 assert_less_than_equal(numActiveDOMObjectsCreated(), 8);
67 return createMediaKeyWithMediaKeySession(); 71 return createMediaKeyWithMediaKeySession();
68 }).then(function(mediaKeySession) { 72 }).then(function(mediaKeySession) {
69 // Should be 3 MediaKeySessions. 73 // Should be 3 MediaKeySessions.
70 assert_equals(numActiveDOMObjectsCreated(), 3); 74 assert_less_than_equal(numActiveDOMObjectsCreated(), 12);
71 return createMediaKeyWithMediaKeySession(); 75 return createMediaKeyWithMediaKeySession();
72 }).then(function(mediaKeySession) { 76 }).then(function(mediaKeySession) {
73 // Should be 4 MediaKeySessions. 77 // Should be 4 MediaKeySessions.
74 assert_equals(numActiveDOMObjectsCreated(), 4); 78 assert_less_than_equal(numActiveDOMObjectsCreated(), 16);
75 return createMediaKeyWithMediaKeySession(); 79 return createMediaKeyWithMediaKeySession();
76 }).then(function(mediaKeySession) { 80 }).then(function(mediaKeySession) {
77 // Should be 5 MediaKeySessions. 81 // Should be 5 MediaKeySessions.
78 assert_equals(numActiveDOMObjectsCreated(), 5); 82 assert_less_than_equal(numActiveDOMObjectsCreated(), 20);
79 83
80 // |mediaKeys| refers to the most recently created MediaKeys 84 // |mediaKeys| refers to the most recently created MediaKeys
81 // object. 85 // object.
82 // 86 //
83 // In order for the MediaKeySession objects to have no 87 // In order for the MediaKeySession objects to have no
84 // outstanding activity so that they can be garbage 88 // outstanding activity so that they can be garbage
85 // collected, it needs time to process any pending events. 89 // collected, it needs time to process any pending events.
86 // As a "message" event is generated when a new session is 90 // As a "message" event is generated when a new session is
87 // created, we need to allow the event to run (we're not 91 // created, we need to allow the event to run (we're not
88 // doing anything with the event in this test). 92 // doing anything with the event in this test).
89 return delayToAllowEventProcessingPromise(); 93 return delayToAllowEventProcessingPromise();
90 }).then(function(result) { 94 }).then(function(result) {
91 // In non-Oilpan, numActiveDOMObjectsCreated() is 5 95 // In non-Oilpan, numActiveDOMObjectsCreated() is 5
92 // (5 MediaKeySession objects). 96 // (5 MediaKeySession objects).
93 // In Oilpan, numActiveDOMObjectsCreated() is 6 97 // In Oilpan, numActiveDOMObjectsCreated() is 21
94 // (5 MediaKeySession objects + 1 DOMTimer created in the 98 // (5 MediaKeySession objects + 15 ScriptPromiseResolvers
99 // + 1 DOMTimer created in the
95 // above delayToAllowEventProcessingPromise()). 100 // above delayToAllowEventProcessingPromise()).
96 assert_true(numActiveDOMObjectsCreated() >= 5); 101 assert_true(numActiveDOMObjectsCreated() >= 5);
97 102
98 // As we only have a reference (|mediaKeys|) to the last 103 // As we only have a reference (|mediaKeys|) to the last
99 // created MediaKeys object, the other 4 MediaKeys objects 104 // created MediaKeys object, the other 4 MediaKeys objects
100 // are available to be garbage collected. 105 // are available to be garbage collected.
101 // 106 //
102 // Since MediaKeySessions remain alive as long as MediaKeys 107 // Since MediaKeySessions remain alive as long as MediaKeys
103 // is around, it is possible that gc() checks the 108 // is around, it is possible that gc() checks the
104 // MediaKeySession object first, and doesn't collect it 109 // MediaKeySession object first, and doesn't collect it
(...skipping 21 matching lines...) Expand all
126 }).then(function(result) { 131 }).then(function(result) {
127 assert_equals(numActiveDOMObjectsCreated(), 0); 132 assert_equals(numActiveDOMObjectsCreated(), 0);
128 test.done(); 133 test.done();
129 }).catch(function(error) { 134 }).catch(function(error) {
130 forceTestFailureFromPromise(test, error); 135 forceTestFailureFromPromise(test, error);
131 }); 136 });
132 }, 'Multiple MediaKeys lifetime'); 137 }, 'Multiple MediaKeys lifetime');
133 </script> 138 </script>
134 </body> 139 </body>
135 </html> 140 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698