OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <style> |
| 3 #test { |
| 4 --important:green!important; |
| 5 --not-important:red; |
| 6 color:var(--important); |
| 7 } |
| 8 #test2 { |
| 9 --variable:value; |
| 10 } |
| 11 </style> |
| 12 <div id="test"></div> |
| 13 <script src="../../../resources/js-test.js"></script> |
| 14 <script> |
| 15 var style = document.styleSheets[0].rules[0].style; |
| 16 shouldBeEqualToString('style.getPropertyValue("--important")', "green"); |
| 17 shouldBeEqualToString('style.getPropertyValue("--not-important")', "red"); |
| 18 shouldBeEqualToString('style.getPropertyValue("color")', "var(--important)"); |
| 19 shouldBeEqualToString('style.getPropertyPriority("--important")', "important"); |
| 20 shouldBeEqualToString('style.getPropertyPriority("--not-important")', ""); |
| 21 style.setProperty("--foo", "papayawhip"); |
| 22 style.setProperty("--important-foo", "navajowhite", "important"); |
| 23 shouldBeEqualToString('style.getPropertyValue("--foo")', "papayawhip"); |
| 24 shouldBeEqualToString('style.getPropertyPriority("--foo")', ""); |
| 25 shouldBeEqualToString('style.getPropertyPriority("--important-foo")', "important
"); |
| 26 style.setProperty("--important-foo", "") |
| 27 shouldBeEqualToString('style.getPropertyValue("--important-foo")', ""); |
| 28 shouldBeEqualToString('style.removeProperty("--foo")', "papayawhip"); |
| 29 shouldBeEqualToString('style.getPropertyValue("--foo")', ""); |
| 30 |
| 31 var computedStyle = window.getComputedStyle(document.getElementById("test")); |
| 32 shouldThrow('computedStyle.setProperty("--error", "")', |
| 33 '"NoModificationAllowedError: Failed to execute \'setProperty\' on \'CSSStyl
eDeclaration\': These styles are computed, and therefore the \'--error\' propert
y is read-only."'); |
| 34 |
| 35 var cssText = document.styleSheets[0].rules[1].cssText; |
| 36 shouldBeEqualToString('cssText', '#test2 { --variable: value; }') |
| 37 </script> |
OLD | NEW |