diff options
Diffstat (limited to 'testing/web-platform/tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.toBlob.p3.canvas.html')
-rw-r--r-- | testing/web-platform/tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.toBlob.p3.canvas.html | 50 |
1 files changed, 50 insertions, 0 deletions
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> + |