Skip to content

Commit edca4e6

Browse files
committed
Bug 2024601 - patch 2 - Add evaluation tests involving substitution functions. r=firefox-style-system-reviewers,emilio
The existing WPTs check that these forms can be parsed, but not that they actually work at matching time. So this adds a few examples to the query-evaluation test. They won't pass in Firefox until support for these functions is hooked up. (Confirmed that these work as expected in Chrome.) Differential Revision: https://phabricator.services.mozilla.com/D290903
1 parent a17f99d commit edca4e6

2 files changed

Lines changed: 39 additions & 2 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[query-evaluation-style.html]
2+
3+
[style(1px < attr(xyzzy type(<length>)) < 10px)]
4+
expected: FAIL
5+
6+
[style(1px < attr(plugh, 5px) < 10px)]
7+
expected: FAIL
8+
9+
[style(1px < attr(plugh type(<length>), 5px) < 10px)]
10+
expected: FAIL
11+
12+
[style(var(--unknown-prop, 20px) > 10px)]
13+
expected: FAIL
14+
15+
[style(var(--prop, 5px) > 10px)]
16+
expected: FAIL
17+
18+
[style(var(--length, 20px) < 10px)]
19+
expected: FAIL

testing/web-platform/tests/css/css-conditional/container-queries/query-evaluation-style.html

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
--foo: bar;
4646
}
4747
</style>
48-
<div id=container>
48+
<div id=container xyzzy="5px">
4949
<div id=inner data-foo="3px"></div>
5050
</div>
5151
<script>
@@ -239,10 +239,28 @@
239239
test_query_with_custom_properties('style(--x >= 3ms)',
240240
[['--x', '3px']],
241241
false);
242-
test_query_with_custom_properties(`style(--length <= 30px)`,
242+
test_query_with_custom_properties('style(--length <= 30px)',
243243
[['--length', 'attr(data-foo type(<length>))']],
244244
true);
245245

246+
// These should be true: the container has an attribute 'xyzzy="5px"',
247+
// while 'plugh' is undefined so will use the default.
248+
test_query('style(1px < attr(xyzzy type(<length>)) < 10px)', true);
249+
test_query('style(1px < attr(plugh, 5px) < 10px)', true);
250+
test_query('style(1px < attr(plugh type(<length>), 5px) < 10px)', true);
251+
// This is false because the untyped attr() resolves to a string, not a length.
252+
test_query('style(1px < attr(xyzzy) < 10px)', false);
253+
test_query('style(1px < attr(plugh, "5px") < 10px)', false);
254+
255+
// var() function with a default value.
256+
test_query('style(var(--unknown-prop, 20px) > 10px)', true);
257+
test_query_with_custom_properties('style(var(--prop, 5px) > 10px)',
258+
[['--prop', '15px']],
259+
true);
260+
test_query_with_custom_properties('style(var(--length, 20px) < 10px)',
261+
[['--length', 'attr(data-foo type(<length>))']],
262+
true);
263+
246264
test_query('style(10px <= 10px < 11px)', true);
247265
test_query_with_custom_properties(
248266
'style(3 < --x <= 5)',

0 commit comments

Comments
 (0)