tor-browser

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

style-src-injected-stylesheet-allowed.sub.html (1270B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4    <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline'; style-src http://{{domains[www1]}}:{{ports[http][0]}};">
      5    <script src='/resources/testharness.js'></script>
      6    <script src='/resources/testharnessreport.js'></script>
      7 
      8    <script>
      9      var t = async_test("Programatically injected stylesheet should load");
     10      document.addEventListener("securitypolicyviolation", t.unreached_func("Should not trigger a security policy violation"));
     11    </script>
     12 
     13    <script>
     14      var head = document.getElementsByTagName('head')[0];
     15      var link = document.createElement('link');
     16      link.setAttribute('rel', 'stylesheet');
     17      link.setAttribute('type', 'text/css');
     18      link.setAttribute('href', 'http://{{domains[www1]}}:{{ports[http][0]}}/content-security-policy/style-src/resources/style-src.css');
     19 
     20      onload = t.step_func_done(function(e) {
     21        var contentEl = document.getElementById("content");
     22        var marginLeftVal = getComputedStyle(contentEl).getPropertyValue('margin-left');
     23        assert_equals(marginLeftVal, "2px");
     24      });
     25 
     26      head.appendChild(link);
     27    </script>
     28 </head>
     29 <body>
     30    <div id='log'></div>
     31 
     32    <div id="content">Lorem ipsum</div>
     33 
     34 </body>
     35 </html>