Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests (and spec) for :user-valid and :user-invalid are... light #304

Closed
mfreed7 opened this issue Mar 16, 2023 · 11 comments
Closed

Tests (and spec) for :user-valid and :user-invalid are... light #304

mfreed7 opened this issue Mar 16, 2023 · 11 comments
Labels
focus area: CSS Pseudo-classes test-change-proposal Proposal to add or remove tests for an interop area

Comments

@mfreed7
Copy link

mfreed7 commented Mar 16, 2023

Test List

https://wpt.fyi/results/css/selectors/user-invalid.html
https://wpt.fyi/results/css/selectors/user-valid.html

Rationale

These tests of :user-valid and :user-invalid will 100% pass if:

  1. Those two pseudo classes are parsed as valid by the CSS parser.
  2. They never match any elements.

Here is the :user-valid test, in its entirety:

  const input = document.querySelector('input');
  assert_true(input.validity.valid);
  // The selector can't match because no interaction has happened.
  assert_false(input.matches(':user-valid'));

The spec is located here:
https://w3c.github.io/csswg-drafts/selectors-4/#user-pseudos

It uses phrasing like "the user has significantly interacted with it" and "interacted again" as a criterion for when to apply these pseudos, but I'm not clear that we've defined those cases clearly enough to be interoperable. There's an open discussion in the interop issue for this set of features, and this comment (#178 (comment)) attempts to define the behavior in terms of links to Gecko code. That's great, and I'm sure the proposed behavior is reasonable. But I think that this Interop2023 issue is kind of pointless unless we have significantly more testing, and that will require significantly more discussion about exactly how to spec the feature. Chromium is supportive of this feature, but only if it can be implemented, spec'd, and tested interoperably.

How should we proceed?

@emilio @annevk

@mfreed7 mfreed7 added the test-change-proposal Proposal to add or remove tests for an interop area label Mar 16, 2023
@annevk
Copy link
Member

annevk commented Mar 16, 2023

Right, see whatwg/html#8452.

@mfreed7
Copy link
Author

mfreed7 commented Mar 16, 2023

Right, see whatwg/html#8452.

Ahh, thanks! I missed that issue. Looks like my comments here are still correct though - it isn't standardized yet.

@foolip foolip mentioned this issue Mar 16, 2023
@nt1m
Copy link
Member

nt1m commented Mar 16, 2023

Yeah I do think we should work towards precisely defining the behavior and then writing more precise tests. WebKit uses a different model than Gecko, which I think should be easier to spec (since it just maps directly to change events).

@nt1m
Copy link
Member

nt1m commented Mar 16, 2023

I'm going to take on the work to spec user-invalid/valid

@mfreed7
Copy link
Author

mfreed7 commented Mar 17, 2023

I'm going to take on the work to spec user-invalid/valid

Awesome, thanks!

@nt1m
Copy link
Member

nt1m commented Mar 17, 2023

Here's my first attempt at specifying: whatwg/html#9047

@nt1m
Copy link
Member

nt1m commented May 25, 2023

@mfreed7 Can you let us know if the new tests are sufficient and close the issue if needed? I'll work on the spec & further tests when I have more time.

@nt1m
Copy link
Member

nt1m commented May 25, 2023

These are the changes fwiw: web-platform-tests/wpt@b669c6c

@mfreed7
Copy link
Author

mfreed7 commented May 30, 2023

@mfreed7 Can you let us know if the new tests are sufficient and close the issue if needed? I'll work on the spec & further tests when I have more time.

Thanks - the new tests look pretty good. I can't think of another case to check, off-hand, but we'll possibly find more as we start to implement it. But for now I think this is great, so I'll close it.

@mfreed7 mfreed7 closed this as completed May 30, 2023
@mfreed7
Copy link
Author

mfreed7 commented Aug 1, 2023

See my comment here whatwg/html#9047 (comment)

I'll re-open this tentatively.

@nt1m
Copy link
Member

nt1m commented Aug 24, 2023

Given Chromium is implementing :user-valid/:user-invalid, I'm going to close this: https://chromium-review.googlesource.com/4800294

I'm hoping the spec PR can be merged soon as well.

@nt1m nt1m closed this as completed Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus area: CSS Pseudo-classes test-change-proposal Proposal to add or remove tests for an interop area
Projects
None yet
Development

No branches or pull requests

4 participants