summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/encrypted-media/Google/chromium_specific_disabled/encrypted-media-lifetime-mediakeys.html
blob: b8e79ac8bbb7e91fd36e4377d33f753a6357cf57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<!DOCTYPE html>
<!-- Copyright © 2016 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). -->
<html>
    <head>
        <title>Test MediaKeys lifetime</title>
        <script src="encrypted-media-utils.js"></script>
<!--
        Test requires Chromium specific content and is being disabled.
        <script src="/resources/testharness.js"></script>
        <script src="/resources/testharnessreport.js"></script>
-->
    </head>
    <body>
        <div id="log"></div>
        <script>
            async_test(function(test)
            {
                // Create a MediaKeys object and free immediately.
                navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration()).then(function(access) {
                    return access.createMediaKeys();
                }).then(function(result) {
                    // Do nothing with the created object
                }).then(function(result) {
                    // No way to verify that MediaKeys object is actually
                    // collected, but make sure it doesn't crash.
                    return createGCPromise();
                }).then(function(result) {
                    test.done();
                }).catch(function(error) {
                    forceTestFailureFromPromise(test, error);
                });
            }, 'Creating and destroying MediaKeys does not crash');

            async_test(function(test)
            {
                var mediaKeys;
                navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration()).then(function(access) {
                    return access.createMediaKeys();
                }).then(function(result) {
                    mediaKeys = result;
                    return createGCPromise();
                }).then(function(result) {
                    // Check that the object still exists.
                    assert_equals(typeof mediaKeys.createSession, 'function');
                    mediaKeys = null;

                    // Now that the reference is dropped, it should be
                    // collected. No way to verify that it is actually
                    // collected, but make sure it doesn't crash.
                    return createGCPromise();
                }).then(function(result) {
                    test.done();
                }).catch(function(error) {
                    forceTestFailureFromPromise(test, error);
                });
            }, 'MediaKeys is not collected as long as we have a reference');
        </script>
    </body>
</html>