tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

script-src-1_4.html (1003B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4    <title>eval() should not run without 'unsafe-eval' script-src directive.</title>
      5    <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';">
      6    <script src='/resources/testharness.js'></script>
      7    <script src='/resources/testharnessreport.js'></script>
      8 </head>
      9 <body>
     10    <h1>eval() should not run without 'unsafe-eval' script-src directive.</h1>
     11    <div id='log'></div>
     12 
     13   	<script>
     14        var t_spv = async_test("Test that securitypolicyviolation event is fired");
     15 
     16        window.addEventListener("securitypolicyviolation", t_spv.step_func_done(function(e) {
     17            assert_equals(e.violatedDirective, "script-src");
     18        }));
     19 
     20        var evalRan = false;
     21 
     22        test(function() {assert_throws_js(EvalError, function() { eval('evalRan = true;') })}, "eval() should throw without 'unsafe-eval' keyword source in script-src directive.");
     23 
     24        test(function() {assert_false(evalRan);})
     25 
     26    </script>
     27 </body>
     28 </html>