layout/style/test/test_extra_inherit_initial.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/style/test/test_extra_inherit_initial.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,94 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=940229
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test handling extra inherit/initial/unset in CSS declarations (Bug 940229)</title>
    1.11 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +  <script type="text/javascript" src="property_database.js"></script>
    1.13 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.14 +</head>
    1.15 +<body>
    1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=940229">Mozilla Bug 940229</a>
    1.17 +<p id="display"></p>
    1.18 +<div id="content" style="display: none">
    1.19 +
    1.20 +<div id="testnode"></div>
    1.21 +  
    1.22 +</div>
    1.23 +<pre id="test">
    1.24 +<script class="testbody" type="text/javascript">
    1.25 +
    1.26 +/*
    1.27 + * Inspired by mistake in quotes noticed while reviewing bug 189519.
    1.28 + */
    1.29 +
    1.30 +var gPropsNeedComma = {
    1.31 +  "font": true,
    1.32 +  "font-family": true,
    1.33 +  "voice-family": true,
    1.34 +};
    1.35 +
    1.36 +var gElement = document.getElementById("testnode");
    1.37 +var gDeclaration = gElement.style;
    1.38 +
    1.39 +function test_property(property)
    1.40 +{
    1.41 +  var info = gCSSProperties[property];
    1.42 +
    1.43 +  var delim = (property in gPropsNeedComma) ? ", " : " ";
    1.44 +
    1.45 +  function test_value_pair(relation, val1, val2, extraval) {
    1.46 +    var decl = property + ": " + val1 + delim + val2;
    1.47 +    gElement.setAttribute("style", decl);
    1.48 +    if ("subproperties" in info) {
    1.49 +      for (idx in info.subproperties) {
    1.50 +        var subprop = info.subproperties[idx];
    1.51 +        is(gDeclaration.getPropertyValue(subprop), "",
    1.52 +           ["expected", extraval, "ignored", relation, "value in",
    1.53 +            "'" + decl + "'", "when looking at subproperty",
    1.54 +            "'" + subprop + "'"].join(" "));
    1.55 +      }
    1.56 +    } else {
    1.57 +      is(gDeclaration.getPropertyValue(property), "",
    1.58 +         ["expected", extraval, "ignored", relation, "value in",
    1.59 +          "'" + decl + "'"].join(" "));
    1.60 +    }
    1.61 +  }
    1.62 +
    1.63 +  function test_value(value) {
    1.64 +    test_value_pair("after", value, "inherit", "inherit");
    1.65 +    test_value_pair("after", value, "initial", "initial");
    1.66 +    test_value_pair("after", value, "unset", "unset");
    1.67 +    test_value_pair("before", "inherit", value, "inherit");
    1.68 +    test_value_pair("before", "initial", value, "initial");
    1.69 +    test_value_pair("before", "unset", value, "unset");
    1.70 +  }
    1.71 +
    1.72 +  var idx;
    1.73 +  for (idx in info.initial_values)
    1.74 +    test_value(info.initial_values[idx]);
    1.75 +  for (idx in info.other_values)
    1.76 +    test_value(info.other_values[idx]);
    1.77 +}
    1.78 +
    1.79 +SimpleTest.waitForExplicitFinish();
    1.80 +SimpleTest.requestLongerTimeout(4);
    1.81 +
    1.82 +function start_test() {
    1.83 +  for (var prop in gCSSProperties) {
    1.84 +    test_property(prop);
    1.85 +  }
    1.86 +  SimpleTest.finish();
    1.87 +}
    1.88 +
    1.89 +// Turn off CSS error reporting for this test, since it's a bit expensive,
    1.90 +// and we're expecting to generate tons and tons of parse errors here.
    1.91 +SpecialPowers.pushPrefEnv({ "set": [["layout.css.report_errors", false]] },
    1.92 +                          start_test);
    1.93 +
    1.94 +</script>
    1.95 +</pre>
    1.96 +</body>
    1.97 +</html>

mercurial