tor-browser

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

script-src-1_10.html (1231B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4    <title>data: as script src should not run with a policy that doesn't specify data: as an allowed source</title>
      5    <meta http-equiv="Content-Security-Policy" content="default-src 'self' 'unsafe-inline';">
      6    <script src='/resources/testharness.js'></script>
      7    <script src='/resources/testharnessreport.js'></script>
      8 </head>
      9 <body>
     10    <h1>data: as script src should not run with a policy that doesn't specify data: as an allowed source</h1>
     11    <div id='log'></div>
     12 
     13    <script>
     14        var dataScriptRan = false;
     15        var t_spv = async_test("Test that securitypolicyviolation event is fired");
     16 
     17        window.addEventListener("securitypolicyviolation", t_spv.step_func_done(function(e) {
     18            assert_equals(e.violatedDirective, "script-src-elem");
     19        }));
     20    </script>
     21 
     22    <!-- This is our test case, but we don't expect it to actually execute if CSP is working. -->
     23    <script src="data:text/javascript;charset=utf-8;base64,ZGF0YVNjcmlwdFJhbiA9IHRydWU7"></script>
     24 
     25    <script>
     26        test(function () {
     27            assert_false(dataScriptRan, "data script ran");
     28        }, "Verify that data: as script src doesn't run with this policy");
     29    </script>
     30 </body>
     31 </html>