summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/encrypted-media/Google/migrated_to_root_disabled/encrypted-media-session-closed-event.html
blob: 577047a251d369f41b94829f8bfd8d1fc9d4606f (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
<!DOCTYPE html>
<!-- Copyright © 2016 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). -->
<html>
    <head>
        <title>Test MediaKeySession closed event</title>
        <script src="encrypted-media-utils.js"></script>
<!--
        Test has been migrated to the root directory and is being disabled here.
        <script src="/resources/testharness.js"></script>
        <script src="/resources/testharnessreport.js"></script>
-->
    </head>
    <body>
        <div id="log"></div>
        <script>
            async_test(function(test)
            {
                var initDataType;
                var initData;
                var mediaKeySession;

                navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration()).then(function(access) {
                    initDataType = access.getConfiguration().initDataTypes[0];
                    initData = getInitData(initDataType);
                    return access.createMediaKeys();
                }).then(function(mediaKeys) {
                    mediaKeySession = mediaKeys.createSession();
                    return mediaKeySession.generateRequest(initDataType, initData);
                }).then(function() {
                    // Wait for the session to be closed.
                    mediaKeySession.closed.then(function(result) {
                        assert_equals(result, undefined);
                        // Now that the session is closed, verify that the
                        // closed attribute immediately returns a fulfilled
                        // promise.
                        return mediaKeySession.closed;
                    }).then(function(result) {
                        assert_equals(result, undefined);
                        test.done();
                    });

                    // release() should result in the closed promise being
                    // fulfilled.
                    return mediaKeySession.close();
                }).catch(function(error) {
                    forceTestFailureFromPromise(test, error);
                });
            }, 'Test MediaKeySession closed event.');
        </script>
    </body>
</html>