Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 3 subtest issues.
 - This WPT test may be referenced by the following Test IDs:
            
- /content-security-policy/unsafe-eval/tentative/eval-hashes-override-unsafe-eval.sub.html - WPT Dashboard Interop Dashboard
 
 
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline' 'eval-sha256-wrhs7MZ7Cmwwzxiy9buBGGkLT/3SLW3Sp8UrVRoaaaa=' 'unsafe-eval'; connect-src 'self';">
    <title>eval-blocked</title>
    <script src="/resources/testharness.js"></script>
    <script src="/resources/testharnessreport.js"></script>
    <script src='../../support/logTest.sub.js?logs=["PASS EvalError","PASS EvalError", "violated-directive=script-src"]'></script>
    <script src="../../support/alertAssert.sub.js?alerts=[]"></script>
</head>
<body>
    <script>
        window.addEventListener('securitypolicyviolation', function(e) {
            log("violated-directive=" + e.violatedDirective);
        });
        try {
            eval("alert_assert('FAIL (1 of 2)')");
        } catch (e) {
            log("PASS EvalError");
        }
        try {
            window.eval("alert_assert('FAIL (1 of 2)')");
        } catch (e) {
            log("PASS EvalError");
        }
    </script>
    <div id="log"></div>
</body>
</html>