OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <title>SVG Style element has error on bad style hash</title> |
| 5 <meta http-equiv="Content-Security-Policy" content="style-src 'sha1-pfeR5wMA
6np45oqDTP6Pj3tLpJo='"> |
| 6 <script src="/resources/testharness.js"></script> |
| 7 <script src="/resources/testharnessreport.js"></script> |
| 8 <script> |
| 9 function verifyStep1() { |
| 10 var color = window.getComputedStyle(document.querySelector('p')).col
or; |
| 11 assert_equals(color, "rgb(0, 128, 0)", "The color of the paragraph i
s still green after initial svg style."); |
| 12 } |
| 13 |
| 14 function setupStep2() { |
| 15 var e = document.getElementById("svgelement"); |
| 16 var sty = document.createElementNS("http://www.w3.org/2000/svg", "st
yle"); |
| 17 sty.innerHTML = "p { color: red; }"; |
| 18 sty.onerror = styleError; |
| 19 e.appendChild(sty); |
| 20 } |
| 21 function verifyStep2() { |
| 22 var color = window.getComputedStyle(document.querySelector('p')).col
or; |
| 23 assert_equals(color, "rgb(0, 128, 0)", "The color of the paragraph i
s still green after inserted svg style."); |
| 24 } |
| 25 |
| 26 function setupStep3() { |
| 27 var e = document.getElementById('style1'); |
| 28 e.innerHTML = "p { color: blue; }"; |
| 29 } |
| 30 function verifyStep3() { |
| 31 var color = window.getComputedStyle(document.querySelector('p')).col
or; |
| 32 assert_equals(color, "rgb(0, 128, 0)", "The color of the paragraph i
s still green after changing svg style."); |
| 33 test.done(); |
| 34 } |
| 35 |
| 36 var verifySteps = [ verifyStep1, verifyStep2, verifyStep3 ]; |
| 37 var setupSteps = [ setupStep2, setupStep3 ]; |
| 38 |
| 39 var test = async_test("Test that paragraph remains green and error event
s received."); |
| 40 |
| 41 function styleError() { |
| 42 test.step(function() { |
| 43 verifySteps.shift()(); |
| 44 var nextSetup = setupSteps.shift(); |
| 45 if (nextSetup) |
| 46 nextSetup(); |
| 47 }); |
| 48 } |
| 49 </script> |
| 50 </head> |
| 51 <body> |
| 52 <svg id="svgelement" xmlns="http://www.w3.org/2000/svg" width="800" height="
100"> |
| 53 <style>p { color: green; }</style> |
| 54 <style id="style1" onerror="styleError();">p { color: red; }</style> |
| 55 <p>A test paragraph</p> |
| 56 </svg> |
| 57 </body> |
| 58 </html> |
OLD | NEW |