summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/png/trns-chunk.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/png/trns-chunk.html
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/png/trns-chunk.html')
-rw-r--r--testing/web-platform/tests/png/trns-chunk.html37
1 files changed, 37 insertions, 0 deletions
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>