| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>Test MediaKeys lifetime</title> | 4 <title>Test MediaKeys lifetime</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> |
| 11 <script> | 11 <script> |
| 12 async_test(function(test) | 12 async_test(function(test) |
| 13 { | 13 { |
| 14 // Create a MediaKeys object and free immediately. | 14 // Create a MediaKeys object and free immediately. |
| 15 navigator.requestMediaKeySystemAccess('org.w3.clearkey', [{}]).t
hen(function(access) { | 15 getSupportedInitDataType().then(function(initDataType) { |
| 16 return requestClearKeySystemAccessForInitType(initDataType); |
| 17 }).then(function(access) { |
| 16 return access.createMediaKeys(); | 18 return access.createMediaKeys(); |
| 17 }).then(function(result) { | 19 }).then(function(result) { |
| 18 // Do nothing with the created object | 20 // Do nothing with the created object |
| 19 }).then(function(result) { | 21 }).then(function(result) { |
| 20 // No way to verify that MediaKeys object is actually | 22 // No way to verify that MediaKeys object is actually |
| 21 // collected, but make sure it doesn't crash. | 23 // collected, but make sure it doesn't crash. |
| 22 return createGCPromise(); | 24 return createGCPromise(); |
| 23 }).then(function(result) { | 25 }).then(function(result) { |
| 24 test.done(); | 26 test.done(); |
| 25 }).catch(function(error) { | 27 }).catch(function(error) { |
| 26 forceTestFailureFromPromise(test, error); | 28 forceTestFailureFromPromise(test, error); |
| 27 }); | 29 }); |
| 28 }, 'Creating and destroying MediaKeys does not crash'); | 30 }, 'Creating and destroying MediaKeys does not crash'); |
| 29 | 31 |
| 30 async_test(function(test) | 32 async_test(function(test) |
| 31 { | 33 { |
| 32 var mediaKeys; | 34 var mediaKeys; |
| 33 navigator.requestMediaKeySystemAccess('org.w3.clearkey', [{}]).t
hen(function(access) { | 35 getSupportedInitDataType().then(function(initDataType) { |
| 36 return requestClearKeySystemAccessForInitType(initDataType); |
| 37 }).then(function(access) { |
| 34 return access.createMediaKeys(); | 38 return access.createMediaKeys(); |
| 35 }).then(function(result) { | 39 }).then(function(result) { |
| 36 mediaKeys = result; | 40 mediaKeys = result; |
| 37 return createGCPromise(); | 41 return createGCPromise(); |
| 38 }).then(function(result) { | 42 }).then(function(result) { |
| 39 // Check that the object still exists. | 43 // Check that the object still exists. |
| 40 assert_equals(typeof mediaKeys.createSession, 'function'); | 44 assert_equals(typeof mediaKeys.createSession, 'function'); |
| 41 mediaKeys = null; | 45 mediaKeys = null; |
| 42 | 46 |
| 43 // Now that the reference is dropped, it should be | 47 // Now that the reference is dropped, it should be |
| 44 // collected. No way to verify that it is actually | 48 // collected. No way to verify that it is actually |
| 45 // collected, but make sure it doesn't crash. | 49 // collected, but make sure it doesn't crash. |
| 46 return createGCPromise(); | 50 return createGCPromise(); |
| 47 }).then(function(result) { | 51 }).then(function(result) { |
| 48 test.done(); | 52 test.done(); |
| 49 }).catch(function(error) { | 53 }).catch(function(error) { |
| 50 forceTestFailureFromPromise(test, error); | 54 forceTestFailureFromPromise(test, error); |
| 51 }); | 55 }); |
| 52 }, 'MediaKeys is not collected as long as we have a reference'); | 56 }, 'MediaKeys is not collected as long as we have a reference'); |
| 53 </script> | 57 </script> |
| 54 </body> | 58 </body> |
| 55 </html> | 59 </html> |
| OLD | NEW |