| 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 10 matching lines...) Expand all Loading... |
| 21 // In the tests below, we do not close any session nor keep a | 21 // In the tests below, we do not close any session nor keep a |
| 22 // Javascript reference to any session, so MediaKeySessions remain | 22 // Javascript reference to any session, so MediaKeySessions remain |
| 23 // as long as the associated MediaKeys object is around. | 23 // as long as the associated MediaKeys object is around. |
| 24 | 24 |
| 25 // For this test, create several MediaKeys (each with a | 25 // For this test, create several MediaKeys (each with a |
| 26 // MediaKeySession object so they can be counted) and verify | 26 // MediaKeySession object so they can be counted) and verify |
| 27 // lifetime. | 27 // lifetime. |
| 28 async_test(function(test) | 28 async_test(function(test) |
| 29 { | 29 { |
| 30 var mediaKeys; | 30 var mediaKeys; |
| 31 var initDataType = getInitDataType(); | |
| 32 var initData = getInitData(initDataType); | |
| 33 | |
| 34 var startingActiveDOMObjectCount = window.internals.activeDOMObj
ectCount(document); | 31 var startingActiveDOMObjectCount = window.internals.activeDOMObj
ectCount(document); |
| 35 | 32 |
| 36 function numActiveDOMObjectsCreated() | 33 function numActiveDOMObjectsCreated() |
| 37 { | 34 { |
| 38 return window.internals.activeDOMObjectCount(document) - sta
rtingActiveDOMObjectCount; | 35 return window.internals.activeDOMObjectCount(document) - sta
rtingActiveDOMObjectCount; |
| 39 } | 36 } |
| 40 | 37 |
| 41 // Create a MediaKeys object and an associated MediaKeySession | 38 // Create a MediaKeys object and an associated MediaKeySession |
| 42 // object. |mediaKeys| is updated to refer to the new MediaKeys | 39 // object. |mediaKeys| is updated to refer to the new MediaKeys |
| 43 // object. Returns a promise that resolves with the new | 40 // object. Returns a promise that resolves with the new |
| 44 // MediaKeySession object. | 41 // MediaKeySession object. |
| 45 function createMediaKeyWithMediaKeySession() | 42 function createMediaKeyWithMediaKeySession() |
| 46 { | 43 { |
| 47 return navigator.requestMediaKeySystemAccess('org.w3.clearke
y', [{}]).then(function(access) { | 44 var initDataType; |
| 45 var initData; |
| 46 |
| 47 return getSupportedInitDataType().then(function(type) { |
| 48 initDataType = type; |
| 49 initData = getInitData(initDataType); |
| 50 return navigator.requestMediaKeySystemAccess('org.w3.cle
arkey', [{}]); |
| 51 }).then(function(access) { |
| 48 return access.createMediaKeys(); | 52 return access.createMediaKeys(); |
| 49 }).then(function(result) { | 53 }).then(function(result) { |
| 50 mediaKeys = result; | 54 mediaKeys = result; |
| 51 var mediaKeySession = mediaKeys.createSession(); | 55 var mediaKeySession = mediaKeys.createSession(); |
| 52 return mediaKeySession.generateRequest(initDataType, ini
tData).then(function() { | 56 return mediaKeySession.generateRequest(initDataType, ini
tData).then(function() { |
| 53 return mediaKeySession; | 57 return mediaKeySession; |
| 54 }); | 58 }); |
| 55 }); | 59 }); |
| 56 } | 60 } |
| 57 | 61 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 }).then(function(result) { | 165 }).then(function(result) { |
| 162 assert_less_than_equal(numActiveDOMObjectsCreated(), 1); | 166 assert_less_than_equal(numActiveDOMObjectsCreated(), 1); |
| 163 test.done(); | 167 test.done(); |
| 164 }).catch(function(error) { | 168 }).catch(function(error) { |
| 165 forceTestFailureFromPromise(test, error); | 169 forceTestFailureFromPromise(test, error); |
| 166 }); | 170 }); |
| 167 }, 'Multiple MediaKeys lifetime'); | 171 }, 'Multiple MediaKeys lifetime'); |
| 168 </script> | 172 </script> |
| 169 </body> | 173 </body> |
| 170 </html> | 174 </html> |
| OLD | NEW |