summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/content-security-policy/script-src/script-src-strict_dynamic_discard_source_expressions.html
blob: 4edef301092a090ffa65458e7bbd953a09e42528 (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
<!DOCTYPE HTML>
<html>

<head>
    <title>Source expressions are discarded with `strict-dynamic` in the script-src directive.</title>
    <script src='/resources/testharness.js' nonce='dummy'></script>
    <script src='/resources/testharnessreport.js' nonce='dummy'></script>

    <!-- CSP served: script-src 'self' 'strict-dynamic' 'nonce-dummy' -->
</head>

<body>
    <h1>Source expressions are discarded with `strict-dynamic` in the script-src directive.</h1>
    <div id='log'></div>

    <script nonce='dummy'>
        async_test(function(t) {
            window.addEventListener('message', t.step_func(function(e) {
                if (e.data === 'allowedScript') {
                    assert_unreached('Allowed scripts without a correct nonce are not permitted with `strict-dynamic`.');
                }
            }));
            window.addEventListener('securitypolicyviolation', t.step_func_done(function(e) {
                assert_equals(e.effectiveDirective, 'script-src-elem');
            }));
        }, 'Allowed scripts without a correct nonce are not permitted with `strict-dynamic`.');
    </script>
    <script id='allowedScript' src='simpleSourcedScript.js'></script>

</body>

</html>