| OLD | NEW |
| (Empty) | |
| 1 <!doctype html> |
| 2 <html> |
| 3 <head> |
| 4 <meta http-equiv="Content-Security-Policy" content="style-src 'nonce-nonceyn
once';"> |
| 5 <script src="/resources/testharness.js"></script> |
| 6 <script src="/resources/testharnessreport.js"></script> |
| 7 |
| 8 <script> |
| 9 var t_spv = async_test("Should fire a securitypolicyviolation event"); |
| 10 |
| 11 document.addEventListener("securitypolicyviolation", t_spv.step_func_done(
function(e) { |
| 12 assert_equals("style-src", e.violatedDirective); |
| 13 })); |
| 14 </script> |
| 15 <style id="style1" nonce="not-nonceynonce" |
| 16 onerror="styleError();"> |
| 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 function verifyStep1() { |
| 29 var marginLeft = getComputedStyle(document.querySelector("#content")
).getPropertyValue('margin-left'); |
| 30 assert_false(marginLeft == '2px', "Content still does not have a 2px
margin-left after initial style."); |
| 31 } |
| 32 |
| 33 function setupStep2() { |
| 34 var sty = document.createElement("style"); |
| 35 sty.nonce = "not-nonceynonce"; |
| 36 sty.innerHTML = "#content { margin-left: 2px; }"; |
| 37 sty.onerror = styleError; |
| 38 document.body.appendChild(sty); |
| 39 } |
| 40 function verifyStep2() { |
| 41 var marginLeft = getComputedStyle(document.querySelector("#content")
).getPropertyValue('margin-left'); |
| 42 assert_false(marginLeft == '2px', "Content still does not have a 2px
margin-left after inserted style."); |
| 43 } |
| 44 |
| 45 function setupStep3() { |
| 46 var e = document.getElementById('style1'); |
| 47 e.innerHTML = "#content { margin-left: 2px; }"; |
| 48 } |
| 49 function verifyStep3() { |
| 50 var marginLeft = getComputedStyle(document.querySelector("#content")
).getPropertyValue('margin-left'); |
| 51 assert_false(marginLeft == '2px', "Content still does not have a 2px
margin-left after changing style."); |
| 52 test.done(); |
| 53 } |
| 54 |
| 55 var verifySteps = [ verifyStep1, verifyStep2, verifyStep3 ]; |
| 56 var setupSteps = [ setupStep2, setupStep3 ]; |
| 57 |
| 58 var test = async_test("Test that paragraph remains unmodified and error
events received."); |
| 59 |
| 60 function styleError() { |
| 61 test.step(function() { |
| 62 verifySteps.shift()(); |
| 63 var nextSetup = setupSteps.shift(); |
| 64 if (nextSetup) |
| 65 nextSetup(); |
| 66 }); |
| 67 } |
| 68 </script> |
| 69 |
| 70 </body> |
| 71 </html> |
| OLD | NEW |