diff --git a/Libraries/LibWeb/CSS/FontFaceSet.cpp b/Libraries/LibWeb/CSS/FontFaceSet.cpp index de8ae8337f2..7dd907e4e42 100644 --- a/Libraries/LibWeb/CSS/FontFaceSet.cpp +++ b/Libraries/LibWeb/CSS/FontFaceSet.cpp @@ -175,12 +175,11 @@ static WebIDL::ExceptionOr> find_matching_font_faces(JS::Realm& { // 1. Parse font using the CSS value syntax of the font property. If a syntax error occurs, return a syntax error. auto property = parse_css_value(CSS::Parser::ParsingParams(), font, PropertyID::Font); - if (!property) + if (!property || !property->is_shorthand()) return WebIDL::SyntaxError::create(realm, "Unable to parse font"_string); // If the parsed value is a CSS-wide keyword, return a syntax error. - if (property->is_css_wide_keyword()) - return WebIDL::SyntaxError::create(realm, "Parsed font is a CSS-wide keyword"_string); + // Note: This case is already caught by the is_shorthand check. // FIXME: Absolutize all relative lengths against the initial values of the corresponding properties. (For example, a // relative font weight like bolder is evaluated against the initial value normal.) diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-font-loading/fontfaceset-load-var.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-font-loading/fontfaceset-load-var.txt new file mode 100644 index 00000000000..612ca8307f8 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-font-loading/fontfaceset-load-var.txt @@ -0,0 +1,9 @@ +Harness status: OK + +Found 4 tests + +4 Pass +Pass Loading "var(--x) serif" causes SyntaxError (document) +Pass Loading "var(--x, 10px) serif" causes SyntaxError (document) +Pass Loading "var(--x) serif" causes SyntaxError (worker) +Pass Loading "var(--x, 10px) serif" causes SyntaxError (worker) \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-font-loading/fontfaceset-load-var.html b/Tests/LibWeb/Text/input/wpt-import/css/css-font-loading/fontfaceset-load-var.html new file mode 100644 index 00000000000..87baf6c43b6 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/css/css-font-loading/fontfaceset-load-var.html @@ -0,0 +1,44 @@ + +SyntaxError thrown when matching loading values with var() + + + + +