Skip to content

Commit

Permalink
LibWeb: Fail CSS color parse for "rgba(123, 123, 123, "
Browse files Browse the repository at this point in the history
This matches the behavior of other browsers and fixes a WPT test.

(cherry picked from commit 902586a21de3ef8335e447053d82057c4c927d72;
amended expected output because serenity does not yet have
LadybirdBrowser/ladybird#1603)
  • Loading branch information
awesomekling authored and nico committed Nov 17, 2024
1 parent b71d94a commit eb800f3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#008000
#008000
12 changes: 12 additions & 0 deletions Tests/LibWeb/Text/input/canvas/fillStyle-bogus-rgba-color.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<script src="../include.js"></script>
<canvas id="c" width=300 height=300></canvas>
<script>
test(() => {
let x = c.getContext("2d");
x.fillStyle = 'green';
println(x.fillStyle);
x.fillStyle = 'rgba(255, 0, 0, ';
println(x.fillStyle);
c.remove();
});
</script>
3 changes: 3 additions & 0 deletions Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2851,6 +2851,9 @@ RefPtr<CSSStyleValue> Parser::parse_rgb_color_value(TokenStream<ComponentValue>&

alpha = parse_number_percentage_value(inner_tokens);

if (!alpha)
return {};

inner_tokens.skip_whitespace();

if (inner_tokens.has_next_token())
Expand Down

0 comments on commit eb800f3

Please sign in to comment.