testing/web-platform/tests/content-security-policy/unsafe-hashes/style_attribute_denied_wrong_hash.html
author Chun-Min Chang <chun.m.chang@gmail.com>
Tue, 15 Jul 2025 04:19:58 +0000 (6 hours ago)
changeset 796612 185f590c804be0dc5a6803e176e3a96bfecf686b
parent 435447 2cf2fa1941187e0e7e565fbcb86023e88927ad4c
permissions -rw-r--r--
Bug 1974892 - Fix typo in WMFMediaDataEncoder's log r=media-playback-reviewers,alwu Differential Revision: https://phabricator.services.mozilla.com/D256733
<!DOCTYPE HTML>
<html>

<head>
    <meta http-equiv="Content-Security-Policy" content="img-src *;
                      style-src 'unsafe-hashes' 'sha256-UI8QfroYhb0WX073XBuM+RTPntpjZfkyFLsMw5vQfd0=';">
    <!--
      '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 blocked");

        window.addEventListener('securitypolicyviolation', t1.step_func_done(function(e) {
            assert_equals(e.violatedDirective, 'style-src-attr');
            assert_equals(e.blockedURI, 'inline');
        }));

    </script>
    <img src='../support/pass.png' id='test' style='background: green'>
</body>

</html>