| Cameron McCormack | 70a385f | 2017-05-05 16:45:31 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <meta charset="utf-8"> |
| 3 | <title>Tests for handling of CSS Custom Property names</title> |
| 4 | <meta name="author" title="Cameron McCormack" href="mailto:cam@mcc.id.au"> |
| 5 | <script src="/resources/testharness.js"></script> |
| 6 | <script src="/resources/testharnessreport.js"></script> |
| 7 | <div id="log"></div> |
| 8 | <script> |
| 9 | |
| 10 | // Valid custom property names, before and after CSS escaping. |
| 11 | var valid_names = [ |
| 12 | ["--a", "--a"], |
| 13 | ["--a;b", "--a\\;b"], |
| 14 | ["---", "---"], |
| 15 | ["--\\", "--\\\\"], |
| 16 | ["--ab", "--\\61 b"], |
| 17 | ["--0", "--\\30 "], |
| 18 | ]; |
| 19 | |
| 20 | valid_names.forEach(function(t) { |
| 21 | var name = t[0]; |
| 22 | var escaped_name = t[1]; |
| 23 | |
| 24 | test(function() { |
| 25 | var e = document.createElement("span"); |
| 26 | e.style = escaped_name + ":value"; |
| 27 | |
| 28 | for (var after_refeeding = 0; after_refeeding <= 1; ++after_refeeding) { |
| 29 | var desc_suffix = (after_refeeding ? " (after " : " (before ") + |
| 30 | "serialization/re-parsing)"; |
| 31 | |
| 32 | assert_equals(e.style.length, 1, |
| 33 | "appears on specified style" + desc_suffix); |
| 34 | |
| 35 | assert_equals(e.style[0], name, |
| 36 | "name returned correctly from specified " + |
| 37 | "style indexed getter" + desc_suffix); |
| 38 | |
| 39 | assert_equals(e.style.getPropertyValue(name), "value", |
| 40 | "property value returned correctly from " + |
| 41 | "specified style getPropertyValue" + desc_suffix); |
| 42 | |
| 43 | e.style = e.style.cssText; |
| 44 | } |
| 45 | }, "custom property '" + name + "'"); |
| 46 | }); |
| 47 | </script> |