summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/encrypted-media/Google/migrated_to_root_disabled/encrypted-media-setmediakeys.html
blob: 96b0fed974fe3960bd4d3a581f660f6a73b6afce (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>setMediaKeys</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>
        <video id="video"></video>
        <div id="log"></div>
        <script>
            async_test(function(test)
            {
                var mediaKeys;
                var video = document.getElementById('video');
                assert_not_equals(video, null);

                // Test MediaKeys assignment.
                assert_equals(video.mediaKeys, null);
                assert_equals(typeof video.setMediaKeys, 'function');

                // Try setting mediaKeys to null.
                video.setMediaKeys(null).then(function(result) {
                    assert_equals(video.mediaKeys, null);

                    // Try setting mediaKeys to the wrong type of object.
                    return video.setMediaKeys(new Date());
                }).then(function(result) {
                    assert_unreached('setMediaKeys did not fail when setting to Date()');
                }, function(error) {
                    // TypeError expected.
                    assert_equals(error.name, 'TypeError');

                    // Create a MediaKeys object and assign it to video.
                    return navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration());
                }).then(function(access) {
                    assert_equals(access.keySystem, 'org.w3.clearkey');
                    return access.createMediaKeys();
                }).then(function(result) {
                    mediaKeys = result;
                    assert_not_equals(mediaKeys, null);
                    assert_equals(typeof mediaKeys.createSession, 'function');
                    return video.setMediaKeys(mediaKeys);
                }).then(function(result) {
                    assert_not_equals(video.mediaKeys, null);
                    assert_true(video.mediaKeys === mediaKeys);
                    test.done();
                }).catch(function(error) {
                    forceTestFailureFromPromise(test, error);
                });
            }, 'Setting MediaKeys on a video object.');
        </script>
    </body>
</html>