Skip to content

Commit

Permalink
Add :user-valid test for programmatically setting value
Browse files Browse the repository at this point in the history
When assigning into input.value from script, :user-valid and
:user-invalid should not start matching because it is not input from the
user:
https://drafts.csswg.org/selectors-4/#user-pseudos:~:text=but%20only%20after%20the%20user%20has%20significantly%20interacted%20with%20it

Change-Id: I2304c65c6e3a120af4c20829566ad3922940b983
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5018442
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Reviewed-by: Mason Freed <masonf@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1225826}
  • Loading branch information
josepharhar authored and chromium-wpt-export-bot committed Nov 17, 2023
1 parent 2274ebe commit 06b33e5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions css/selectors/user-invalid.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@
assert_false(input.matches(":user-valid"), "No change happened, still does not match :user-valid");
assert_false(input.matches(":user-invalid"), "No change happened, still does not match :user-invalid");

input.value = "not an email";

assert_false(input.matches(":user-valid"), "Programatically set value, :user-valid should not match");
assert_false(input.matches(":user-invalid"), "Programatically set value, :user-invalid should not match");

input.value = "";

assert_false(input.matches(":user-valid"), "Programatically cleared value, :user-valid should not match");
assert_false(input.matches(":user-invalid"), "Programatically cleared value, :user-invalid should not match");

await test_driver.click(input);
await test_driver.send_keys(input, "not an email");
input.blur();
Expand Down
10 changes: 10 additions & 0 deletions css/selectors/user-valid.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@
assert_false(input.matches(":user-valid"), "No change happened, still does not match :user-valid");
assert_false(input.matches(":user-invalid"), "No change happened, still does not match :user-invalid");

input.value = "test@example.com";

assert_false(input.matches(":user-valid"), "Programatically set value, :user-valid should not match");
assert_false(input.matches(":user-invalid"), "Programatically set value, :user-invalid should not match");

input.value = "";

assert_false(input.matches(":user-valid"), "Programatically cleared value, :user-valid should not match");
assert_false(input.matches(":user-invalid"), "Programatically cleared value, :user-invalid should not match");

await test_driver.click(input);
await test_driver.send_keys(input, "test@example.com");
input.blur();
Expand Down

0 comments on commit 06b33e5

Please sign in to comment.