summaryrefslogtreecommitdiff
path: root/layout/inspector/tests/test_css_property_is_valid.html
blob: 21f00bf1848edd6a8ffbb37083e38cdcc6aa3018 (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <title>Test inDOMUtils::CssPropertyIsValid</title>
  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  <script type="application/javascript;version=1.8">
  let utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
                           .getService(SpecialPowers.Ci.inIDOMUtils);

  let tests = [
    {
      property: "color",
      value: "red",
      expected: true
    },
    {
      property: "display",
      value: "none",
      expected: true
    },
    {
      property: "display",
      value: "red",
      expected: false
    },
    {
      property: "displayx",
      value: "none",
      expected: false
    },
    {
      property: "border",
      value: "1px solid blue",
      expected: true
    },
    {
      property: "border",
      value: "1 solid blue",
      expected: false
    },
    {
      property: "border",
      value: "1px underline blue",
      expected: false
    },
    {
      property: "border",
      value: "1px solid",
      expected: true
    },
    {
      property: "color",
      value: "blue !important",
      expected: true
    },
    {
      property: "color",
      value: "blue ! important",
      expected: true
    },
    {
      property: "color",
      value: "blue !impoxxxrtant",
      expected: false
    },
    {
      property: "color",
      value: "red; background:green;",
      expected: false
    },
    {
      property: "content",
      value: "\"hello\"",
      expected: true
    },
    {
      property: "color",
      value: "var(--some-kind-of-green)",
      expected: true
    }
  ];

  for (let {property, value, expected} of tests) {
    let valid = utils.cssPropertyIsValid(property, value);

    if (expected) {
      ok(valid, property + ":" + value + " is valid");
    } else {
      ok(!valid, property + ":" + value + " is not valid");
    }
  }
  </script>
</head>
<body>
<h1>Test inDOMUtils::CssPropertyIsValid</h1>
<p id="display"></p>
<div id="content" style="display: none">

</div>
<pre id="test">
</pre>
</body>
</html>