tor-browser

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

style-src-inline-style-nonce-allowed.html (938B)


      1 <!doctype html>
      2 <html>
      3 <head>
      4    <meta http-equiv="Content-Security-Policy" content="style-src 'nonce-nonceynonce';">
      5    <script src="/resources/testharness.js"></script>
      6    <script src="/resources/testharnessreport.js"></script>
      7 
      8    <script>
      9        var t = async_test("Style with correct nonce should load");
     10        document.addEventListener("securitypolicyviolation", t.unreached_func("Should not trigger a security policy violation"));
     11    </script>
     12 
     13    <style nonce="nonceynonce">
     14        #content {
     15            margin-left: 2px;
     16        }
     17    </style>
     18 </head>
     19 <body>
     20    <div id='log'></div>
     21 
     22    <div id="content">Lorem ipsum</div>
     23 
     24    <script>
     25      t.step(function() {
     26        var contentEl = document.getElementById("content");
     27        var marginLeftVal = getComputedStyle(contentEl).getPropertyValue('margin-left');
     28        assert_equals(marginLeftVal, "2px");
     29        t.done();
     30      });
     31    </script>
     32 
     33 </body>
     34 </html>