1
0
mirror of https://github.com/SerenityOS/serenity synced 2024-07-03 10:13:39 +00:00

Tests/LibWeb: Add test to verify correctness of getImageData

(cherry picked from commit dbc94ce92e09e987f8a07a5b1e978250286b015a)
This commit is contained in:
circl 2024-06-14 15:22:25 +02:00 committed by Nico Weber
parent ec7d44d635
commit 462abc242e
2 changed files with 21 additions and 0 deletions

View File

@ -0,0 +1,20 @@
<script src="../include.js"></script>
<script>
test(() => {
let area = document.createElement("canvas");
let areaCtx = area.getContext("2d");
area.width = 1;
area.height = 1;
areaCtx.fillStyle = "#ff8040";
areaCtx.fillRect(0, 0, 1, 1);
let imageData = areaCtx.getImageData(0, 0, area.width, area.height);
if (imageData.data[0] == 0xff && imageData.data[1] == 0x80 && imageData.data[2] == 0x40)
println("PASS");
else
println("FAIL");
});
</script>