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