tor-browser

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

test_bug1112014.html (2745B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=1112014
      5 -->
      6 <head>
      7  <meta charset="utf-8">
      8  <title>Test for Bug 1112014</title>
      9  <script src="/tests/SimpleTest/SimpleTest.js"></script>
     10  <script src="property_database.js"></script>
     11  <script type="application/javascript">
     12 
     13 SimpleTest.waitForExplicitFinish();
     14 SimpleTest.requestLongerTimeout(2);
     15 
     16 async function test() {
     17  const InspectorUtils = SpecialPowers.InspectorUtils;
     18 
     19  // This holds a canonical test value for each TYPE_ constant.
     20  let testValues = {
     21    "color": "rgb(3,3,3)",
     22    "gradient": "linear-gradient( 45deg, blue, red )",
     23    "timing-function": "cubic-bezier(0.1, 0.7, 1.0, 0.1)",
     24  };
     25 
     26  // The canonical test values don't work for all properties, in
     27  // particular some shorthand properties.  For these cases we have
     28  // override values.
     29  let overrideValues = {
     30    "box-shadow": {
     31      "color": testValues.color + " 2px 2px"
     32    },
     33    "-webkit-box-shadow": {
     34      "color": testValues.color + " 2px 2px"
     35    },
     36    "scrollbar-color": {
     37      "color": testValues.color + " " + testValues.color,
     38    },
     39    "text-shadow": {
     40      "color": testValues.color + " 2px 2px"
     41    },
     42  };
     43 
     44 
     45  // Ensure that all the TYPE_ constants have a representative
     46  // test value, to try to ensure that this test is updated
     47  // whenever a new type is added.
     48  let reps = await SpecialPowers.spawn(window, [], () => {
     49    return Object.getOwnPropertyNames(InspectorUtils).filter(tc => /TYPE_/.test(tc));
     50  }).then(v => v.filter(tc => !(tc in testValues)));
     51  is(reps.join(","), "", "all types have representative test value");
     52 
     53  for (let propertyName in gCSSProperties) {
     54    let prop = gCSSProperties[propertyName];
     55 
     56    for (let iter in testValues) {
     57      let testValue = testValues[iter];
     58      if (propertyName in overrideValues &&
     59          iter in overrideValues[propertyName]) {
     60        testValue = overrideValues[propertyName][iter];
     61      }
     62 
     63      let supported =
     64        InspectorUtils.cssPropertySupportsType(propertyName, iter);
     65      let parsed = CSS.supports(propertyName, testValue);
     66      is(supported, parsed, propertyName + " supports " + iter);
     67    }
     68  }
     69 
     70  // Regression test for an assertion failure in an earlier version of
     71  // the code.  Note that cssPropertySupportsType returns false for
     72  // all types for a variable.
     73  ok(!InspectorUtils.cssPropertySupportsType("--variable", "color"),
     74     "cssPropertySupportsType returns false for variable");
     75 
     76  SimpleTest.finish();
     77 }
     78  </script>
     79 </head>
     80 <body onload="test()">
     81 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1112014">Mozilla Bug 1112014</a>
     82 <p id="display"></p>
     83 <div id="content" style="display: none">
     84 
     85 </div>
     86 <pre id="test">
     87 </pre>
     88 </body>
     89 </html>