Skip to content

Commit

Permalink
Implement at-rule for use with @supports.
Browse files Browse the repository at this point in the history
It's behind a flag for now. Note that there is a CSSWG resolution
(w3c/csswg-drafts#2463 (comment))
but no spec. We don't support the proposed but not yet ratified
extension of having a full block
(w3c/csswg-drafts#6966)

Bug: 40211832
Change-Id: Ic80e28abe9e9fce6d44b1a52311aba7b60a8caa2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5972643
Reviewed-by: Anders Hartvoll Ruud <[email protected]>
Commit-Queue: Steinar H Gunderson <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1376258}
  • Loading branch information
Steinar H. Gunderson authored and chromium-wpt-export-bot committed Oct 31, 2024
1 parent a2112d6 commit 30d1140
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions css/css-conditional/js/supports-at-rule.tentative.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!doctype html>
<title>@supports at-rule</title>
<link rel="help" href="https://www.w3.org/TR/css-conditional-4/#the-css-namespace">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function test_supports(rule, expected, desc) {
test(() => {
assert_equals(CSS.supports(rule), expected, 'CSS.supports(' + rule + ')');
}, desc);
}

// Basic at-rule support.
test_supports("at-rule(@supports)", true);
test_supports("at-rule( @supports)", true);
test_supports("at-rule(@supports )", true);
test_supports("at-rule(@media)", true);
test_supports("at-rule(@counter-style)", true);
test_supports("at-rule(@doesnotexist)", false);

// With descriptors.
test_supports("at-rule(@counter-style; system: fixed)", true);
test_supports("at-rule(@counter-style;system: fixed )", true);
test_supports("at-rule(@counter-style;system: fixed )", true);
test_supports("at-rule(@counter-style; system:)", false, "missing value 1");
test_supports("at-rule(@counter-style; system: )", false, "missing value 2");
test_supports("at-rule(@counter-style; system: doesnotexist)", false, "invalid value");
test_supports("at-rule(@counter-style; system: fixed junk)", false, "junk after value");
test_supports("at-rule(@counter-style; system)", false, "missing value 3");
test_supports("at-rule(@counter-style! system: fixed)", false, "invalid separator");
test_supports("at-rule(@counter-style; suffix: \"abc\")", true, "quoted value is OK");
test_supports("at-rule(@counter-style; suffix: \"abc\";)", false, "semicolon after value");
test_supports("at-rule(@counter-style; suffix: \"abc\"", true, "implicit end parenthesis");
test_supports("at-rule(@counter-style; system: fixed; system: fixed)", false, "multiple descriptors");
test_supports("at-rule(@supports; system: fixed)", false, "descriptor invalid in context");
test_supports("at-rule(@media; color: red)", false, "properties are not descriptors");
</script>

0 comments on commit 30d1140

Please sign in to comment.