tor-browser

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

script-src-1_4_2.html (1043B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4    <title>Function() called as a constructor should throw 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>Function() called as a constructor should throw 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 
     21        test(function() {
     22            assert_throws_js(
     23                EvalError,
     24                function() {
     25                    var funq = new Function('');
     26                    funq();
     27        })}, "Unsafe eval ran in Function() constructor.");
     28 
     29    </script>
     30 </body>
     31 </html>