tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

variable-names.html (1563B)


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