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> |
11 <script> | 11 <script> |
12 // For this test, create several MediaKeys and verify lifetime. | 12 // For this test, create several MediaKeys and verify lifetime. |
13 async_test(function(test) | 13 async_test(function(test) |
14 { | 14 { |
15 var mediaKeys; | 15 var mediaKeys; |
16 var startingActiveDOMObjectCount = window.internals.activeDOMObj
ectCount(document); | 16 var startingActiveDOMObjectCount = window.internals.activeDOMObj
ectCount(document); |
17 | 17 |
18 function numActiveDOMObjectsCreated() | 18 function numActiveDOMObjectsCreated() |
19 { | 19 { |
20 return window.internals.activeDOMObjectCount(document) - sta
rtingActiveDOMObjectCount; | 20 return window.internals.activeDOMObjectCount(document) - sta
rtingActiveDOMObjectCount; |
21 } | 21 } |
22 | 22 |
23 // Create a MediaKeys object. Returns a promise that resolves | 23 // Create a MediaKeys object. Returns a promise that resolves |
24 // with the new MediaKeys object. | 24 // with the new MediaKeys object. |
25 function createMediaKeys() | 25 function createMediaKeys() |
26 { | 26 { |
27 return getSupportedInitDataType().then(function(type) { | 27 return navigator.requestMediaKeySystemAccess('org.w3.clearke
y', getSimpleConfiguration()).then(function(access) { |
28 return navigator.requestMediaKeySystemAccess('org.w3.cle
arkey', [{}]); | |
29 }).then(function(access) { | |
30 return access.createMediaKeys(); | 28 return access.createMediaKeys(); |
31 }).then(function(mediaKeys) { | 29 }).then(function(mediaKeys) { |
32 return mediaKeys; | 30 return mediaKeys; |
33 }); | 31 }); |
34 } | 32 } |
35 | 33 |
36 // Create a few MediaKeys objects. Only keep a reference to the | 34 // Create a few MediaKeys objects. Only keep a reference to the |
37 // last one created. | 35 // last one created. |
38 createMediaKeys().then(function(result) { | 36 createMediaKeys().then(function(result) { |
39 // Should be 1 MediaKeys. | 37 // Should be 1 MediaKeys. |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 // Should be just a DOMTimer. | 118 // Should be just a DOMTimer. |
121 assert_less_than_equal(numActiveDOMObjectsCreated(), 1); | 119 assert_less_than_equal(numActiveDOMObjectsCreated(), 1); |
122 test.done(); | 120 test.done(); |
123 }).catch(function(error) { | 121 }).catch(function(error) { |
124 forceTestFailureFromPromise(test, error); | 122 forceTestFailureFromPromise(test, error); |
125 }); | 123 }); |
126 }, 'Multiple MediaKeys lifetime'); | 124 }, 'Multiple MediaKeys lifetime'); |
127 </script> | 125 </script> |
128 </body> | 126 </body> |
129 </html> | 127 </html> |
OLD | NEW |