4 <title>Test MediaKeys lifetime
</title>
5 <script src=
"encrypted-media-utils.js"></script>
6 <script src=
"../../resources/testharness.js"></script>
7 <script src=
"../../resources/testharnessreport.js"></script>
12 async_test(function(test
)
14 // Create a MediaKeys object and free immediately.
15 navigator
.requestMediaKeySystemAccess('org.w3.clearkey', [{}]).then(function(access
) {
16 return access
.createMediaKeys();
17 }).then(function(result
) {
18 // Do nothing with the created object
19 }).then(function(result
) {
20 // No way to verify that MediaKeys object is actually
21 // collected, but make sure it doesn't crash.
22 return createGCPromise();
23 }).then(function(result
) {
25 }).catch(function(error
) {
26 forceTestFailureFromPromise(test
, error
);
28 }, 'Creating and destroying MediaKeys does not crash');
30 async_test(function(test
)
33 navigator
.requestMediaKeySystemAccess('org.w3.clearkey', [{}]).then(function(access
) {
34 return access
.createMediaKeys();
35 }).then(function(result
) {
37 return createGCPromise();
38 }).then(function(result
) {
39 // Check that the object still exists.
40 assert_equals(typeof mediaKeys
.createSession
, 'function');
43 // Now that the reference is dropped, it should be
44 // collected. No way to verify that it is actually
45 // collected, but make sure it doesn't crash.
46 return createGCPromise();
47 }).then(function(result
) {
49 }).catch(function(error
) {
50 forceTestFailureFromPromise(test
, error
);
52 }, 'MediaKeys is not collected as long as we have a reference');