ladybird/Tests/LibWeb/Screenshot/input/canvas-text.html
Jelle Raaijmakers 59a867d3e3
Some checks are pending
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Tests: Enable all screenshot tests on all platforms
With the newly supported fuzzy matching in our test-web runner, we can
now define the expected maximum color channel and pixel count errors per
failing test and set a baseline they should not exceed.

The figures I added to these tests all come from my macOS M4 machine.
Most discrepancies seem to come from color calculations being slightly
off.
2025-07-17 12:59:11 +01:00

48 lines
1.2 KiB
HTML

<!DOCTYPE html>
<link rel="match" href="../expected/canvas-text-ref.html" />
<meta name="fuzzy" content="maxDifference=0-1;totalPixels=0-563">
<html>
<head>
<style>
canvas {
border: 1px solid black;
image-rendering: pixelated;
}
</style>
</head>
<body>
<script>
const canvas = document.createElement("canvas");
canvas.width = 600;
canvas.height = 280;
document.body.appendChild(canvas);
const ctx = canvas.getContext("2d");
ctx.font = "48px serif";
ctx.save();
ctx.translate(20, 250);
ctx.rotate(-Math.PI*0.2);
ctx.fillText("Rotated Text!", 10, 40);
ctx.restore();
ctx.strokeText("Stroke Text!", 10, 50);
const gradient = ctx.createLinearGradient(280, 20, 580, 120);
gradient.addColorStop(0,"red");
gradient.addColorStop(0.15,"yellow");
gradient.addColorStop(0.3,"green");
gradient.addColorStop(0.45,"aqua");
gradient.addColorStop(0.6,"blue");
gradient.addColorStop(0.7,"fuchsia");
gradient.addColorStop(1,"red");
ctx.fillStyle = gradient;
ctx.fillText("Gradient Text!", 260, 150);
ctx.fillStyle = "red";
ctx.fillText("Squished Text", 50, 120, 100);
</script>
</body>
</html>