зеркало из https://github.com/mozilla/gecko-dev.git
106 строки
2.1 KiB
HTML
106 строки
2.1 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
|
|
},
|
|
{
|
|
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>
|