Add WPT test for @font-face format() parsing issues.

I notice there's a lack of test coverage here, so before making changes I'd like to
add a simple set of tests so that we can see the effect of the upcoming fix.

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

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1784058
gecko-commit: 9398ed3c2567b8661d65293f94200ce787291a59
gecko-reviewers: emilio
diff --git a/css/css-fonts/parsing/font-face-src-format.html b/css/css-fonts/parsing/font-face-src-format.html
new file mode 100644
index 0000000..34ed5ec
--- /dev/null
+++ b/css/css-fonts/parsing/font-face-src-format.html
@@ -0,0 +1,59 @@
+<!DOCTYPE html>
+<title>CSS Fonts 4 test: parsing the format() function in the src descriptor</title>
+<link rel="help" href="https://drafts.csswg.org/css-fonts/#font-face-src-parsing">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<style id="testStyle">
+</style>
+<script>
+  const sheet = testStyle.sheet;
+  tests = [
+    // No format() function
+    { src: 'url("foo.ttf")', valid: true },
+    // Empty format() is not valid
+    { src: 'url("foo.ttf") format()', valid: false },
+    // Quoted strings in format()
+    { src: 'url("foo.ttf") format("collection")', valid: true },
+    { src: 'url("foo.ttf") format("embedded-opentype")', valid: true },
+    { src: 'url("foo.ttf") format("opentype")', valid: true },
+    { src: 'url("foo.ttf") format("svg")', valid: true },
+    { src: 'url("foo.ttf") format("truetype")', valid: true },
+    { src: 'url("foo.ttf") format("woff")', valid: true },
+    { src: 'url("foo.ttf") format("woff2")', valid: true },
+    // Multiple strings (was valid in CSS Fonts 3, but not allowed in Fonts 4)
+    { src: 'url("foo.ttf") format("opentype", "truetype")', valid: false },
+    // Unknown format string still matches the grammar, although it won't be loaded
+    { src: 'url("foo.ttf") format("xyzzy")', valid: true },
+    // Keywords (new in Fonts 4)
+    { src: 'url("foo.ttf") format(collection)', valid: true },
+    { src: 'url("foo.ttf") format(embedded-opentype)', valid: true },
+    { src: 'url("foo.ttf") format(opentype)', valid: true },
+    { src: 'url("foo.ttf") format(svg)', valid: true },
+    { src: 'url("foo.ttf") format(truetype)', valid: true },
+    { src: 'url("foo.ttf") format(woff)', valid: true },
+    { src: 'url("foo.ttf") format(woff2)', valid: true },
+    // Multiple keywords are not accepted
+    { src: 'url("foo.ttf") format(opentype, truetype)', valid: false },
+    { src: 'url("foo.ttf") format(opentype truetype)', valid: false },
+    // Invalid format keywords should be a parse error
+    { src: 'url("foo.ttf") format(auto)', valid: false },
+    { src: 'url("foo.ttf") format(default)', valid: false },
+    { src: 'url("foo.ttf") format(inherit)', valid: false },
+    { src: 'url("foo.ttf") format(initial)', valid: false },
+    { src: 'url("foo.ttf") format(none)', valid: false },
+    { src: 'url("foo.ttf") format(normal)', valid: false },
+    { src: 'url("foo.ttf") format(xyzzy)', valid: false },
+  ];
+
+  for (let t of tests) {
+    test(() => {
+      assert_equals(sheet.cssRules.length, 0, "testSheet should initially be empty");
+      sheet.insertRule("@font-face { src: " + t.src + "}");
+      try {
+        assert_equals(sheet.cssRules[0].style.getPropertyValue("src") != "", t.valid);
+      } finally {
+        sheet.deleteRule(0);
+      }
+    }, "Check that src: " + t.src + " is " + (t.valid ? "valid" : "invalid"));
+  }
+</script>