<!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>

