Fix some :has() pseudo-element parsing tests.

The spec is pretty clear:

> The :has() pseudo-class cannot be nested; :has() is not valid within
> :has().

However recent resolution regarding forgiving selectors made these
serialize as-is, which turned the test into somewhat useless.

Test that :has() inside :is() doesn't have an effect.

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

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1855994
gecko-commit: 943079383c1b47c17119eb94ec678fa597d6b4cd
gecko-reviewers: dshin
diff --git a/css/selectors/parsing/parse-has-disallow-nesting-has-inside-has.html b/css/selectors/parsing/parse-has-disallow-nesting-has-inside-has.html
index c5fcb58..a633c91 100644
--- a/css/selectors/parsing/parse-has-disallow-nesting-has-inside-has.html
+++ b/css/selectors/parsing/parse-has-disallow-nesting-has-inside-has.html
@@ -8,6 +8,12 @@
 <script src="/css/support/parsing-testcommon.js"></script>
 <script>
   test_invalid_selector('.a:has(.b:has(.c))');
-  test_valid_selector('.a:has(:is(.b:has(.c)))');
-  test_valid_selector('.a:has(:is(.b:has(.c), .d))');
+  test(() => {
+    // It's not easy to check that these are invalid because :is() and :where()
+    // use forgiving parsing. Check that they never match instead.
+    assert_false(document.documentElement.matches(":has(:is(:has(*)))"));
+    assert_false(document.documentElement.matches(":has(:where(:has(*)))"));
+    assert_true(document.documentElement.matches(":has(:is(:has(*), script))"));
+    assert_true(document.documentElement.matches(":has(:where(:has(*), script))"));
+  })
 </script>
diff --git a/css/selectors/parsing/parse-has.html b/css/selectors/parsing/parse-has.html
index 902fc98..3492373 100644
--- a/css/selectors/parsing/parse-has.html
+++ b/css/selectors/parsing/parse-has.html
@@ -37,5 +37,5 @@
   test_invalid_selector(':has()');
   test_invalid_selector(':has(123)');
   test_invalid_selector(':has(.a, 123)');
-  test_valid_selector(':has(:is(.a, 123))');
+  test_valid_selector(':has(:is(.a, 123))', [':has(:is(.a, 123))', ':has(:is(.a))']);
 </script>