style-src-inline-style-nonce-blocked.html (1083B)
1 <!doctype html> 2 <html> 3 <head> 4 <meta http-equiv="Content-Security-Policy" content="style-src 'self' 'nonce-nonceynonce'"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 8 <script> 9 var t = async_test("Should not load inline style element with invalid nonce"); 10 var t_spv = async_test("Should fire a securitypolicyviolation event"); 11 12 document.addEventListener("securitypolicyviolation", t_spv.step_func_done(function(e) { 13 assert_equals("style-src-elem", e.violatedDirective); 14 })); 15 </script> 16 <style nonce="not-nonceynonce"> 17 #content { 18 margin-left: 2px; 19 } 20 </style> 21 </head> 22 <body> 23 <div id='log'></div> 24 25 <div id="content">Lorem ipsum</div> 26 27 <script> 28 t.step(function() { 29 var contentEl = document.getElementById("content"); 30 var marginLeftVal = getComputedStyle(contentEl).getPropertyValue('margin-left'); 31 assert_not_equals(marginLeftVal, "2px"); 32 t.done(); 33 }); 34 </script> 35 36 </body> 37 </html>