// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
// OffscreenCanvas test in a worker:2d.imageData.put.basic.rgba.float16
// Description:putImageData() puts 16-bit floating point image data from getImageData() onto the canvas
// Note:

importScripts("/resources/testharness.js");
importScripts("/html/canvas/resources/canvas-tests.js");

var t = async_test("putImageData() puts 16-bit floating point image data from getImageData() onto the canvas");
var t_pass = t.done.bind(t);
var t_fail = t.step_func(function(reason) {
    throw reason;
});
t.step(function() {

  var canvas = new OffscreenCanvas(100, 50);
  var ctx = canvas.getContext('2d', {colorSpace: "srgb", colorType: "float16"});

  ctx.fillStyle = 'color(display-p3 1 0 0)';
  ctx.fillRect(0, 0, 100, 50)
  var imgdata = ctx.getImageData(0, 0, 100, 50, {colorSpace:"srgb", pixelFormat:"rgba-float16"});
  ctx.fillStyle = '#f00';
  ctx.fillRect(0, 0, 100, 50)
  ctx.putImageData(imgdata, 0, 0);
  var pixel = ctx.getImageData(0, 0, 1, 1, {colorSpace:"display-p3", pixelFormat:"rgba-float16"});
  assert_approx_equals(pixel.data[0], 1, 0.01);
  assert_approx_equals(pixel.data[1], 0, 0.01);
  assert_approx_equals(pixel.data[2], 0, 0.01);
  assert_approx_equals(pixel.data[3], 1, 0.01);
  t.done();
});
done();
