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

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 // In non-Oilpan, numActiveDOMObjectsCreate() == 1.
63 // In Oilpan, numActiveDOMObjectsCreated() <= 4.
64 // (1 MediaKeysInitializer,
65 // 1 MediaKeySystemAccessInitializer,
66 // 1 ContentDecryptionModuleResultPromise and
67 // 1 MediaKeySession).
68 assert_less_than_equal(numActiveDOMObjectsCreated(), 4);
63 return createMediaKeyWithMediaKeySession(); 69 return createMediaKeyWithMediaKeySession();
64 }).then(function(mediaKeySession) { 70 }).then(function(mediaKeySession) {
65 // Should be 2 MediaKeySessions. 71 // Should be 2 MediaKeySessions.
66 assert_equals(numActiveDOMObjectsCreated(), 2); 72 // In non-Oilpan, numActiveDOMObjectsCreate() == 2.
73 // In Oilpan, numActiveDOMObjectsCreate() <= 8.
74 // (2 MediaKeysInitializer,
75 // 2 MediaKeySystemAccessInitializer,
76 // 2 ContentDecryptionModuleResultPromise and
77 // 2 MediaKeySession).
78 assert_less_than_equal(numActiveDOMObjectsCreated(), 8);
67 return createMediaKeyWithMediaKeySession(); 79 return createMediaKeyWithMediaKeySession();
68 }).then(function(mediaKeySession) { 80 }).then(function(mediaKeySession) {
69 // Should be 3 MediaKeySessions. 81 // Should be 3 MediaKeySessions.
70 assert_equals(numActiveDOMObjectsCreated(), 3); 82 // In non-Oilpan, numActiveDOMObjectsCreate() == 3.
83 // In Oilpan, numActiveDOMObjectsCreate() <= 12.
84 // (3 MediaKeysInitializer,
85 // 3 MediaKeySystemAccessInitializer,
86 // 3 ContentDecryptionModuleResultPromise and
87 // 3 MediaKeySession).
88 assert_less_than_equal(numActiveDOMObjectsCreated(), 12);
71 return createMediaKeyWithMediaKeySession(); 89 return createMediaKeyWithMediaKeySession();
72 }).then(function(mediaKeySession) { 90 }).then(function(mediaKeySession) {
73 // Should be 4 MediaKeySessions. 91 // Should be 4 MediaKeySessions.
74 assert_equals(numActiveDOMObjectsCreated(), 4); 92 // In non-Oilpan, numActiveDOMObjectsCreate() == 4.
93 // In Oilpan, numActiveDOMObjectsCreate() <= 16.
94 // (4 MediaKeysInitializer,
95 // 4 MediaKeySystemAccessInitializer,
96 // 4 ContentDecryptionModuleResultPromise and
97 // 4 MediaKeySession).
98 assert_less_than_equal(numActiveDOMObjectsCreated(), 16);
75 return createMediaKeyWithMediaKeySession(); 99 return createMediaKeyWithMediaKeySession();
76 }).then(function(mediaKeySession) { 100 }).then(function(mediaKeySession) {
77 // Should be 5 MediaKeySessions. 101 // Should be 5 MediaKeySessions.
78 assert_equals(numActiveDOMObjectsCreated(), 5); 102 // In non-Oilpan, numActiveDOMObjectsCreate() == 5.
103 // In Oilpan, numActiveDOMObjectsCreate() <= 20.
104 // (5 MediaKeysInitializer,
105 // 5 MediaKeySystemAccessInitializer,
106 // 5 ContentDecryptionModuleResultPromise and
107 // 5 MediaKeySession).
108 assert_less_than_equal(numActiveDOMObjectsCreated(), 20);
79 109
80 // |mediaKeys| refers to the most recently created MediaKeys 110 // |mediaKeys| refers to the most recently created MediaKeys
81 // object. 111 // object.
82 // 112 //
83 // In order for the MediaKeySession objects to have no 113 // In order for the MediaKeySession objects to have no
84 // outstanding activity so that they can be garbage 114 // outstanding activity so that they can be garbage
85 // collected, it needs time to process any pending events. 115 // collected, it needs time to process any pending events.
86 // As a "message" event is generated when a new session is 116 // As a "message" event is generated when a new session is
87 // created, we need to allow the event to run (we're not 117 // created, we need to allow the event to run (we're not
88 // doing anything with the event in this test). 118 // doing anything with the event in this test).
89 return delayToAllowEventProcessingPromise(); 119 return delayToAllowEventProcessingPromise();
90 }).then(function(result) { 120 }).then(function(result) {
91 // In non-Oilpan, numActiveDOMObjectsCreated() is 5 121 // In non-Oilpan, numActiveDOMObjectsCreated() == 5
92 // (5 MediaKeySession objects). 122 // (5 MediaKeySession objects).
93 // In Oilpan, numActiveDOMObjectsCreated() is 6 123 // In Oilpan, numActiveDOMObjectsCreated() <= 21
94 // (5 MediaKeySession objects + 1 DOMTimer created in the 124 // (5 MediaKeysInitializer,
95 // above delayToAllowEventProcessingPromise()). 125 // 5 MediaKeySystemAccessInitializer,
126 // 5 ContentDecryptionModuleResultPromise,
127 // 5 MediaKeySession, and
128 // 1 DOMTimer (in delayToAllowEventProcessingPromise))
96 assert_true(numActiveDOMObjectsCreated() >= 5); 129 assert_true(numActiveDOMObjectsCreated() >= 5);
130 assert_less_than_equal(numActiveDOMObjectsCreated(), 21);
97 131
98 // As we only have a reference (|mediaKeys|) to the last 132 // As we only have a reference (|mediaKeys|) to the last
99 // created MediaKeys object, the other 4 MediaKeys objects 133 // created MediaKeys object, the other 4 MediaKeys objects
100 // are available to be garbage collected. 134 // are available to be garbage collected.
101 // 135 //
102 // Since MediaKeySessions remain alive as long as MediaKeys 136 // Since MediaKeySessions remain alive as long as MediaKeys
103 // is around, it is possible that gc() checks the 137 // is around, it is possible that gc() checks the
104 // MediaKeySession object first, and doesn't collect it 138 // MediaKeySession object first, and doesn't collect it
105 // since MediaKeys hasn't been collected yet. Thus run gc() 139 // since MediaKeys hasn't been collected yet. Thus run gc()
106 // twice, to ensure that the unreferenced MediaKeySession 140 // twice, to ensure that the unreferenced MediaKeySession
(...skipping 19 matching lines...) Expand all
126 }).then(function(result) { 160 }).then(function(result) {
127 assert_equals(numActiveDOMObjectsCreated(), 0); 161 assert_equals(numActiveDOMObjectsCreated(), 0);
128 test.done(); 162 test.done();
129 }).catch(function(error) { 163 }).catch(function(error) {
130 forceTestFailureFromPromise(test, error); 164 forceTestFailureFromPromise(test, error);
131 }); 165 });
132 }, 'Multiple MediaKeys lifetime'); 166 }, 'Multiple MediaKeys lifetime');
133 </script> 167 </script>
134 </body> 168 </body>
135 </html> 169 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698