insertRule-syntax-error-01.html (625B)
1 <!DOCTYPE html> 2 <link rel="help" href="https://drafts.csswg.org/cssom-1/#insert-a-css-rule"> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <style> 6 p { color: green; } 7 </style> 8 <p id="test">This text should be green.</p> 9 <script> 10 test(function() { 11 assert_throws_dom("SyntaxError", () => document.styleSheets[0].insertRule("p { color: red; } garbage", 1)); 12 assert_equals(getComputedStyle(document.getElementById("test")).color, "rgb(0, 128, 0)"); 13 }, "A syntax error in insertRule should throw and not affect the style of the page"); 14 </script>