tor-browser

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

test_property_database.html (5991B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 -->
      5 <head>
      6  <title>Test that property_database.js contains all supported CSS properties</title>
      7  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      8  <script type="text/javascript" src="css_properties.js"></script>
      9  <script type="text/javascript" src="property_database.js"></script>
     10  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     11 </head>
     12 <body>
     13 <p id="display"></p>
     14 <div id="content" style="display: none">
     15 
     16 <div id="testnode"></div>
     17 
     18 </div>
     19 <pre id="test">
     20 <script class="testbody" type="text/javascript">
     21 
     22 /** Test that property_database.js contains all supported CSS properties */
     23 
     24 /*
     25 * Here we are testing the hand-written property_database.js against
     26 * the autogenerated css_properties.js to make sure that everything in
     27 * css_properties.js is in property_database.js.
     28 *
     29 * This prevents CSS properties from being added to the code without
     30 * also being put under the minimal test coverage provided by the tests
     31 * that use property_database.js.
     32 */
     33 
     34 for (var idx in gLonghandProperties) {
     35  var prop = gLonghandProperties[idx];
     36  if (prop.pref && !IsCSSPropertyPrefEnabled(prop.pref)) {
     37    continue;
     38  }
     39  var present = prop.name in gCSSProperties;
     40  ok(present,
     41     "'" + prop.name + "' listed in gCSSProperties");
     42  if (present) {
     43    is(gCSSProperties[prop.name].type, CSS_TYPE_LONGHAND,
     44       "'" + prop.name + "' listed as CSS_TYPE_LONGHAND");
     45    is(gCSSProperties[prop.name].domProp, prop.prop,
     46       "'" + prop.name + "' listed with correct DOM property name");
     47  }
     48 }
     49 for (var idx in gShorthandProperties) {
     50  var prop = gShorthandProperties[idx];
     51  if (prop.pref && !IsCSSPropertyPrefEnabled(prop.pref)) {
     52    continue;
     53  }
     54  if (prop.name == "all") {
     55    // "all" isn't listed in property_database.js.
     56    continue;
     57  }
     58  var present = prop.name in gCSSProperties;
     59  ok(present,
     60     "'" + prop.name + "' listed in gCSSProperties");
     61  if (present) {
     62    ok(gCSSProperties[prop.name].type == CSS_TYPE_TRUE_SHORTHAND ||
     63       gCSSProperties[prop.name].type == CSS_TYPE_LEGACY_SHORTHAND ||
     64       gCSSProperties[prop.name].type == CSS_TYPE_SHORTHAND_AND_LONGHAND,
     65       "'" + prop.name + "' listed as CSS_TYPE_TRUE_SHORTHAND, CSS_TYPE_LEGACY_SHORTHAND, or CSS_TYPE_SHORTHAND_AND_LONGHAND");
     66    ok(gCSSProperties[prop.name].domProp == prop.prop,
     67       "'" + prop.name + "' listed with correct DOM property name");
     68  }
     69 }
     70 for (var idx in gShorthandPropertiesLikeLonghand) {
     71  var prop = gShorthandPropertiesLikeLonghand[idx];
     72  if (prop.pref && !IsCSSPropertyPrefEnabled(prop.pref)) {
     73    continue;
     74  }
     75  var present = prop.name in gCSSProperties;
     76  ok(present,
     77     "'" + prop.name + "' listed in gCSSProperties");
     78  if (present) {
     79    ok(gCSSProperties[prop.name].type == CSS_TYPE_SHORTHAND_AND_LONGHAND,
     80       "'" + prop.name + "' listed as CSS_TYPE_SHORTHAND_AND_LONGHAND");
     81    ok(gCSSProperties[prop.name].domProp == prop.prop,
     82       "'" + prop.name + "' listed with correct DOM property name");
     83  }
     84 }
     85 
     86 /*
     87 * Test that all shorthand properties have a subproperty list and all
     88 * longhand properties do not.
     89 */
     90 for (var prop in gCSSProperties) {
     91  var entry = gCSSProperties[prop];
     92  if (entry.pref && !IsCSSPropertyPrefEnabled(entry.pref)) {
     93    continue;
     94  }
     95  if (entry.type == CSS_TYPE_LONGHAND) {
     96    ok(!("subproperties" in entry),
     97       "longhand property '" + prop + "' must not have subproperty list");
     98  } else if (entry.type == CSS_TYPE_TRUE_SHORTHAND ||
     99             entry.type == CSS_TYPE_SHORTHAND_AND_LONGHAND) {
    100    ok("subproperties" in entry,
    101       "shorthand property '" + prop + "' must have subproperty list");
    102  }
    103 
    104  if ("subproperties" in entry) {
    105    var good = true;
    106    if (entry.subproperties.length < 1) {
    107      info("subproperty list for '" + prop + "' is empty");
    108      good = false;
    109    }
    110    for (var idx in entry.subproperties) {
    111      var subprop = entry.subproperties[idx];
    112      if (!(subprop in gCSSProperties)) {
    113        info("subproperty list for '" + prop + "' lists nonexistent subproperty '" + subprop + "'");
    114        good = false;
    115      }
    116    }
    117    ok(good, "property '" + prop + "' has a good subproperty list");
    118  }
    119 
    120  ok("initial_values" in entry && entry.initial_values.length >= 1,
    121     "must have initial values for property '" + prop + "'");
    122  ok("other_values" in entry && entry.other_values.length >= 1,
    123     "must have non-initial values for property '" + prop + "'");
    124 }
    125 
    126 /*
    127 * Test that only longhand properties or its aliases are listed as logical
    128 * properties.
    129 */
    130 for (var prop in gCSSProperties) {
    131  var entry = gCSSProperties[prop];
    132  if (entry.logical) {
    133    ok(entry.type == CSS_TYPE_LONGHAND ||
    134       (entry.alias_for && gCSSProperties[entry.alias_for].logical),
    135       "property '" + prop + "' is listed as CSS_TYPE_LONGHAND or is an alias due to it " +
    136       "being a logical property");
    137  }
    138 }
    139 
    140 /*
    141 * Test that axis is only specified for logical properties.
    142 */
    143 for (var prop in gCSSProperties) {
    144  var entry = gCSSProperties[prop];
    145  if (entry.axis) {
    146    ok(entry.logical,
    147       "property '" + prop + "' is listed as an logical property due to its " +
    148       "being listed as an axis-related property");
    149  }
    150 }
    151 
    152 /*
    153 * Test that DOM properties match the expected rules.
    154 */
    155 for (var prop in gCSSProperties) {
    156  var entry = gCSSProperties[prop];
    157  if (entry.domPropDisabled) {
    158    continue;
    159  }
    160  var expectedDOMProp = prop.replace(/-([a-z])/g,
    161                                     function(m, p1, offset, str) {
    162                                       return p1.toUpperCase();
    163                                     });
    164  if (expectedDOMProp == "float") {
    165    expectedDOMProp = "cssFloat";
    166  } else if (prop.startsWith("-webkit")) {
    167    // Our DOM accessors for webkit-prefixed properties start with lowercase w,
    168    // not uppercase like standard DOM accessors.
    169    expectedDOMProp = expectedDOMProp.replace(/^W/, "w");
    170  }
    171  is(entry.domProp, expectedDOMProp, "DOM property for " + prop);
    172 }
    173 </script>
    174 </pre>
    175 </body>
    176 </html>