| OLD | NEW |
| (Empty) | |
| 1 <!DOCTYPE HTML> |
| 2 <html> |
| 3 <head> |
| 4 <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsaf
e-inline'; 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("Programatically injected stylesheet should not load"); |
| 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", e.violatedDirective); |
| 14 })); |
| 15 </script> |
| 16 |
| 17 <script> |
| 18 var head = document.getElementsByTagName('head')[0]; |
| 19 var link = document.createElement('link'); |
| 20 link.setAttribute('rel', 'stylesheet'); |
| 21 link.setAttribute('type', 'text/css'); |
| 22 link.setAttribute('href', 'http://{{domains[www1]}}:{{ports[http][0]}}/con
tent-security-policy/style-src/resources/style-src.css'); |
| 23 |
| 24 onload = t.step_func_done(function(e) { |
| 25 var contentEl = document.getElementById("content"); |
| 26 var marginLeftVal = getComputedStyle(contentEl).getPropertyValue('margin
-left'); |
| 27 assert_false(marginLeftVal == "2px"); |
| 28 }); |
| 29 |
| 30 head.appendChild(link); |
| 31 </script> |
| 32 </head> |
| 33 <body> |
| 34 <div id='log'></div> |
| 35 |
| 36 <div id="content">Lorem ipsum</div> |
| 37 |
| 38 </body> |
| 39 </html> |
| OLD | NEW |