style-src-imported-style-blocked.html (1242B)
1 <!doctype html> 2 <html> 3 <head> 4 <meta http-equiv="Content-Security-Policy" content="style-src 'self';"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 8 <script> 9 var t = async_test("@import stylesheet should not load because it does not match style-src"); 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 16 var l = document.createElement("link"); 17 l.setAttribute("href", "/content-security-policy/style-src/resources/style-src-import.sub.css"); 18 l.setAttribute("rel", "stylesheet"); 19 l.setAttribute("type", "text/css"); 20 document.head.appendChild(l); 21 </script> 22 </head> 23 <body> 24 <div id='log'></div> 25 26 <div id="content">Lorem ipsum</div> 27 28 <script> 29 t.step(function() { 30 var contentEl = document.getElementById("content"); 31 var marginLeftVal = getComputedStyle(contentEl).getPropertyValue('margin-left'); 32 assert_not_equals(marginLeftVal, "2px"); 33 t.done(); 34 }); 35 </script> 36 37 </body> 38 </html>