tor-browser

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

getComputedStyle-property-order.html (1088B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>CSSOM: getComputedStyle property order</title>
      4 <link rel="help" href="https://drafts.csswg.org/cssom/#dom-window-getcomputedstyle">
      5 <link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com">
      6 <meta name="assert" content="This test checks that in a computed style, properties are sorted in lexicographical order." />
      7 <script src=/resources/testharness.js></script>
      8 <script src=/resources/testharnessreport.js></script>
      9 <script>
     10 test(function() {
     11  const properties = [...getComputedStyle(document.documentElement)];
     12  const sorted = properties.slice().sort(function(a,b) {
     13    if (a === b) {
     14      assert_unreached("There shouldn't be repeated properties");
     15      return 0;
     16    }
     17    // Sort vendor-prefixed properties after standard ones
     18    if (a.startsWith("-") != b.startsWith("-")) {
     19      return b.startsWith("-") ? -1 : 1;
     20    }
     21    // Sort with lexicographical order
     22    return a < b ? -1 : 1;
     23  });
     24  assert_array_equals(properties, sorted);
     25 }, "Computed style properties should be sorted lexicographically");
     26 </script>