mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 12:49:19 +00:00
Tests/LibWeb: Import a PNG and CICP related test
I had to manually import the png file as the import script is unable to find resources from within the javascript code.
This commit is contained in:
parent
03a058ba5e
commit
7197d78ea3
Notes:
github-actions[bot]
2025-02-25 21:38:24 +00:00
Author: https://github.com/LucasChollet
Commit: 7197d78ea3
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3698
Reviewed-by: https://github.com/gmta ✅
3 changed files with 46 additions and 0 deletions
6
Tests/LibWeb/Text/expected/wpt-import/png/cicp-chunk.txt
Normal file
6
Tests/LibWeb/Text/expected/wpt-import/png/cicp-chunk.txt
Normal file
|
@ -0,0 +1,6 @@
|
|||
Harness status: OK
|
||||
|
||||
Found 1 tests
|
||||
|
||||
1 Pass
|
||||
Pass test pixel values of a display-p3 PNG
|
40
Tests/LibWeb/Text/input/wpt-import/png/cicp-chunk.html
Normal file
40
Tests/LibWeb/Text/input/wpt-import/png/cicp-chunk.html
Normal file
|
@ -0,0 +1,40 @@
|
|||
<!DOCTYPE html>
|
||||
<title>PNG test: cICP chunk</title>
|
||||
<link rel="help" href="https://w3c.github.io/PNG-spec/#cICP-chunk">
|
||||
<script src="../resources/testharness.js"></script>
|
||||
<script src="../resources/testharnessreport.js"></script>
|
||||
<script src="../html/canvas/resources/canvas-tests.js"></script>
|
||||
<body>
|
||||
|
||||
<h1>cICP chunk</h1>
|
||||
<p class="desc">test pixel values of a display-p3 PNG</p>
|
||||
|
||||
<p class="output">Actual output:</p>
|
||||
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
|
||||
|
||||
<ul id="d"></ul>
|
||||
<script>
|
||||
var t = async_test("test pixel values of a display-p3 PNG");
|
||||
const img = new Image();
|
||||
img.onload = () => {
|
||||
_addTest(function(canvas, ctx) {
|
||||
ctx.drawImage(img, 0, 0);
|
||||
|
||||
var pixel = ctx.getImageData(5, 5, 1, 1, {colorSpace: "srgb"}).data;
|
||||
|
||||
// The pixel values stored are (51 red, 102 green, 153 blue).
|
||||
// These numbers are chosen because 0.2 * 255 = 51.
|
||||
// The image has a cICP chunk indicating the Display P3 color space.
|
||||
// This results in decoded pixel values of (27 red, 104 green, 157 blue).
|
||||
const pixel_expected = [27, 104, 157, 255];
|
||||
const epsilon = 2;
|
||||
|
||||
_assertSame(pixel.length, pixel_expected.length, "pixel.length", "pixel_expected.length");
|
||||
assert_approx_equals(pixel[0], pixel_expected[0], epsilon);
|
||||
assert_approx_equals(pixel[1], pixel_expected[1], epsilon);
|
||||
assert_approx_equals(pixel[2], pixel_expected[2], epsilon);
|
||||
assert_approx_equals(pixel[3], pixel_expected[3], epsilon);
|
||||
}, {colorSpace: "display-p3"});
|
||||
};
|
||||
img.src = "support/cicp-display-p3.png";
|
||||
</script>
|
Binary file not shown.
After Width: | Height: | Size: 143 B |
Loading…
Add table
Add a link
Reference in a new issue