Skip to content

Commit

Permalink
Bug 1864029 [wpt PR 43058] - Add :user-valid test for programmaticall…
Browse files Browse the repository at this point in the history
…y setting value, a=testonly

Automatic update from web-platform-tests
Add :user-valid test for programmatically setting value

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}

--

wpt-commits: 06b33e5d2f85f2aef89949539819658426f5ddd0
wpt-pr: 43058
  • Loading branch information
josepharhar authored and moz-wptsync-bot committed Nov 22, 2023
1 parent 1f23693 commit 45bfcc9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions testing/web-platform/tests/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 testing/web-platform/tests/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 45bfcc9

Please sign in to comment.