summaryrefslogtreecommitdiffstats
path: root/layout/style/test/test_condition_text.html
blob: e2462979c2ba3d46f854cfbe3e449f2485b47a04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=814907
-->
<head>
  <title>Test for Bug 814907</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  <style id="style">
    @media all {}
    @media only color {}
    @media (color ) {}
    @media color \0061ND ( monochrome ) {}
    @media (max-width: 200px), (color) {}

    @supports(color: green){}
    @supports (color: green) {}
    @supports ((color: green)) {}
    @supports (color: green) and (color: blue) {}
    @supports ( Font:  20px serif ! Important)  {}
  </style>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=814907">Mozilla Bug 814907</a>
<p id="display"></p>
<div id="content" style="display: none">

</div>
<pre id="test">
<script type="application/javascript">

/** Test for Bug 814907 **/

function runTest()
{
  // re-parse the style sheet with the pref turned on
  var style = document.getElementById("style");
  style.textContent += " ";

  var sheet = style.sheet;

  var conditions = [
    "all",
    "only color",
    "(color)",
    "color and (monochrome)",
    "(max-width: 200px), (color)",
    "(color: green)",
    "(color: green)",
    "((color: green))",
    "(color: green) and (color: blue)",
    "( Font:  20px serif ! Important)"
  ];

  is(sheet.cssRules.length, conditions.length);

  for (var i = 0; i < sheet.cssRules.length; i++) {
    var rule = sheet.cssRules[i];
    is(rule.conditionText, conditions[i], "rule " + i + " has expected conditionText");
    if (rule.type == CSSRule.MEDIA_RULE) {
      is(rule.conditionText, rule.media.mediaText, "rule " + i + " conditionText matches media.mediaText");
    }
  }

  SimpleTest.finish();
}

SimpleTest.waitForExplicitFinish();
runTest();
</script>
</pre>
</body>
</html>