mirror of
https://github.com/servo/servo.git
synced 2025-08-16 19:05:33 +01:00
Auto merge of #14789 - Manishearth:supports, r=SimonSapin
Support @supports fixes #14786 cc @heycam @upsuper r? @SimonSapin <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14789) <!-- Reviewable:end -->
This commit is contained in:
commit
50bba770d6
98 changed files with 638 additions and 218 deletions
|
@ -39,6 +39,25 @@ macro_rules! assert_roundtrip_with_context {
|
|||
}
|
||||
}
|
||||
|
||||
macro_rules! assert_roundtrip {
|
||||
($fun:expr, $string:expr) => {
|
||||
assert_roundtrip!($fun, $string, $string);
|
||||
};
|
||||
($fun:expr,$input:expr, $output:expr) => {
|
||||
let mut parser = Parser::new($input);
|
||||
let parsed = $fun(&mut parser)
|
||||
.expect(&format!("Failed to parse {}", $input));
|
||||
let serialized = ToCss::to_css_string(&parsed);
|
||||
assert_eq!(serialized, $output);
|
||||
|
||||
let mut parser = Parser::new(&serialized);
|
||||
let re_parsed = $fun(&mut parser)
|
||||
.expect(&format!("Failed to parse serialization {}", $input));
|
||||
let re_serialized = ToCss::to_css_string(&re_parsed);
|
||||
assert_eq!(serialized, re_serialized);
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! parse_longhand {
|
||||
($name:ident, $s:expr) => {{
|
||||
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
|
||||
|
@ -58,3 +77,4 @@ mod inherited_text;
|
|||
mod mask;
|
||||
mod position;
|
||||
mod selectors;
|
||||
mod supports;
|
||||
|
|
14
tests/unit/style/parsing/supports.rs
Normal file
14
tests/unit/style/parsing/supports.rs
Normal file
|
@ -0,0 +1,14 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use cssparser::Parser;
|
||||
use style::supports::SupportsCondition;
|
||||
use style_traits::ToCss;
|
||||
|
||||
#[test]
|
||||
fn test_supports_condition() {
|
||||
assert_roundtrip!(SupportsCondition::parse, "(margin: 1px)");
|
||||
assert_roundtrip!(SupportsCondition::parse, "not (--be: to be)");
|
||||
assert_roundtrip!(SupportsCondition::parse, "(color: blue) and future-extension(4)");
|
||||
}
|
|
@ -21,6 +21,13 @@ skip: true
|
|||
[xhtml1print]
|
||||
skip: true
|
||||
|
||||
[css-conditional-3_dev]
|
||||
skip: false
|
||||
[xhtml1]
|
||||
skip: true
|
||||
[xhtml1print]
|
||||
skip: true
|
||||
|
||||
[css-flexbox-1_dev]
|
||||
skip: false
|
||||
[xhtml1]
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
[001.htm]
|
||||
type: testharness
|
||||
[Inserting @font-face inside @supports works]
|
||||
expected: FAIL
|
||||
|
||||
[Inserting an @supports inside a style rule should fail]
|
||||
expected: FAIL
|
||||
|
|
@ -2,3 +2,4 @@
|
|||
type: testharness
|
||||
[changing transition-property / values]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
[variable-external-supports-01.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-01.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-02.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-03.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-04.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-05.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-06.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-07.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-08.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-09.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-10.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-11.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-12.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-13.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-14.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-15.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-16.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-17.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-18.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-19.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-20.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-21.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-22.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-23.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-24.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-25.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-26.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-27.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-28.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-29.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-30.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-31.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-32.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-33.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-34.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-35.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-36.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-37.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-38.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-39.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-40.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-41.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-42.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-43.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-44.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-45.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-46.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-47.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-48.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-49.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-50.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-51.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-52.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-53.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-54.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-55.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-56.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-57.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-58.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-59.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-60.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-61.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-62.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-63.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-64.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-65.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-66.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[variable-supports-67.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,5 +1,6 @@
|
|||
[css-style-declaration-modifications.htm]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
[CSSStyleDeclaration_accessible]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -204,3 +204,9 @@
|
|||
[PseudoElement interface: attribute usedStyle]
|
||||
expected: FAIL
|
||||
|
||||
[CSSMediaRule interface: existence and properties of interface object]
|
||||
expected: FAIL
|
||||
|
||||
[CSSMediaRule interface: existence and properties of interface prototype object]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -20,6 +20,7 @@ test_interfaces([
|
|||
"CharacterData",
|
||||
"CloseEvent",
|
||||
"CSS",
|
||||
"CSSConditionRule",
|
||||
"CSSFontFaceRule",
|
||||
"CSSGroupingRule",
|
||||
"CSSImportRule",
|
||||
|
@ -32,6 +33,7 @@ test_interfaces([
|
|||
"CSSStyleDeclaration",
|
||||
"CSSStyleRule",
|
||||
"CSSStyleSheet",
|
||||
"CSSSupportsRule",
|
||||
"CSSViewportRule",
|
||||
"DOMMatrix",
|
||||
"DOMMatrixReadOnly",
|
||||
|
|
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