tor-browser

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

test_bug657143.html (3980B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=657143
      5 -->
      6 <head>
      7  <title>Test for Bug 657143</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     10 </head>
     11 <body>
     12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=657143">Mozilla Bug 657143</a>
     13 <p id="display"></p>
     14 <style>
     15 /* Ensure that there is at least one custom property on the root element's
     16   computed style */
     17 :root { --test: some value; }
     18 </style>
     19 <div id="content" style="display: none">
     20 
     21 </div>
     22 <pre id="test">
     23 <script class="testbody" type="text/javascript">
     24 
     25 /** Test for Bug 657143 */
     26 
     27 // Check ordering of CSS properties in nsComputedDOMStylePropertyList.h
     28 // by splitting the getComputedStyle() into five sublists
     29 // then cloning and sort()ing the lists and comparing with originals.
     30 
     31 function isMozPrefixed(aProp) {
     32  return aProp.startsWith("-moz");
     33 }
     34 
     35 function isNotMozPrefixed(aProp) {
     36  return !isMozPrefixed(aProp);
     37 }
     38 
     39 function isWebkitPrefixed(aProp) {
     40  return aProp.startsWith("-webkit");
     41 }
     42 
     43 function isNotWebkitPrefixed(aProp) {
     44  return !isWebkitPrefixed(aProp);
     45 }
     46 
     47 function isCustom(aProp) {
     48  return aProp.startsWith("--");
     49 }
     50 
     51 function isNotCustom(aProp) {
     52  return !isCustom(aProp);
     53 }
     54 
     55 var styleList = window.getComputedStyle(document.documentElement);
     56    cssA = [], mozA = [], webkitA = [], customA = [];
     57 
     58 // Partition the list of property names into four lists:
     59 //
     60 //   cssA: regular properties
     61 //   mozA: '-moz-' prefixed properties
     62 //   customA: '--' prefixed custom properties
     63 
     64 var list = cssA;
     65 for (var i = 0, j = styleList.length; i < j; i++) {
     66  var prop = styleList.item(i);
     67 
     68  switch (list) {
     69    case cssA:
     70      if (isMozPrefixed(prop)) {
     71        list = mozA;
     72      }
     73      // fall through
     74    case mozA:
     75      if (isWebkitPrefixed(prop)) {
     76        list = webkitA;
     77      }
     78      // fall through
     79    case webkitA:
     80      if (isCustom(prop)) {
     81        list = customA;
     82      }
     83      // fall through
     84  }
     85 
     86  list.push(prop);
     87 }
     88 
     89 var cssB = cssA.slice(0).sort(),
     90    mozB = mozA.slice(0).sort(),
     91    webkitB = webkitA.slice(0).sort();
     92 
     93 is(cssA.toString(), cssB.toString(), 'CSS property list should be alphabetical');
     94 is(mozA.toString(), mozB.toString(), 'Experimental -moz- CSS property list should be alphabetical');
     95 is(webkitA.toString(), webkitB.toString(), 'Compatible -webkit- CSS property list should be alphabetical');
     96 
     97 // We don't test that the custom property list is sorted, as the CSSOM
     98 // specification does not yet require it, and we don't return them
     99 // in sorted order.
    100 
    101 ok(!cssA.find(isWebkitPrefixed), 'Compatible -webkit- CSS properties should not be in the mature CSS property list');
    102 ok(!cssA.find(isMozPrefixed), 'Experimental -moz- CSS properties should not be in the mature CSS property list');
    103 ok(!cssA.find(isCustom), 'Custom CSS properties should not be in the mature CSS property list');
    104 ok(!mozA.find(isWebkitPrefixed), 'Compatible -webkit- CSS properties should not be in the experimental -moz- CSS '
    105                                  + 'property list');
    106 ok(!mozA.find(isNotMozPrefixed), 'Experimental -moz- CSS property list should not contain non -moz- prefixed '
    107                                  + 'CSS properties');
    108 ok(!mozA.find(isCustom), 'Custom CSS properties should not be in the experimental -moz- CSS property list');
    109 ok(!webkitA.find(isNotWebkitPrefixed), 'Compatible -webkit- CSS properties should not contain non -webkit- prefixed '
    110                                        + 'CSS properties');
    111 ok(!webkitA.find(isMozPrefixed), 'Experimental -moz- CSS properties should not be in the compatible -webkit- CSS '
    112                                  + 'property list');
    113 ok(!webkitA.find(isCustom), 'Custom CSS properties should not be in the compatible -webkit- CSS property list');
    114 ok(!customA.find(isNotCustom), 'Non-custom CSS properties should not be in the custom property list');
    115 
    116 </script>
    117 </pre>
    118 </body>
    119 </html>