diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/html/canvas/element/wide-gamut-canvas | |
parent | Initial commit. (diff) | |
download | firefox-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/html/canvas/element/wide-gamut-canvas')
10 files changed, 505 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.fillText.html b/testing/web-platform/tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.fillText.html new file mode 100644 index 0000000000..9c3d1b3374 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.fillText.html @@ -0,0 +1,58 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: 2d.color.space.p3.fillText</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.color.space.p3.fillText</h1> +<p class="desc">Test if fillText can be used with a solid display-p3 color</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 if fillText can be used with a solid display-p3 color"); +_addTest(function(canvas, ctx) { + + deferTest(); + + const fullRedInP3 = [255, 0, 0, 255]; + const sRGBRedInP3 = [234, 51, 35, 255]; + + canvas.width = 100; + canvas.height = 100; + + let f = new FontFace("Ahem", "url(/fonts/Ahem.ttf)"); + document.fonts.add(f); + f.load().then(function() { + t.step(function() { + ctx.font = "40px Ahem"; + + ctx.fillStyle = "#f00"; + ctx.fillText("A", 0, 50); + + ctx.fillStyle = "black"; + ctx.fillStyle = "color(display-p3 100% 0 0)"; + ctx.fillText("A", 50, 50); + + let pixels = ctx.getImageData(0, 0, canvas.width, canvas.height, { colorSpace: "display-p3" }).data; + let pixelAt = function(x, y) { + let offset = (y * canvas.width + x) * 4; + return [pixels[offset], pixels[offset + 1], pixels[offset + 2], pixels[offset + 3]]; + }; + + assert_array_equals(pixelAt(25, 25), sRGBRedInP3); + assert_array_equals(pixelAt(75, 25), fullRedInP3); + + t.done(); + }); + }); + +}, {colorSpace: "display-p3"}); +</script> + diff --git a/testing/web-platform/tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.fillText.shadow.html b/testing/web-platform/tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.fillText.shadow.html new file mode 100644 index 0000000000..cc459fb2cd --- /dev/null +++ b/testing/web-platform/tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.fillText.shadow.html @@ -0,0 +1,62 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: 2d.color.space.p3.fillText.shadow</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.color.space.p3.fillText.shadow</h1> +<p class="desc">Test if fillText can be used with a display-p3 shadow color</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 if fillText can be used with a display-p3 shadow color"); +_addTest(function(canvas, ctx) { + + deferTest(); + + const fullRedInP3 = [255, 0, 0, 255]; + const sRGBRedInP3 = [234, 51, 35, 255]; + + canvas.width = 100; + canvas.height = 100; + + let f = new FontFace("Ahem", "url(/fonts/Ahem.ttf)"); + document.fonts.add(f); + f.load().then(function() { + t.step(function() { + ctx.font = "40px Ahem"; + + ctx.fillStyle = "black"; + ctx.shadowBlur = 4; + ctx.shadowOffsetX = 0; + ctx.shadowOffsetY = 50; + ctx.shadowColor = "#f00"; + ctx.fillText("A", 0, 0); + + ctx.shadowColor = "black"; + ctx.shadowColor = "color(display-p3 100% 0 0)"; + ctx.fillText("A", 50, 0); + + let pixels = ctx.getImageData(0, 0, canvas.width, canvas.height, { colorSpace: "display-p3" }).data; + let pixelAt = function(x, y) { + let offset = (y * canvas.width + x) * 4; + return [pixels[offset], pixels[offset + 1], pixels[offset + 2], pixels[offset + 3]]; + }; + + assert_array_equals(pixelAt(25, 25), sRGBRedInP3); + assert_array_equals(pixelAt(75, 25), fullRedInP3); + + t.done(); + }); + }); + +}, {colorSpace: "display-p3"}); +</script> + diff --git a/testing/web-platform/tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.strokeText.html b/testing/web-platform/tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.strokeText.html new file mode 100644 index 0000000000..626a41b49b --- /dev/null +++ b/testing/web-platform/tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.strokeText.html @@ -0,0 +1,59 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: 2d.color.space.p3.strokeText</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.color.space.p3.strokeText</h1> +<p class="desc">Test if strokeText can be used with a solid display-p3 color</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 if strokeText can be used with a solid display-p3 color"); +_addTest(function(canvas, ctx) { + + deferTest(); + + const fullRedInP3 = [255, 0, 0, 255]; + const sRGBRedInP3 = [234, 51, 35, 255]; + + canvas.width = 100; + canvas.height = 100; + + let f = new FontFace("Ahem", "url(/fonts/Ahem.ttf)"); + document.fonts.add(f); + f.load().then(function() { + t.step(function() { + ctx.font = "40px Ahem"; + + ctx.strokeStyle = "#f00"; + ctx.lineWidth = 20; + ctx.strokeText("A", 0, 50); + + ctx.strokeStyle = "black"; + ctx.strokeStyle = "color(display-p3 100% 0 0)"; + ctx.strokeText("A", 50, 50); + + let pixels = ctx.getImageData(0, 0, canvas.width, canvas.height, { colorSpace: "display-p3" }).data; + let pixelAt = function(x, y) { + let offset = (y * canvas.width + x) * 4; + return [pixels[offset], pixels[offset + 1], pixels[offset + 2], pixels[offset + 3]]; + }; + + assert_array_equals(pixelAt(25, 25), sRGBRedInP3); + assert_array_equals(pixelAt(75, 25), fullRedInP3); + + t.done(); + }); + }); + +}, {colorSpace: "display-p3"}); +</script> + diff --git a/testing/web-platform/tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.to.p3.html b/testing/web-platform/tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.to.p3.html new file mode 100644 index 0000000000..a03f49740f --- /dev/null +++ b/testing/web-platform/tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.to.p3.html @@ -0,0 +1,38 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: 2d.color.space.p3.to.p3</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.color.space.p3.to.p3</h1> +<p class="desc">test getImageData with display-p3 and uint8 from display p3 uint8 canvas</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 getImageData with display-p3 and uint8 from display p3 uint8 canvas"); +_addTest(function(canvas, ctx) { + + var color_style = 'rgb(50, 100, 150)'; + // [0.24304, 0.38818, 0.57227, 1.0] * 255 = [62, 99, 146, 255] + var pixel_expected = [62, 99, 146, 255]; + var epsilon = 2; + ctx.fillStyle = color_style; + ctx.fillRect(0, 0, 10, 10); + + var pixel = ctx.getImageData(5, 5, 1, 1, {colorSpace: "display-p3", storageFormat: "uint8"}).data; + _assertSame(pixel.length, pixel_expected.length, "pixel.length", "pixel_expected.length"); + assert_approx_equals(pixel[0], pixel_expected[0], 2); + assert_approx_equals(pixel[1], pixel_expected[1], 2); + assert_approx_equals(pixel[2], pixel_expected[2], 2); + assert_approx_equals(pixel[3], pixel_expected[3], 2); + +}, {colorSpace: "display-p3"}); +</script> + diff --git a/testing/web-platform/tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.to.srgb.html b/testing/web-platform/tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.to.srgb.html new file mode 100644 index 0000000000..0433ae38c7 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.to.srgb.html @@ -0,0 +1,37 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: 2d.color.space.p3.to.srgb</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.color.space.p3.to.srgb</h1> +<p class="desc">test getImageData with srsb and uint8 from display p3 uint8 canvas</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 getImageData with srsb and uint8 from display p3 uint8 canvas"); +_addTest(function(canvas, ctx) { + + var color_style = 'rgb(50, 100, 150)'; + var pixel_expected = [50, 100, 150, 255]; + var epsilon = 2; + ctx.fillStyle = color_style; + ctx.fillRect(0, 0, 10, 10); + + var pixel = ctx.getImageData(5, 5, 1, 1, {colorSpace: "srgb", storageFormat: "uint8"}).data; + _assertSame(pixel.length, pixel_expected.length, "pixel.length", "pixel_expected.length"); + assert_approx_equals(pixel[0], pixel_expected[0], 2); + assert_approx_equals(pixel[1], pixel_expected[1], 2); + assert_approx_equals(pixel[2], pixel_expected[2], 2); + assert_approx_equals(pixel[3], pixel_expected[3], 2); + +}, {colorSpace: "display-p3"}); +</script> + diff --git a/testing/web-platform/tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.toBlob.p3.canvas.html b/testing/web-platform/tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.toBlob.p3.canvas.html new file mode 100644 index 0000000000..1a44af20a6 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.toBlob.p3.canvas.html @@ -0,0 +1,50 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: 2d.color.space.p3.toBlob.p3.canvas</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.color.space.p3.toBlob.p3.canvas</h1> +<p class="desc">test if toblob returns p3 data from p3 color space canvas</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 if toblob returns p3 data from p3 color space canvas"); +_addTest(function(canvas, ctx) { + + ctx.fillStyle = "rgba(155, 27, 27, 1)"; + ctx.fillRect(0, 0, 1, 1); + ctx.fillStyle = "rgba(27, 155, 27, 0)"; + ctx.fillRect(1, 0, 1, 1); + ctx.fillStyle = "rgba(27, 27, 155, 0.5)"; + ctx.fillRect(0, 1, 1, 1); + ctx.fillStyle = "rgba(27, 27, 27, 0.5)"; + ctx.fillRect(1, 1, 1, 1); + expectedPixels = ctx.getImageData(0, 0, 2, 2, {colorSpace: "display-p3"}).data; + + var image = new Image(); + image.onload = t.step_func_done(function() { + var dstCanvas = document.createElement("canvas"); + dstCanvas.width = 2; + dstCanvas.height = 2; + var ctx = dstCanvas.getContext('2d', {colorSpace: "display-p3"}); + ctx.drawImage(image, 0, 0); + var actualPixels = ctx.getImageData(0, 0, 2, 2, {colorSpace: "display-p3"}).data; + assert_array_approx_equals(actualPixels, expectedPixels, 2); + }); + + canvas.toBlob(function(blob) { + var urlCreator = window.URL || window.webkitURL; + image.src = urlCreator.createObjectURL(blob); + }, 'image/png', 1); + +}, {colorSpace: "display-p3"}); +</script> + diff --git a/testing/web-platform/tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.toBlob.with.putImageData.html b/testing/web-platform/tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.toBlob.with.putImageData.html new file mode 100644 index 0000000000..a53de72259 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.toBlob.with.putImageData.html @@ -0,0 +1,56 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: 2d.color.space.p3.toBlob.with.putImageData</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.color.space.p3.toBlob.with.putImageData</h1> +<p class="desc">Use putImageData to put some p3 data in canvas and test if toBlob returns the same data</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("Use putImageData to put some p3 data in canvas and test if toBlob returns the same data"); +_addTest(function(canvas, ctx) { + + canvas.width = 2; + canvas.height = 2; + + // Create an ImageData using createImageData and populate its data array. + var image_data = ctx.createImageData(canvas.width, canvas.height, {colorSpace: "display-p3"}); + var color_data = [[255, 100, 150, 1.0], [255, 100, 150, 0.5], + [255, 100, 150, 0.5], [255, 100, 150, 0]]; + var data = image_data.data; + for (var i = 0; i < data.length / 4; ++i) { + data[4*i + 0] = color_data[i][0]; + data[4*i + 1] = color_data[i][1]; + data[4*i + 2] = color_data[i][2]; + data[4*i + 3] = color_data[i][3]; + } + ctx.putImageData(image_data, 0, 0); + expectedPixels = ctx.getImageData(0, 0, 2, 2, {colorSpace: "display-p3"}).data; + + var image = new Image(); + image.onload = t.step_func_done(function() { + var dstCanvas = document.createElement("canvas"); + dstCanvas.width = 2; + dstCanvas.height = 2; + var ctx = dstCanvas.getContext('2d', {colorSpace: "display-p3"}); + ctx.drawImage(image, 0, 0); + var actualPixels = ctx.getImageData(0, 0, 2, 2, {colorSpace: "display-p3"}).data; + assert_array_approx_equals(actualPixels, expectedPixels, 2); + }); + canvas.toBlob(function(blob) { + var urlCreator = window.URL || window.webkitURL; + image.src = urlCreator.createObjectURL(blob); + }, 'image/png', 1); + +}, {colorSpace: "display-p3"}); +</script> + diff --git a/testing/web-platform/tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.toDataURL.jpeg.p3.canvas.html b/testing/web-platform/tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.toDataURL.jpeg.p3.canvas.html new file mode 100644 index 0000000000..e0986cb8e8 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.toDataURL.jpeg.p3.canvas.html @@ -0,0 +1,46 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: 2d.color.space.p3.toDataURL.jpeg.p3.canvas</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.color.space.p3.toDataURL.jpeg.p3.canvas</h1> +<p class="desc">test if toDataURL('image/jpeg') returns p3 data from canvas with p3 color space</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 if toDataURL('image/jpeg') returns p3 data from canvas with p3 color space"); +_addTest(function(canvas, ctx) { + + ctx.fillStyle = "rgba(155, 27, 27, 1)"; + ctx.fillRect(0, 0, 1, 1); + ctx.fillStyle = "rgba(27, 155, 27, 0)"; + ctx.fillRect(1, 0, 1, 1); + ctx.fillStyle = "rgba(27, 27, 155, 0.5)"; + ctx.fillRect(0, 1, 1, 1); + ctx.fillStyle = "rgba(27, 27, 27, 0.5)"; + ctx.fillRect(1, 1, 1, 1); + expectedPixels = ctx.getImageData(0, 0, 2, 2, {colorSpace: "display-p3"}).data; + + var image = new Image(); + image.onload = t.step_func_done(function() { + var dstCanvas = document.createElement("canvas"); + dstCanvas.width = 2; + dstCanvas.height = 2; + var ctx = dstCanvas.getContext('2d', {colorSpace: "display-p3"}); + ctx.drawImage(image, 0, 0); + var actualPixels = ctx.getImageData(0, 0, 2, 2, {colorSpace: "display-p3"}).data; + assert_array_approx_equals(actualPixels, expectedPixels, 2); + }); + image.src = canvas.toDataURL("image/jpeg"); + +}, {colorSpace: "display-p3"}); +</script> + diff --git a/testing/web-platform/tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.toDataURL.p3.canvas.html b/testing/web-platform/tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.toDataURL.p3.canvas.html new file mode 100644 index 0000000000..94ba703980 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.toDataURL.p3.canvas.html @@ -0,0 +1,46 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: 2d.color.space.p3.toDataURL.p3.canvas</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.color.space.p3.toDataURL.p3.canvas</h1> +<p class="desc">test if toDataURL returns p3 data from canvas with p3 color space</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 if toDataURL returns p3 data from canvas with p3 color space"); +_addTest(function(canvas, ctx) { + + ctx.fillStyle = "rgba(155, 27, 27, 1)"; + ctx.fillRect(0, 0, 1, 1); + ctx.fillStyle = "rgba(27, 155, 27, 0)"; + ctx.fillRect(1, 0, 1, 1); + ctx.fillStyle = "rgba(27, 27, 155, 0.5)"; + ctx.fillRect(0, 1, 1, 1); + ctx.fillStyle = "rgba(27, 27, 27, 0.5)"; + ctx.fillRect(1, 1, 1, 1); + expectedPixels = ctx.getImageData(0, 0, 2, 2, {colorSpace: "display-p3"}).data; + + var image = new Image(); + image.onload = t.step_func_done(function() { + var dstCanvas = document.createElement("canvas"); + dstCanvas.width = 2; + dstCanvas.height = 2; + var ctx = dstCanvas.getContext('2d', {colorSpace: "display-p3"}); + ctx.drawImage(image, 0, 0); + var actualPixels = ctx.getImageData(0, 0, 2, 2, {colorSpace: "display-p3"}).data; + assert_array_approx_equals(actualPixels, expectedPixels, 2); + }); + image.src = canvas.toDataURL(); + +}, {colorSpace: "display-p3"}); +</script> + diff --git a/testing/web-platform/tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.toDataURL.with.putImageData.html b/testing/web-platform/tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.toDataURL.with.putImageData.html new file mode 100644 index 0000000000..58d0718eba --- /dev/null +++ b/testing/web-platform/tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.toDataURL.with.putImageData.html @@ -0,0 +1,53 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: 2d.color.space.p3.toDataURL.with.putImageData</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.color.space.p3.toDataURL.with.putImageData</h1> +<p class="desc">Use putImageData to put some p3 data in canvas and test if toDataURL returns the same data</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("Use putImageData to put some p3 data in canvas and test if toDataURL returns the same data"); +_addTest(function(canvas, ctx) { + + canvas.width = 2; + canvas.height = 2; + + // Create an ImageData using createImageData and populate its data array. + var image_data = ctx.createImageData(canvas.width, canvas.height, {colorSpace: "display-p3"}); + var color_data = [[255, 100, 150, 1.0], [255, 100, 150, 0.5], + [255, 100, 150, 0.5], [255, 100, 150, 0]]; + var data = image_data.data; + for (var i = 0; i < data.length / 4; ++i) { + data[4*i + 0] = color_data[i][0]; + data[4*i + 1] = color_data[i][1]; + data[4*i + 2] = color_data[i][2]; + data[4*i + 3] = color_data[i][3]; + } + ctx.putImageData(image_data, 0, 0); + expectedPixels = ctx.getImageData(0, 0, 2, 2, {colorSpace: "display-p3"}).data; + + var image = new Image(); + image.onload = t.step_func_done(function() { + var dstCanvas = document.createElement("canvas"); + dstCanvas.width = 2; + dstCanvas.height = 2; + var ctx = dstCanvas.getContext('2d', {colorSpace: "display-p3"}); + ctx.drawImage(image, 0, 0); + var actualPixels = ctx.getImageData(0, 0, 2, 2, {colorSpace: "display-p3"}).data; + assert_array_approx_equals(actualPixels, expectedPixels, 2); + }); + image.src = canvas.toDataURL(); + +}, {colorSpace: "display-p3"}); +</script> + |