mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Add test for CSS interface
This commit is contained in:
parent
62bea28031
commit
dbc35f4360
2 changed files with 43 additions and 0 deletions
|
@ -45847,6 +45847,12 @@
|
|||
"deleted_reftests": {},
|
||||
"items": {
|
||||
"testharness": {
|
||||
"cssom/CSS.html": [
|
||||
{
|
||||
"path": "cssom/CSS.html",
|
||||
"url": "/cssom/CSS.html"
|
||||
}
|
||||
],
|
||||
"cssom/CSSKeyframeRule.html": [
|
||||
{
|
||||
"path": "cssom/CSSKeyframeRule.html",
|
||||
|
|
37
tests/wpt/web-platform-tests/cssom/CSS.html
Normal file
37
tests/wpt/web-platform-tests/cssom/CSS.html
Normal file
|
@ -0,0 +1,37 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<title>CSSOM - CSS interface</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
test(function () {
|
||||
// https://drafts.csswg.org/cssom/#dom-css-escape
|
||||
// https://drafts.csswg.org/cssom/#serialize-an-identifier
|
||||
assert_equals(CSS.escape("hello world"), "hello\\ world", "CSS.escape: spaces get escaped with backslashes");
|
||||
assert_equals(CSS.escape("hello\0world"), "hello\u{FFFD}world", "CSS.escape: NULL get replaced with U+FFFD REPLACEMENT CHARACTER");
|
||||
assert_equals(CSS.escape("hello0world"), "hello0world", "CSS.escape: Numbers within string preserved");
|
||||
assert_equals(CSS.escape("hello\x10world"), "hello\\10 world", "CSS.escape: Values between \\x01 and \\x1f are unicode escaped");
|
||||
assert_equals(CSS.escape("hello\\world"), "hello\\\\world", "CSS.escape: Backslashes get backslash-escaped");
|
||||
assert_equals(CSS.escape("hello\u{1234}world"), "hello\u{1234}world", "CSS.escape: Code points greater than U+0080 are preserved");
|
||||
assert_equals(CSS.escape("hello\x7Fworld"), "hello\\7f world", "CSS.escape: Some code points less than U+0080 are unicode-escaped");
|
||||
assert_equals(CSS.escape("-"), "\\-", "CSS.escape: Single dash escaped");
|
||||
assert_equals(CSS.escape("0foo"), "\\30 foo", "CSS.escape: Numbers at the beginning of an ident get unicode escaped");
|
||||
assert_equals(CSS.escape("-0foo"), "-\\30 foo", "CSS.escape: Numbers at the beginning of an ident after single hyphen get unicode escaped");
|
||||
assert_equals(CSS.escape("--0foo"), "--0foo", "CSS.escape: Numbers at the beginning of an ident after multiple hyphens do not get unicode escaped");
|
||||
}, "CSS.escape");
|
||||
test(function () {
|
||||
// https://drafts.csswg.org/css-conditional/#dom-css-supports
|
||||
// https://drafts.csswg.org/css-conditional/#typedef-supports-condition
|
||||
assert_equals(CSS.supports("color: red"), true, "CSS.supports: Single-argument form allows for declarations without enclosing parentheses");
|
||||
assert_equals(CSS.supports("(color: red) and (color: blue)"), true, "CSS.supports: Complex conditions allowed");
|
||||
assert_equals(CSS.supports("not (foobar)"), true, "CSS.supports: general_enclosed still parses");
|
||||
}, "CSS.supports, one argument form");
|
||||
test(function () {
|
||||
// https://drafts.csswg.org/css-conditional/#dom-css-supports
|
||||
// https://drafts.csswg.org/css-conditional/#dfn-support
|
||||
assert_equals(CSS.supports("color", "red"), true, "CSS.supports: two argument form succeeds for known property");
|
||||
assert_equals(CSS.supports("unknownproperty", "blah"), false, "CSS.supports: two argument form fails for unknown property");
|
||||
assert_equals(CSS.supports("width", "blah"), false, "CSS.supports: two argument form fails for invalid value");
|
||||
assert_equals(CSS.supports("--foo", "blah"), true, "CSS.supports: two argument form succeeds for custom property");
|
||||
}, "CSS.supports, two argument form");
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue