Check for 'revert-layer' in both versions of IsCSSWideKeyword.

This fixes the inconsistency between two overloads of IsCSSWideKeyword,
only one of which checked for 'revert-layer'.

The added test in
css/css-properties-values-api/register-property-syntax-parsing.html
fails without the change (OR without the existing codepath; it seems to
require both).

The added test that tests "medium revert-layer" in
css/css-font-loading/fontfaceset-load-css-wide-keywords.html is also
fixed by this change.  (The added test that tests only "revert-layer" is
unaffected; that's why I added the set testing with "medium " prefixed.)

Fixed: 1340993
Change-Id: I12e36c5b8db1e51647e1fcbfb904c8db8fe27a59
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3741078
Commit-Queue: David Baron <dbaron@chromium.org>
Reviewed-by: Xiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1021329}
diff --git a/css/css-font-loading/fontfaceset-load-css-wide-keywords.html b/css/css-font-loading/fontfaceset-load-css-wide-keywords.html
index b85b92b..b5716fb 100644
--- a/css/css-font-loading/fontfaceset-load-css-wide-keywords.html
+++ b/css/css-font-loading/fontfaceset-load-css-wide-keywords.html
@@ -25,36 +25,24 @@
     });
   }
 
-  promise_test(test => {
-    return promise_rejects_dom(test, 'SyntaxError', document.fonts.load('initial'));
-  }, 'Loading CSS-wide keyword "initial" causes SyntaxError (document)')
-
-  promise_test(test => {
-    return promise_rejects_dom(test, 'SyntaxError', document.fonts.load('inherit'));
-  }, 'Loading CSS-wide keyword "inherit" causes SyntaxError (document)')
-
-  promise_test(test => {
-    return promise_rejects_dom(test, 'SyntaxError', document.fonts.load('unset'));
-  }, 'Loading CSS-wide keyword "unset" causes SyntaxError (document)')
-
-  promise_test(test => {
-    return promise_rejects_dom(test, 'SyntaxError', document.fonts.load('revert'));
-  }, 'Loading CSS-wide keyword "revert" causes SyntaxError (document)')
-
-  promise_test(test => {
-    return promise_rejects_dom(test, 'SyntaxError', load_on_worker('initial'));
-  }, 'Loading CSS-wide keyword "initial" causes SyntaxError (worker)')
-
-  promise_test(test => {
-    return promise_rejects_dom(test, 'SyntaxError', load_on_worker('inherit'));
-  }, 'Loading CSS-wide keyword "inherit" causes SyntaxError (worker)')
-
-  promise_test(test => {
-    return promise_rejects_dom(test, 'SyntaxError', load_on_worker('unset'));
-  }, 'Loading CSS-wide keyword "unset" causes SyntaxError (worker)')
-
-  promise_test(test => {
-    return promise_rejects_dom(test, 'SyntaxError', load_on_worker('revert'));
-  }, 'Loading CSS-wide keyword "revert" causes SyntaxError (worker)')
+  // https://drafts.csswg.org/css-font-loading/#find-the-matching-font-faces
+  // forbids CSS-wide keywords as the value of the font given to the
+  // load method (equivalent to the font shorthand).  Note that the test
+  // for this case will also pass when the system-wide keyword simply
+  // isn't supported, since the syntax won't be valid syntax for the
+  // 'font' shorthand.
+  // https://drafts.csswg.org/css-fonts-4/#family-name-syntax also
+  // forbids using the CSS-wide keywords as unquoted keywords within
+  // <font-family>.
+  for (let [description_prefix, syntax_prefix] of [["", ""], ["value with ", "medium "]]) {
+    for (let keyword of ["initial", "inherit", "unset", "default", "revert", "revert-layer"]) {
+      promise_test(test => {
+        return promise_rejects_dom(test, 'SyntaxError', document.fonts.load(`${syntax_prefix}${keyword}`));
+      }, `Loading ${description_prefix}CSS-wide keyword "${keyword}" causes SyntaxError (document)`)
+      promise_test(test => {
+        return promise_rejects_dom(test, 'SyntaxError', load_on_worker(`${syntax_prefix}${keyword}`));
+      }, `Loading ${description_prefix}CSS-wide keyword "${keyword}" causes SyntaxError (worker)`)
+    }
+  }
 
 </script>
diff --git a/css/css-properties-values-api/register-property-syntax-parsing.html b/css/css-properties-values-api/register-property-syntax-parsing.html
index 31094d2..ee3ebc8 100644
--- a/css/css-properties-values-api/register-property-syntax-parsing.html
+++ b/css/css-properties-values-api/register-property-syntax-parsing.html
@@ -157,16 +157,19 @@
 assert_invalid("*", "inherit");
 assert_invalid("*", "unset");
 assert_invalid("*", "revert");
+assert_invalid("*", "revert-layer");
 assert_invalid("*", "default");
 assert_invalid("<custom-ident>", "initial");
 assert_invalid("<custom-ident>", "inherit");
 assert_invalid("<custom-ident>", "unset");
 assert_invalid("<custom-ident>", "revert");
+assert_invalid("<custom-ident>", "revert-layer");
 assert_invalid("<custom-ident>", "default");
 assert_invalid("<custom-ident>+", "foo initial bar");
 assert_invalid("<custom-ident>+", "foo inherit bar");
 assert_invalid("<custom-ident>+", "foo unset bar");
 assert_invalid("<custom-ident>+", "foo revert bar");
+assert_invalid("<custom-ident>+", "foo revert-layer bar");
 assert_invalid("<custom-ident>+", "foo default bar");
 
 assert_invalid("*", ")");