layout/style/test/test_condition_text.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/style/test/test_condition_text.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,93 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=814907
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 814907</title>
    1.11 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.13 +  <style id="style">
    1.14 +    @-moz-document url(http://www.example.com/) {}
    1.15 +    @-moz-document url('http://www.example.com/') {}
    1.16 +    @-moz-document url("http://www.example.com/") {}
    1.17 +    @-moz-document url-prefix('http://www.example.com/') {}
    1.18 +    @-moz-document url-prefix("http://www.example.com/") {}
    1.19 +    @-moz-document domain('example.com') {}
    1.20 +    @-moz-document domain("example.com") {}
    1.21 +    @-moz-document regexp('http://www.w3.org/TR/\\d{4}/[^/]*-CSS2-\\d{8}/') {}
    1.22 +    @-moz-document regexp("http://www.w3.org/TR/\\d{4}/[^/]*-CSS2-\\d{8}/") {}
    1.23 +
    1.24 +    @media all {}
    1.25 +    @media only color {}
    1.26 +    @media (color ) {}
    1.27 +    @media color \0061ND ( monochrome ) {}
    1.28 +    @media (max-width: 200px), (color) {}
    1.29 +
    1.30 +    @supports(color: green){}
    1.31 +    @supports (color: green) {}
    1.32 +    @supports ((color: green)) {}
    1.33 +    @supports (color: green) and (color: blue) {}
    1.34 +    @supports ( Font:  20px serif ! Important)  {}
    1.35 +  </style>
    1.36 +</head>
    1.37 +<body>
    1.38 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=814907">Mozilla Bug 814907</a>
    1.39 +<p id="display"></p>
    1.40 +<div id="content" style="display: none">
    1.41 +
    1.42 +</div>
    1.43 +<pre id="test">
    1.44 +<script type="application/javascript">
    1.45 +
    1.46 +/** Test for Bug 814907 **/
    1.47 +
    1.48 +function runTest()
    1.49 +{
    1.50 +  // re-parse the style sheet with the pref turned on
    1.51 +  var style = document.getElementById("style");
    1.52 +  style.textContent += " ";
    1.53 +
    1.54 +  var sheet = style.sheet;
    1.55 +
    1.56 +  var conditions = [
    1.57 +    "url(\"http://www.example.com/\")",
    1.58 +    "url(\"http://www.example.com/\")",
    1.59 +    "url(\"http://www.example.com/\")",
    1.60 +    "url-prefix(\"http://www.example.com/\")",
    1.61 +    "url-prefix(\"http://www.example.com/\")",
    1.62 +    "domain(\"example.com\")",
    1.63 +    "domain(\"example.com\")",
    1.64 +    "regexp(\"http://www.w3.org/TR/\\\\d{4}/[^/]*-CSS2-\\\\d{8}/\")",
    1.65 +    "regexp(\"http://www.w3.org/TR/\\\\d{4}/[^/]*-CSS2-\\\\d{8}/\")",
    1.66 +    "all",
    1.67 +    "only color",
    1.68 +    "(color)",
    1.69 +    "color and (monochrome)",
    1.70 +    "(max-width: 200px), (color)",
    1.71 +    "(color: green)",
    1.72 +    "(color: green)",
    1.73 +    "((color: green))",
    1.74 +    "(color: green) and (color: blue)",
    1.75 +    "( Font:  20px serif ! Important)"
    1.76 +  ];
    1.77 +
    1.78 +  is(sheet.cssRules.length, conditions.length);
    1.79 +
    1.80 +  for (var i = 0; i < sheet.cssRules.length; i++) {
    1.81 +    var rule = sheet.cssRules[i];
    1.82 +    is(rule.conditionText, conditions[i], "rule " + i + " has expected conditionText");
    1.83 +    if (rule.type == CSSRule.MEDIA_RULE) {
    1.84 +      is(rule.conditionText, rule.media.mediaText, "rule " + i + " conditionText matches media.mediaText");
    1.85 +    }
    1.86 +  }
    1.87 +
    1.88 +  SimpleTest.finish();
    1.89 +}
    1.90 +
    1.91 +SimpleTest.waitForExplicitFinish();
    1.92 +SpecialPowers.pushPrefEnv({ "set": [["layout.css.supports-rule.enabled", true]] }, runTest);
    1.93 +</script>
    1.94 +</pre>
    1.95 +</body>
    1.96 +</html>

mercurial