summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/content-security-policy/unsafe-hashes/style_attribute_allowed.html
blob: 568c469b063c0faaed83cf9551b56a3bf7d2b3d9 (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
<!DOCTYPE HTML>
<html>

<head>
    <meta http-equiv="Content-Security-Policy" content="img-src *;
                      style-src 'unsafe-hashes' 'sha256-S0VSqEOmzmyOifPfat2sJ7ELOgkldAEbaXlvi5iMqjc=';">
    <!--
      'sha256-S0VSqEOmzmyOifPfat2sJ7ELOgkldAEbaXlvi5iMqjc=' ==> 'background: green'
      -->
    <title>Event handlers should be allowed if a matching hash and 'unsafe-hashes' are present</title>
    <script src='/resources/testharness.js'></script>
    <script src='/resources/testharnessreport.js'></script>
</head>

<body>
    <div id='log'></div>
    <script>
        var t1 = async_test("Test that the inline style attribute is loaded");

        self.check_for_style = t1.step_func_done(function() {
          assert_equals("green", document.getElementById('test').style.background);
        });

        window.addEventListener('securitypolicyviolation', t1.unreached_func("Should have not raised any event"));
    </script>
    <img src='../support/pass.png' id='test' style='background: green'
         onload='check_for_style()'>
</body>

</html>