mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-01 23:26:36 +00:00
LibWeb: Check CanvasTextDrawingStyles.font assignment is valid
Checking that the string parsed for the `font` property is not enough, the spec also wants to rule out CSS-wide keywords like `inherit`. The simplest way to do so is to check if it's a ShorthandStyleValue, which also rules out use of `var()`; this matches other browsers' behaviour. The newly-added test would previously crash, and now doesn't. :^)
This commit is contained in:
parent
54066ec5a4
commit
64d45afd8a
Notes:
github-actions[bot]
2024-07-23 16:01:08 +00:00
Author: https://github.com/AtkinsSJ
Commit: 64d45afd8a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/791
3 changed files with 23 additions and 1 deletions
15
Tests/LibWeb/Text/input/canvas/invalid-font-property.html
Normal file
15
Tests/LibWeb/Text/input/canvas/invalid-font-property.html
Normal file
|
@ -0,0 +1,15 @@
|
|||
<script src="../include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
let canvas = document.createElement("canvas");
|
||||
let context = canvas.getContext("2d");
|
||||
context.font = '20px SerenitySans';
|
||||
println(context.font);
|
||||
context.font = 'inherit'; // CSS-wide keywords are not allowed
|
||||
println(context.font);
|
||||
context.font = 'var(--font-size, 30px) Arial'; // Variables are not allowed here
|
||||
println(context.font);
|
||||
context.font = '!!!'; // Invalid value, should be ignored.
|
||||
println(context.font);
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue