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