gecko/layout/inspector/tests/test_css_property_is_valid.html

101 lines
2.0 KiB
HTML

<!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
}
];
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>