summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/encrypted-media/Google/migrated_to_root_disabled/encrypted-media-update-disallowed-input.html
blob: e829a885c65b66eb703de45a7bc08ad88a1ca42b (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE html>
<!-- Copyright © 2016 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). -->
<html>
    <head>
        <title>Test handling of invalid responses for update().</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>
            // This test passes |response| to update() as a JSON Web Key Set.
            // CDMs other than Clear Key won't expect |response| in this format.

            async_test(function(test)
            {
                var initDataType;
                var initData;
                var mediaKeySession;

                function repeat(pattern, count) {
                    var result = '';
                    while (count > 1) {
                        if (count & 1) result += pattern;
                        count >>= 1;
                        pattern += pattern;
                    }
                    return result + pattern;
                }

                function createReallyLongJWKSet()
                {
                    // This is just a standard JWKSet with a lot of
                    // extra items added to the end. Key ID and key
                    // doesn't really matter.
                    var jwkSet = '{"keys":[{'
                               +     '"kty":"oct",'
                               +     '"k":"MDEyMzQ1Njc4OTAxMjM0NQ",'
                               +     '"kid":"MDEyMzQ1Njc4OTAxMjM0NQ"'
                               + '}]';
                    return jwkSet + repeat(',"test":"unknown"', 4000) + '}';
                }

                function processMessage(event)
                {
                    var jwkSet = createReallyLongJWKSet();
                    assert_greater_than(jwkSet.length, 65536);
                    var jwkSetArray = stringToUint8Array(jwkSet);
                    mediaKeySession.update(jwkSetArray).then(function() {
                        forceTestFailureFromPromise(test, 'Error: update() succeeded');
                    }, function(error) {
                        assert_equals(error.name, 'InvalidAccessError');
                        test.done();
                    });
                }

                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();
                    waitForEventAndRunStep('message', mediaKeySession, processMessage, test);
                    return mediaKeySession.generateRequest(initDataType, initData);
                });
            }, 'update() with response longer than 64Kb characters.');
        </script>
    </body>
</html>