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