summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/png
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/png
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/png')
-rw-r--r--testing/web-platform/tests/png/META.yml4
-rw-r--r--testing/web-platform/tests/png/cicp-chunk.html40
-rw-r--r--testing/web-platform/tests/png/support/cicp-display-p3.pngbin0 -> 143 bytes
-rw-r--r--testing/web-platform/tests/png/support/trns-high-bits-set.pngbin0 -> 205 bytes
-rw-r--r--testing/web-platform/tests/png/trns-chunk.html37
5 files changed, 81 insertions, 0 deletions
diff --git a/testing/web-platform/tests/png/META.yml b/testing/web-platform/tests/png/META.yml
new file mode 100644
index 0000000000..da174ac614
--- /dev/null
+++ b/testing/web-platform/tests/png/META.yml
@@ -0,0 +1,4 @@
+spec: https://www.w3.org/TR/png/
+suggested_reviewers:
+ - programmax
+ - svgeesus
diff --git a/testing/web-platform/tests/png/cicp-chunk.html b/testing/web-platform/tests/png/cicp-chunk.html
new file mode 100644
index 0000000000..8add5d602e
--- /dev/null
+++ b/testing/web-platform/tests/png/cicp-chunk.html
@@ -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", storageFormat: "uint8"}).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>
diff --git a/testing/web-platform/tests/png/support/cicp-display-p3.png b/testing/web-platform/tests/png/support/cicp-display-p3.png
new file mode 100644
index 0000000000..8fa0ce2123
--- /dev/null
+++ b/testing/web-platform/tests/png/support/cicp-display-p3.png
Binary files differ
diff --git a/testing/web-platform/tests/png/support/trns-high-bits-set.png b/testing/web-platform/tests/png/support/trns-high-bits-set.png
new file mode 100644
index 0000000000..4e309a89a8
--- /dev/null
+++ b/testing/web-platform/tests/png/support/trns-high-bits-set.png
Binary files differ
diff --git a/testing/web-platform/tests/png/trns-chunk.html b/testing/web-platform/tests/png/trns-chunk.html
new file mode 100644
index 0000000000..3a24753382
--- /dev/null
+++ b/testing/web-platform/tests/png/trns-chunk.html
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<title>PNG test: tRNS chunk</title>
+<link rel="help" href="https://w3c.github.io/PNG-spec/#11tRNS">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/html/canvas/resources/canvas-tests.js"></script>
+<body>
+
+<h1>tRNS chunk handling</h1>
+<p class="desc">test ignored high bits on lower bit depth tRNS</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 ignored high bits on lower bit depth tRNS");
+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", storageFormat: "uint8"}).data;
+
+ const pixel_expected = [255, 0, 0, 0];
+ const epsilon = 2;
+
+ _assertSame(pixel.length, pixel_expected.length, "pixel.length", "pixel_expected.length");
+ // Ignore the color channel comparisons.
+ // The image itself stores 255 red, 0 green, 0 blue.
+ // But there may not be a requirement that this be preserved
+ // while decoding or through canvas processing.
+ assert_approx_equals(pixel[3], pixel_expected[3], epsilon);
+ });
+};
+img.src = "support/trns-high-bits-set.png";
+</script>