css/css-values/if-cycle.html expects a `style()` test of `--prop` inside `--prop`'s own `if()` to make it guaranteed-invalid, where css-values-5 makes that test false

Open
#65,835 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
html, javascript, playwright
Domain
testing, web-dev

Research direction

Start with css/css-values/if-cycle.html and compare the five cases where style() tests --prop inside its own if() against the css-values-5 rule quoted in the issue. Run the supplied reproducer to confirm the browser results. Decide whether the test expectations or the spec rule need to change, then update the affected cases and verify the Web Platform Test.

Written by the indexing model from the issue text.

Description

css-values-5's replace an if() function says: "If a <style-query> in condition tests the value of a property, and guarding a substitution context «"property", referenced-property-name» would mark it as a cyclic substitution context, that query evaluates to false." Its example: "in --foo: if(style(--foo: bar): baz); the style() query is automatically false". The rule came with w3c/csswg-drafts#11500, in w3c/csswg-drafts@c7235bb46274.

css/css-values/if-cycle.html puts each if() in --prop, and five cases test --prop itself in a style() query and expect --prop to be guaranteed-invalid (''). By the rule each of those tests is false, so the if() takes its other branch: if(style(--prop): var(--prop); else: value) gives value, if(style(--prop: 3): true_value; else: false_value) gives false_value, and the or/and cases follow from a false (--prop). Chromium and WebKit compute '' as the test expects; Firefox leaves the if()s it does not support as written.

Reproducer: https://gist.github.com/YevheniiKotyrlo/7c169641ce372c86f3fc124dde3a54db

git clone https://gist.github.com/7c169641ce372c86f3fc124dde3a54db.git if-cycle-style-test-of-itself
cd if-cycle-style-test-of-itself
sh ./run.sh

run.sh installs Playwright and runs repro.mjs, which reads the rule from csswg-drafts main and if-cycle.html from wpt master, prints each case whose style() query tests --prop, and computes each in Chromium, Firefox and WebKit as test_if() does. It exits 1 while the rule stands and a case expects ''. On Windows 11 with Node 26.12.1 and Playwright 1.65.0:

css-values-5 from w3c/csswg-drafts@6f177f4c13fbc3153474b66e88c25cf58ce5cfdd; if-cycle.html from web-platform-tests/wpt@7afc7e8f2ae85d916622d5de523a6bf08c55f3c1
  css-values-5: "If a <<style-query>> in |condition| tests the value of a property, and [=guarded|guarding=] a [=substitution context=] &bs<<;"property", referenced-property-name&bs>>; would mark it as a [=cyclic substitution context=], that query evaluates to false."
  wpt test_if: --prop: if(style(--prop): var(--prop); else: value) with [] expects ''
  wpt test_if: --prop: if(style(--prop: 3): true_value; else: false_value) with [["--prop","3"]] expects ''
  wpt test_if: --prop: if(style(not (--prop)): true_value; else: false_value) with [] expects ''
  wpt test_if: --prop: if(style((--prop) or (--y)): true_value; else: false_value) with [["--y","3"]] expects ''
  wpt test_if: --prop: if(style((--prop) and (--y)): true_value; else: false_value) with [["--y","3"]] expects ''
  wpt test_if: --prop: if(style(--x: 0): value1; style(--prop): value2) with [["--x","0"]] expects 'value1'
  the engines' --prop for each case above, in order:
playwright 1.65.0
chromium 158.0.8127.18: '', '', '', '', '', 'value1'
firefox 159.0: '', 'if(style(--prop: 3): true_value; else: false_value)', 'if(style(not (--prop)): true_value; else: false_value)', 'if(style((--prop) or (--y)): true_value; else: false_value)', 'if(style((--prop) and (--y)): true_value; else: false_value)', 'if(style(--x: 0): value1; style(--prop): value2)'
webkit 27.2: '', '', '', '', '', 'value1'

SUMMARY: css-values-5 makes a style() test of --prop inside --prop's own if() false, and if-cycle.html expects 5 such if()s to make --prop guaranteed-invalid ('')

I'd expect these cases to expect the branch the false test leads to, or the rule to change if the cycle is meant to win.

Dominant language
HTML
Stars
6.3k
Forks
4.1k
Avg merge
17h 20m
Merged PRs (30d)
841

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from web-platform-tests/wpt

All issues in web-platform-tests/wpt

Similar issues

More Testing & QA issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.