Implement :user-valid and :user-invalid.

And alias :-moz-ui-valid and :-moz-ui-invalid to them.

There are CSSWG resolutions for these for quite a while, and spec for
user-invalid.

Differential Revision: https://phabricator.services.mozilla.com/D105966

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1694141
gecko-commit: 05e013ea94bfa78102ec3ed7a7aa55ae14a0b323
gecko-reviewers: xidorn
diff --git a/css/selectors/user-invalid.html b/css/selectors/user-invalid.html
index 05cf2b6..1f3ad22 100644
--- a/css/selectors/user-invalid.html
+++ b/css/selectors/user-invalid.html
@@ -3,10 +3,11 @@
 <link rel="help" href="https://drafts.csswg.org/selectors/#user-pseudos">
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
-<input>
+<input value="bar" pattern="foo">
 <script>
 test(() => {
   const input = document.querySelector('input');
+  assert_false(input.validity.valid, "Should be invalid");
   // The selector can't match because no interaction has happened.
   assert_false(input.matches(':user-invalid'));
 }, ':user-invalid selector should be supported');
diff --git a/css/selectors/user-valid.html b/css/selectors/user-valid.html
new file mode 100644
index 0000000..36ca7af
--- /dev/null
+++ b/css/selectors/user-valid.html
@@ -0,0 +1,14 @@
+<!doctype html>
+<title>Support for the :user-valid pseudo-class</title>
+<link rel="help" href="https://drafts.csswg.org/selectors/#user-pseudos">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<input>
+<script>
+test(() => {
+  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'));
+}, ':user-valid selector should be supported');
+</script>