|
| 1 | +<!doctype html> |
| 2 | +<title>@supports at-rule</title> |
| 3 | +<link rel="help" href="https://www.w3.org/TR/css-conditional-4/#the-css-namespace"> |
| 4 | +<script src="/resources/testharness.js"></script> |
| 5 | +<script src="/resources/testharnessreport.js"></script> |
| 6 | +<script> |
| 7 | + function test_supports(rule, expected, desc) { |
| 8 | + test(() => { |
| 9 | + assert_equals(CSS.supports(rule), expected, 'CSS.supports(' + rule + ')'); |
| 10 | + }, desc); |
| 11 | + } |
| 12 | + |
| 13 | + // Basic at-rule support. |
| 14 | + test_supports("at-rule(@supports)", true); |
| 15 | + test_supports("at-rule( @supports)", true); |
| 16 | + test_supports("at-rule(@supports )", true); |
| 17 | + test_supports("at-rule(@media)", true); |
| 18 | + test_supports("at-rule(@counter-style)", true); |
| 19 | + test_supports("at-rule(@doesnotexist)", false); |
| 20 | + |
| 21 | + // With descriptors. |
| 22 | + test_supports("at-rule(@counter-style; system: fixed)", true); |
| 23 | + test_supports("at-rule(@counter-style;system: fixed )", true); |
| 24 | + test_supports("at-rule(@counter-style;system: fixed )", true); |
| 25 | + test_supports("at-rule(@counter-style; system:)", false, "missing value 1"); |
| 26 | + test_supports("at-rule(@counter-style; system: )", false, "missing value 2"); |
| 27 | + test_supports("at-rule(@counter-style; system: doesnotexist)", false, "invalid value"); |
| 28 | + test_supports("at-rule(@counter-style; system: fixed junk)", false, "junk after value"); |
| 29 | + test_supports("at-rule(@counter-style; system)", false, "missing value 3"); |
| 30 | + test_supports("at-rule(@counter-style! system: fixed)", false, "invalid separator"); |
| 31 | + test_supports("at-rule(@counter-style; suffix: \"abc\")", true, "quoted value is OK"); |
| 32 | + test_supports("at-rule(@counter-style; suffix: \"abc\";)", false, "semicolon after value"); |
| 33 | + test_supports("at-rule(@counter-style; suffix: \"abc\"", true, "implicit end parenthesis"); |
| 34 | + test_supports("at-rule(@counter-style; system: fixed; system: fixed)", false, "multiple descriptors"); |
| 35 | + test_supports("at-rule(@supports; system: fixed)", false, "descriptor invalid in context"); |
| 36 | + test_supports("at-rule(@media; color: red)", false, "properties are not descriptors"); |
| 37 | +</script> |
0 commit comments