diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation')
100 files changed, 3636 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create1.basic.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create1.basic.html new file mode 100644 index 0000000000..24d9a77405 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create1.basic.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.create1.basic</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.create1.basic</h1> +<p class="desc">createImageData(imgdata) exists and returns something</p> + + +<script> +var t = async_test("createImageData(imgdata) exists and returns something"); +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'); + +_assertDifferent(ctx.createImageData(ctx.createImageData(1, 1)), null, "ctx.createImageData(ctx.createImageData(1, 1))", "null"); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create1.basic.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create1.basic.worker.js new file mode 100644 index 0000000000..54d2cadb1c --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create1.basic.worker.js @@ -0,0 +1,23 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.create1.basic +// Description:createImageData(imgdata) exists and returns something +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("createImageData(imgdata) exists and returns something"); +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'); + +_assertDifferent(ctx.createImageData(ctx.createImageData(1, 1)), null, "ctx.createImageData(ctx.createImageData(1, 1))", "null"); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create1.initial.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create1.initial.html new file mode 100644 index 0000000000..658ae83b56 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create1.initial.html @@ -0,0 +1,38 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.create1.initial</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.create1.initial</h1> +<p class="desc">createImageData(imgdata) returns transparent black data of the right size</p> + + +<script> +var t = async_test("createImageData(imgdata) returns transparent black data of the right size"); +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'); + +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50); +var imgdata1 = ctx.getImageData(0, 0, 10, 20); +var imgdata2 = ctx.createImageData(imgdata1); +_assertSame(imgdata2.data.length, imgdata1.data.length, "imgdata2.data.length", "imgdata1.data.length"); +_assertSame(imgdata2.width, imgdata1.width, "imgdata2.width", "imgdata1.width"); +_assertSame(imgdata2.height, imgdata1.height, "imgdata2.height", "imgdata1.height"); +var isTransparentBlack = true; +for (var i = 0; i < imgdata2.data.length; ++i) + if (imgdata2.data[i] !== 0) + isTransparentBlack = false; +_assert(isTransparentBlack, "isTransparentBlack"); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create1.initial.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create1.initial.worker.js new file mode 100644 index 0000000000..bfff76b29f --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create1.initial.worker.js @@ -0,0 +1,34 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.create1.initial +// Description:createImageData(imgdata) returns transparent black data of the right size +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("createImageData(imgdata) returns transparent black data of the right size"); +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'); + +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50); +var imgdata1 = ctx.getImageData(0, 0, 10, 20); +var imgdata2 = ctx.createImageData(imgdata1); +_assertSame(imgdata2.data.length, imgdata1.data.length, "imgdata2.data.length", "imgdata1.data.length"); +_assertSame(imgdata2.width, imgdata1.width, "imgdata2.width", "imgdata1.width"); +_assertSame(imgdata2.height, imgdata1.height, "imgdata2.height", "imgdata1.height"); +var isTransparentBlack = true; +for (var i = 0; i < imgdata2.data.length; ++i) + if (imgdata2.data[i] !== 0) + isTransparentBlack = false; +_assert(isTransparentBlack, "isTransparentBlack"); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create1.zero.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create1.zero.html new file mode 100644 index 0000000000..736725f0fd --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create1.zero.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.create1.zero</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.create1.zero</h1> +<p class="desc">createImageData(null) throws TypeError</p> + + +<script> +var t = async_test("createImageData(null) throws TypeError"); +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'); + +assert_throws_js(TypeError, function() { ctx.createImageData(null); }); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create1.zero.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create1.zero.worker.js new file mode 100644 index 0000000000..c51067ed62 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create1.zero.worker.js @@ -0,0 +1,23 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.create1.zero +// Description:createImageData(null) throws TypeError +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("createImageData(null) throws TypeError"); +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'); + +assert_throws_js(TypeError, function() { ctx.createImageData(null); }); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.basic.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.basic.html new file mode 100644 index 0000000000..7dca77e4ae --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.basic.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.create2.basic</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.create2.basic</h1> +<p class="desc">createImageData(sw, sh) exists and returns something</p> + + +<script> +var t = async_test("createImageData(sw, sh) exists and returns something"); +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'); + +_assertDifferent(ctx.createImageData(1, 1), null, "ctx.createImageData(1, 1)", "null"); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.basic.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.basic.worker.js new file mode 100644 index 0000000000..e99cbe276b --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.basic.worker.js @@ -0,0 +1,23 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.create2.basic +// Description:createImageData(sw, sh) exists and returns something +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("createImageData(sw, sh) exists and returns something"); +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'); + +_assertDifferent(ctx.createImageData(1, 1), null, "ctx.createImageData(1, 1)", "null"); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.initial.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.initial.html new file mode 100644 index 0000000000..76017f5c4f --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.initial.html @@ -0,0 +1,35 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.create2.initial</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.create2.initial</h1> +<p class="desc">createImageData(sw, sh) returns transparent black data of the right size</p> + + +<script> +var t = async_test("createImageData(sw, sh) returns transparent black data of the right size"); +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'); + +var imgdata = ctx.createImageData(10, 20); +_assertSame(imgdata.data.length, imgdata.width*imgdata.height*4, "imgdata.data.length", "imgdata.width*imgdata.height*4"); +_assert(imgdata.width < imgdata.height, "imgdata.width < imgdata.height"); +_assert(imgdata.width > 0, "imgdata.width > 0"); +var isTransparentBlack = true; +for (var i = 0; i < imgdata.data.length; ++i) + if (imgdata.data[i] !== 0) + isTransparentBlack = false; +_assert(isTransparentBlack, "isTransparentBlack"); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.initial.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.initial.worker.js new file mode 100644 index 0000000000..0e681dee07 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.initial.worker.js @@ -0,0 +1,31 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.create2.initial +// Description:createImageData(sw, sh) returns transparent black data of the right size +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("createImageData(sw, sh) returns transparent black data of the right size"); +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'); + +var imgdata = ctx.createImageData(10, 20); +_assertSame(imgdata.data.length, imgdata.width*imgdata.height*4, "imgdata.data.length", "imgdata.width*imgdata.height*4"); +_assert(imgdata.width < imgdata.height, "imgdata.width < imgdata.height"); +_assert(imgdata.width > 0, "imgdata.width > 0"); +var isTransparentBlack = true; +for (var i = 0; i < imgdata.data.length; ++i) + if (imgdata.data[i] !== 0) + isTransparentBlack = false; +_assert(isTransparentBlack, "isTransparentBlack"); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.large.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.large.html new file mode 100644 index 0000000000..f3d19d3f29 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.large.html @@ -0,0 +1,35 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.create2.large</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.create2.large</h1> +<p class="desc">createImageData(sw, sh) works for sizes much larger than the canvas</p> + + +<script> +var t = async_test("createImageData(sw, sh) works for sizes much larger than 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'); + +var imgdata = ctx.createImageData(1000, 2000); +_assertSame(imgdata.data.length, imgdata.width*imgdata.height*4, "imgdata.data.length", "imgdata.width*imgdata.height*4"); +_assert(imgdata.width < imgdata.height, "imgdata.width < imgdata.height"); +_assert(imgdata.width > 0, "imgdata.width > 0"); +var isTransparentBlack = true; +for (var i = 0; i < imgdata.data.length; i += 7813) // check ~1024 points (assuming normal scaling) + if (imgdata.data[i] !== 0) + isTransparentBlack = false; +_assert(isTransparentBlack, "isTransparentBlack"); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.large.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.large.worker.js new file mode 100644 index 0000000000..57dda69d4d --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.large.worker.js @@ -0,0 +1,31 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.create2.large +// Description:createImageData(sw, sh) works for sizes much larger than the canvas +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("createImageData(sw, sh) works for sizes much larger than 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'); + +var imgdata = ctx.createImageData(1000, 2000); +_assertSame(imgdata.data.length, imgdata.width*imgdata.height*4, "imgdata.data.length", "imgdata.width*imgdata.height*4"); +_assert(imgdata.width < imgdata.height, "imgdata.width < imgdata.height"); +_assert(imgdata.width > 0, "imgdata.width > 0"); +var isTransparentBlack = true; +for (var i = 0; i < imgdata.data.length; i += 7813) // check ~1024 points (assuming normal scaling) + if (imgdata.data[i] !== 0) + isTransparentBlack = false; +_assert(isTransparentBlack, "isTransparentBlack"); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.negative.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.negative.html new file mode 100644 index 0000000000..f4b4df99a8 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.negative.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.create2.negative</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.create2.negative</h1> +<p class="desc">createImageData(sw, sh) takes the absolute magnitude of the size arguments</p> + + +<script> +var t = async_test("createImageData(sw, sh) takes the absolute magnitude of the size arguments"); +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'); + +var imgdata1 = ctx.createImageData(10, 20); +var imgdata2 = ctx.createImageData(-10, 20); +var imgdata3 = ctx.createImageData(10, -20); +var imgdata4 = ctx.createImageData(-10, -20); +_assertSame(imgdata1.data.length, imgdata2.data.length, "imgdata1.data.length", "imgdata2.data.length"); +_assertSame(imgdata2.data.length, imgdata3.data.length, "imgdata2.data.length", "imgdata3.data.length"); +_assertSame(imgdata3.data.length, imgdata4.data.length, "imgdata3.data.length", "imgdata4.data.length"); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.negative.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.negative.worker.js new file mode 100644 index 0000000000..a5cb857295 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.negative.worker.js @@ -0,0 +1,29 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.create2.negative +// Description:createImageData(sw, sh) takes the absolute magnitude of the size arguments +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("createImageData(sw, sh) takes the absolute magnitude of the size arguments"); +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'); + +var imgdata1 = ctx.createImageData(10, 20); +var imgdata2 = ctx.createImageData(-10, 20); +var imgdata3 = ctx.createImageData(10, -20); +var imgdata4 = ctx.createImageData(-10, -20); +_assertSame(imgdata1.data.length, imgdata2.data.length, "imgdata1.data.length", "imgdata2.data.length"); +_assertSame(imgdata2.data.length, imgdata3.data.length, "imgdata2.data.length", "imgdata3.data.length"); +_assertSame(imgdata3.data.length, imgdata4.data.length, "imgdata3.data.length", "imgdata4.data.length"); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.nonfinite.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.nonfinite.html new file mode 100644 index 0000000000..d7d1e7f756 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.nonfinite.html @@ -0,0 +1,43 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.create2.nonfinite</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.create2.nonfinite</h1> +<p class="desc">createImageData() throws TypeError if arguments are not finite</p> + + +<script> +var t = async_test("createImageData() throws TypeError if arguments are not finite"); +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'); + +assert_throws_js(TypeError, function() { ctx.createImageData(Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.createImageData(-Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.createImageData(NaN, 10); }); +assert_throws_js(TypeError, function() { ctx.createImageData(10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.createImageData(10, -Infinity); }); +assert_throws_js(TypeError, function() { ctx.createImageData(10, NaN); }); +assert_throws_js(TypeError, function() { ctx.createImageData(Infinity, Infinity); }); +var posinfobj = { valueOf: function() { return Infinity; } }, + neginfobj = { valueOf: function() { return -Infinity; } }, + nanobj = { valueOf: function() { return -Infinity; } }; +assert_throws_js(TypeError, function() { ctx.createImageData(posinfobj, 10); }); +assert_throws_js(TypeError, function() { ctx.createImageData(neginfobj, 10); }); +assert_throws_js(TypeError, function() { ctx.createImageData(nanobj, 10); }); +assert_throws_js(TypeError, function() { ctx.createImageData(10, posinfobj); }); +assert_throws_js(TypeError, function() { ctx.createImageData(10, neginfobj); }); +assert_throws_js(TypeError, function() { ctx.createImageData(10, nanobj); }); +assert_throws_js(TypeError, function() { ctx.createImageData(posinfobj, posinfobj); }); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.nonfinite.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.nonfinite.worker.js new file mode 100644 index 0000000000..f398e2a5d4 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.nonfinite.worker.js @@ -0,0 +1,39 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.create2.nonfinite +// Description:createImageData() throws TypeError if arguments are not finite +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("createImageData() throws TypeError if arguments are not finite"); +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'); + +assert_throws_js(TypeError, function() { ctx.createImageData(Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.createImageData(-Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.createImageData(NaN, 10); }); +assert_throws_js(TypeError, function() { ctx.createImageData(10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.createImageData(10, -Infinity); }); +assert_throws_js(TypeError, function() { ctx.createImageData(10, NaN); }); +assert_throws_js(TypeError, function() { ctx.createImageData(Infinity, Infinity); }); +var posinfobj = { valueOf: function() { return Infinity; } }, + neginfobj = { valueOf: function() { return -Infinity; } }, + nanobj = { valueOf: function() { return -Infinity; } }; +assert_throws_js(TypeError, function() { ctx.createImageData(posinfobj, 10); }); +assert_throws_js(TypeError, function() { ctx.createImageData(neginfobj, 10); }); +assert_throws_js(TypeError, function() { ctx.createImageData(nanobj, 10); }); +assert_throws_js(TypeError, function() { ctx.createImageData(10, posinfobj); }); +assert_throws_js(TypeError, function() { ctx.createImageData(10, neginfobj); }); +assert_throws_js(TypeError, function() { ctx.createImageData(10, nanobj); }); +assert_throws_js(TypeError, function() { ctx.createImageData(posinfobj, posinfobj); }); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.round.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.round.html new file mode 100644 index 0000000000..f2f0aa89e2 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.round.html @@ -0,0 +1,30 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.create2.round</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.create2.round</h1> +<p class="desc">createImageData(w, h) is rounded the same as getImageData(0, 0, w, h)</p> + + +<script> +var t = async_test("createImageData(w, h) is rounded the same as getImageData(0, 0, w, h)"); +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'); + +var imgdata1 = ctx.createImageData(10.01, 10.99); +var imgdata2 = ctx.getImageData(0, 0, 10.01, 10.99); +_assertSame(imgdata1.width, imgdata2.width, "imgdata1.width", "imgdata2.width"); +_assertSame(imgdata1.height, imgdata2.height, "imgdata1.height", "imgdata2.height"); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.round.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.round.worker.js new file mode 100644 index 0000000000..2387498418 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.round.worker.js @@ -0,0 +1,26 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.create2.round +// Description:createImageData(w, h) is rounded the same as getImageData(0, 0, w, h) +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("createImageData(w, h) is rounded the same as getImageData(0, 0, w, h)"); +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'); + +var imgdata1 = ctx.createImageData(10.01, 10.99); +var imgdata2 = ctx.getImageData(0, 0, 10.01, 10.99); +_assertSame(imgdata1.width, imgdata2.width, "imgdata1.width", "imgdata2.width"); +_assertSame(imgdata1.height, imgdata2.height, "imgdata1.height", "imgdata2.height"); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.zero.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.zero.html new file mode 100644 index 0000000000..7c3a2d9410 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.zero.html @@ -0,0 +1,29 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.create2.zero</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.create2.zero</h1> +<p class="desc">createImageData(sw, sh) throws INDEX_SIZE_ERR if size is zero</p> + + +<script> +var t = async_test("createImageData(sw, sh) throws INDEX_SIZE_ERR if size is zero"); +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'); + +assert_throws_dom("INDEX_SIZE_ERR", function() { ctx.createImageData(10, 0); }); +assert_throws_dom("INDEX_SIZE_ERR", function() { ctx.createImageData(0, 10); }); +assert_throws_dom("INDEX_SIZE_ERR", function() { ctx.createImageData(0, 0); }); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.zero.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.zero.worker.js new file mode 100644 index 0000000000..615a989e68 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.create2.zero.worker.js @@ -0,0 +1,25 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.create2.zero +// Description:createImageData(sw, sh) throws INDEX_SIZE_ERR if size is zero +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("createImageData(sw, sh) throws INDEX_SIZE_ERR if size is zero"); +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'); + +assert_throws_dom("INDEX_SIZE_ERR", function() { ctx.createImageData(10, 0); }); +assert_throws_dom("INDEX_SIZE_ERR", function() { ctx.createImageData(0, 10); }); +assert_throws_dom("INDEX_SIZE_ERR", function() { ctx.createImageData(0, 0); }); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.basic.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.basic.html new file mode 100644 index 0000000000..d4f4a63b3a --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.basic.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.get.basic</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.get.basic</h1> +<p class="desc">getImageData() exists and returns something</p> + + +<script> +var t = async_test("getImageData() exists and returns something"); +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'); + +_assertDifferent(ctx.getImageData(0, 0, 100, 50), null, "ctx.getImageData(0, 0, 100, 50)", "null"); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.basic.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.basic.worker.js new file mode 100644 index 0000000000..8accaccc75 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.basic.worker.js @@ -0,0 +1,23 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.get.basic +// Description:getImageData() exists and returns something +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("getImageData() exists and returns something"); +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'); + +_assertDifferent(ctx.getImageData(0, 0, 100, 50), null, "ctx.getImageData(0, 0, 100, 50)", "null"); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.clamp.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.clamp.html new file mode 100644 index 0000000000..9cbc1b48dc --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.clamp.html @@ -0,0 +1,38 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.get.clamp</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.get.clamp</h1> +<p class="desc">getImageData() clamps colors to the range [0, 255]</p> + + +<script> +var t = async_test("getImageData() clamps colors to the range [0, 255]"); +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'); + +ctx.fillStyle = 'rgb(-100, -200, -300)'; +ctx.fillRect(0, 0, 100, 50); +ctx.fillStyle = 'rgb(256, 300, 400)'; +ctx.fillRect(20, 10, 60, 10); +var imgdata1 = ctx.getImageData(10, 5, 1, 1); +_assertSame(imgdata1.data[0], 0, "imgdata1.data[\""+(0)+"\"]", "0"); +_assertSame(imgdata1.data[1], 0, "imgdata1.data[\""+(1)+"\"]", "0"); +_assertSame(imgdata1.data[2], 0, "imgdata1.data[\""+(2)+"\"]", "0"); +var imgdata2 = ctx.getImageData(30, 15, 1, 1); +_assertSame(imgdata2.data[0], 255, "imgdata2.data[\""+(0)+"\"]", "255"); +_assertSame(imgdata2.data[1], 255, "imgdata2.data[\""+(1)+"\"]", "255"); +_assertSame(imgdata2.data[2], 255, "imgdata2.data[\""+(2)+"\"]", "255"); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.clamp.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.clamp.worker.js new file mode 100644 index 0000000000..ceeb8d5d86 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.clamp.worker.js @@ -0,0 +1,34 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.get.clamp +// Description:getImageData() clamps colors to the range [0, 255] +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("getImageData() clamps colors to the range [0, 255]"); +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'); + +ctx.fillStyle = 'rgb(-100, -200, -300)'; +ctx.fillRect(0, 0, 100, 50); +ctx.fillStyle = 'rgb(256, 300, 400)'; +ctx.fillRect(20, 10, 60, 10); +var imgdata1 = ctx.getImageData(10, 5, 1, 1); +_assertSame(imgdata1.data[0], 0, "imgdata1.data[\""+(0)+"\"]", "0"); +_assertSame(imgdata1.data[1], 0, "imgdata1.data[\""+(1)+"\"]", "0"); +_assertSame(imgdata1.data[2], 0, "imgdata1.data[\""+(2)+"\"]", "0"); +var imgdata2 = ctx.getImageData(30, 15, 1, 1); +_assertSame(imgdata2.data[0], 255, "imgdata2.data[\""+(0)+"\"]", "255"); +_assertSame(imgdata2.data[1], 255, "imgdata2.data[\""+(1)+"\"]", "255"); +_assertSame(imgdata2.data[2], 255, "imgdata2.data[\""+(2)+"\"]", "255"); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.length.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.length.html new file mode 100644 index 0000000000..2f7247fafc --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.length.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.get.length</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.get.length</h1> +<p class="desc">getImageData() returns a correctly-sized Uint8ClampedArray</p> + + +<script> +var t = async_test("getImageData() returns a correctly-sized Uint8ClampedArray"); +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'); + +var imgdata = ctx.getImageData(0, 0, 10, 10); +_assertSame(imgdata.data.length, imgdata.width*imgdata.height*4, "imgdata.data.length", "imgdata.width*imgdata.height*4"); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.length.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.length.worker.js new file mode 100644 index 0000000000..dd2e3dd6c5 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.length.worker.js @@ -0,0 +1,24 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.get.length +// Description:getImageData() returns a correctly-sized Uint8ClampedArray +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("getImageData() returns a correctly-sized Uint8ClampedArray"); +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'); + +var imgdata = ctx.getImageData(0, 0, 10, 10); +_assertSame(imgdata.data.length, imgdata.width*imgdata.height*4, "imgdata.data.length", "imgdata.width*imgdata.height*4"); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.nonfinite.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.nonfinite.html new file mode 100644 index 0000000000..5efc73663d --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.nonfinite.html @@ -0,0 +1,75 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.get.nonfinite</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.get.nonfinite</h1> +<p class="desc">getImageData() throws TypeError if arguments are not finite</p> + + +<script> +var t = async_test("getImageData() throws TypeError if arguments are not finite"); +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'); + +assert_throws_js(TypeError, function() { ctx.getImageData(Infinity, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(-Infinity, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(NaN, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, Infinity, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, -Infinity, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, NaN, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, 10, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, 10, -Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, 10, NaN, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, 10, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, 10, 10, -Infinity); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, 10, 10, NaN); }); +assert_throws_js(TypeError, function() { ctx.getImageData(Infinity, Infinity, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(Infinity, Infinity, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(Infinity, Infinity, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.getImageData(Infinity, Infinity, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.getImageData(Infinity, 10, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(Infinity, 10, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.getImageData(Infinity, 10, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, Infinity, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, Infinity, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, Infinity, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, 10, Infinity, Infinity); }); +var posinfobj = { valueOf: function() { return Infinity; } }, + neginfobj = { valueOf: function() { return -Infinity; } }, + nanobj = { valueOf: function() { return -Infinity; } }; +assert_throws_js(TypeError, function() { ctx.getImageData(posinfobj, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(neginfobj, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(nanobj, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, posinfobj, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, neginfobj, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, nanobj, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, 10, posinfobj, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, 10, neginfobj, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, 10, nanobj, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, 10, 10, posinfobj); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, 10, 10, neginfobj); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, 10, 10, nanobj); }); +assert_throws_js(TypeError, function() { ctx.getImageData(posinfobj, posinfobj, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(posinfobj, posinfobj, posinfobj, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(posinfobj, posinfobj, posinfobj, posinfobj); }); +assert_throws_js(TypeError, function() { ctx.getImageData(posinfobj, posinfobj, 10, posinfobj); }); +assert_throws_js(TypeError, function() { ctx.getImageData(posinfobj, 10, posinfobj, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(posinfobj, 10, posinfobj, posinfobj); }); +assert_throws_js(TypeError, function() { ctx.getImageData(posinfobj, 10, 10, posinfobj); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, posinfobj, posinfobj, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, posinfobj, posinfobj, posinfobj); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, posinfobj, 10, posinfobj); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, 10, posinfobj, posinfobj); }); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.nonfinite.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.nonfinite.worker.js new file mode 100644 index 0000000000..15b3950adc --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.nonfinite.worker.js @@ -0,0 +1,71 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.get.nonfinite +// Description:getImageData() throws TypeError if arguments are not finite +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("getImageData() throws TypeError if arguments are not finite"); +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'); + +assert_throws_js(TypeError, function() { ctx.getImageData(Infinity, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(-Infinity, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(NaN, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, Infinity, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, -Infinity, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, NaN, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, 10, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, 10, -Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, 10, NaN, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, 10, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, 10, 10, -Infinity); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, 10, 10, NaN); }); +assert_throws_js(TypeError, function() { ctx.getImageData(Infinity, Infinity, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(Infinity, Infinity, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(Infinity, Infinity, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.getImageData(Infinity, Infinity, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.getImageData(Infinity, 10, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(Infinity, 10, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.getImageData(Infinity, 10, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, Infinity, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, Infinity, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, Infinity, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, 10, Infinity, Infinity); }); +var posinfobj = { valueOf: function() { return Infinity; } }, + neginfobj = { valueOf: function() { return -Infinity; } }, + nanobj = { valueOf: function() { return -Infinity; } }; +assert_throws_js(TypeError, function() { ctx.getImageData(posinfobj, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(neginfobj, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(nanobj, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, posinfobj, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, neginfobj, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, nanobj, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, 10, posinfobj, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, 10, neginfobj, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, 10, nanobj, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, 10, 10, posinfobj); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, 10, 10, neginfobj); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, 10, 10, nanobj); }); +assert_throws_js(TypeError, function() { ctx.getImageData(posinfobj, posinfobj, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(posinfobj, posinfobj, posinfobj, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(posinfobj, posinfobj, posinfobj, posinfobj); }); +assert_throws_js(TypeError, function() { ctx.getImageData(posinfobj, posinfobj, 10, posinfobj); }); +assert_throws_js(TypeError, function() { ctx.getImageData(posinfobj, 10, posinfobj, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(posinfobj, 10, posinfobj, posinfobj); }); +assert_throws_js(TypeError, function() { ctx.getImageData(posinfobj, 10, 10, posinfobj); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, posinfobj, posinfobj, 10); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, posinfobj, posinfobj, posinfobj); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, posinfobj, 10, posinfobj); }); +assert_throws_js(TypeError, function() { ctx.getImageData(10, 10, posinfobj, posinfobj); }); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.nonpremul.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.nonpremul.html new file mode 100644 index 0000000000..bed3294be4 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.nonpremul.html @@ -0,0 +1,34 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.get.nonpremul</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.get.nonpremul</h1> +<p class="desc">getImageData() returns non-premultiplied colors</p> + + +<script> +var t = async_test("getImageData() returns non-premultiplied colors"); +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'); + +ctx.fillStyle = 'rgba(255, 255, 255, 0.5)'; +ctx.fillRect(0, 0, 100, 50); +var imgdata = ctx.getImageData(10, 10, 10, 10); +_assert(imgdata.data[0] > 200, "imgdata.data[\""+(0)+"\"] > 200"); +_assert(imgdata.data[1] > 200, "imgdata.data[\""+(1)+"\"] > 200"); +_assert(imgdata.data[2] > 200, "imgdata.data[\""+(2)+"\"] > 200"); +_assert(imgdata.data[3] > 100, "imgdata.data[\""+(3)+"\"] > 100"); +_assert(imgdata.data[3] < 200, "imgdata.data[\""+(3)+"\"] < 200"); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.nonpremul.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.nonpremul.worker.js new file mode 100644 index 0000000000..d568c31b38 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.nonpremul.worker.js @@ -0,0 +1,30 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.get.nonpremul +// Description:getImageData() returns non-premultiplied colors +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("getImageData() returns non-premultiplied colors"); +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'); + +ctx.fillStyle = 'rgba(255, 255, 255, 0.5)'; +ctx.fillRect(0, 0, 100, 50); +var imgdata = ctx.getImageData(10, 10, 10, 10); +_assert(imgdata.data[0] > 200, "imgdata.data[\""+(0)+"\"] > 200"); +_assert(imgdata.data[1] > 200, "imgdata.data[\""+(1)+"\"] > 200"); +_assert(imgdata.data[2] > 200, "imgdata.data[\""+(2)+"\"] > 200"); +_assert(imgdata.data[3] > 100, "imgdata.data[\""+(3)+"\"] > 100"); +_assert(imgdata.data[3] < 200, "imgdata.data[\""+(3)+"\"] < 200"); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.order.alpha.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.order.alpha.html new file mode 100644 index 0000000000..a169cb59e3 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.order.alpha.html @@ -0,0 +1,31 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.get.order.alpha</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.get.order.alpha</h1> +<p class="desc">getImageData() returns A in the fourth component</p> + + +<script> +var t = async_test("getImageData() returns A in the fourth component"); +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'); + +ctx.fillStyle = 'rgba(0, 0, 0, 0.5)'; +ctx.fillRect(0, 0, 100, 50); +var imgdata = ctx.getImageData(0, 0, 10, 10); +_assert(imgdata.data[3] < 200, "imgdata.data[\""+(3)+"\"] < 200"); +_assert(imgdata.data[3] > 100, "imgdata.data[\""+(3)+"\"] > 100"); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.order.alpha.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.order.alpha.worker.js new file mode 100644 index 0000000000..038844816f --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.order.alpha.worker.js @@ -0,0 +1,27 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.get.order.alpha +// Description:getImageData() returns A in the fourth component +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("getImageData() returns A in the fourth component"); +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'); + +ctx.fillStyle = 'rgba(0, 0, 0, 0.5)'; +ctx.fillRect(0, 0, 100, 50); +var imgdata = ctx.getImageData(0, 0, 10, 10); +_assert(imgdata.data[3] < 200, "imgdata.data[\""+(3)+"\"] < 200"); +_assert(imgdata.data[3] > 100, "imgdata.data[\""+(3)+"\"] > 100"); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.order.cols.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.order.cols.html new file mode 100644 index 0000000000..09eb58a7fd --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.order.cols.html @@ -0,0 +1,34 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.get.order.cols</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.get.order.cols</h1> +<p class="desc">getImageData() returns leftmost columns first</p> + + +<script> +var t = async_test("getImageData() returns leftmost columns first"); +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'); + +ctx.fillStyle = '#fff'; +ctx.fillRect(0, 0, 100, 50); +ctx.fillStyle = '#000'; +ctx.fillRect(0, 0, 2, 50); +var imgdata = ctx.getImageData(0, 0, 10, 10); +_assertSame(imgdata.data[0], 0, "imgdata.data[\""+(0)+"\"]", "0"); +_assertSame(imgdata.data[Math.round(imgdata.width/2*4)], 255, "imgdata.data[Math.round(imgdata.width/2*4)]", "255"); +_assertSame(imgdata.data[Math.round((imgdata.height/2)*imgdata.width*4)], 0, "imgdata.data[Math.round((imgdata.height/2)*imgdata.width*4)]", "0"); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.order.cols.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.order.cols.worker.js new file mode 100644 index 0000000000..6a13c4dee6 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.order.cols.worker.js @@ -0,0 +1,30 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.get.order.cols +// Description:getImageData() returns leftmost columns first +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("getImageData() returns leftmost columns first"); +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'); + +ctx.fillStyle = '#fff'; +ctx.fillRect(0, 0, 100, 50); +ctx.fillStyle = '#000'; +ctx.fillRect(0, 0, 2, 50); +var imgdata = ctx.getImageData(0, 0, 10, 10); +_assertSame(imgdata.data[0], 0, "imgdata.data[\""+(0)+"\"]", "0"); +_assertSame(imgdata.data[Math.round(imgdata.width/2*4)], 255, "imgdata.data[Math.round(imgdata.width/2*4)]", "255"); +_assertSame(imgdata.data[Math.round((imgdata.height/2)*imgdata.width*4)], 0, "imgdata.data[Math.round((imgdata.height/2)*imgdata.width*4)]", "0"); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.order.rgb.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.order.rgb.html new file mode 100644 index 0000000000..b56adf19fe --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.order.rgb.html @@ -0,0 +1,37 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.get.order.rgb</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.get.order.rgb</h1> +<p class="desc">getImageData() returns R then G then B</p> + + +<script> +var t = async_test("getImageData() returns R then G then B"); +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'); + +ctx.fillStyle = '#48c'; +ctx.fillRect(0, 0, 100, 50); +var imgdata = ctx.getImageData(0, 0, 10, 10); +_assertSame(imgdata.data[0], 0x44, "imgdata.data[\""+(0)+"\"]", "0x44"); +_assertSame(imgdata.data[1], 0x88, "imgdata.data[\""+(1)+"\"]", "0x88"); +_assertSame(imgdata.data[2], 0xCC, "imgdata.data[\""+(2)+"\"]", "0xCC"); +_assertSame(imgdata.data[3], 255, "imgdata.data[\""+(3)+"\"]", "255"); +_assertSame(imgdata.data[4], 0x44, "imgdata.data[\""+(4)+"\"]", "0x44"); +_assertSame(imgdata.data[5], 0x88, "imgdata.data[\""+(5)+"\"]", "0x88"); +_assertSame(imgdata.data[6], 0xCC, "imgdata.data[\""+(6)+"\"]", "0xCC"); +_assertSame(imgdata.data[7], 255, "imgdata.data[\""+(7)+"\"]", "255"); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.order.rgb.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.order.rgb.worker.js new file mode 100644 index 0000000000..771a777b9b --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.order.rgb.worker.js @@ -0,0 +1,33 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.get.order.rgb +// Description:getImageData() returns R then G then B +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("getImageData() returns R then G then B"); +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'); + +ctx.fillStyle = '#48c'; +ctx.fillRect(0, 0, 100, 50); +var imgdata = ctx.getImageData(0, 0, 10, 10); +_assertSame(imgdata.data[0], 0x44, "imgdata.data[\""+(0)+"\"]", "0x44"); +_assertSame(imgdata.data[1], 0x88, "imgdata.data[\""+(1)+"\"]", "0x88"); +_assertSame(imgdata.data[2], 0xCC, "imgdata.data[\""+(2)+"\"]", "0xCC"); +_assertSame(imgdata.data[3], 255, "imgdata.data[\""+(3)+"\"]", "255"); +_assertSame(imgdata.data[4], 0x44, "imgdata.data[\""+(4)+"\"]", "0x44"); +_assertSame(imgdata.data[5], 0x88, "imgdata.data[\""+(5)+"\"]", "0x88"); +_assertSame(imgdata.data[6], 0xCC, "imgdata.data[\""+(6)+"\"]", "0xCC"); +_assertSame(imgdata.data[7], 255, "imgdata.data[\""+(7)+"\"]", "255"); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.order.rows.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.order.rows.html new file mode 100644 index 0000000000..3ad1ced7d2 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.order.rows.html @@ -0,0 +1,34 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.get.order.rows</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.get.order.rows</h1> +<p class="desc">getImageData() returns topmost rows first</p> + + +<script> +var t = async_test("getImageData() returns topmost rows first"); +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'); + +ctx.fillStyle = '#fff'; +ctx.fillRect(0, 0, 100, 50); +ctx.fillStyle = '#000'; +ctx.fillRect(0, 0, 100, 2); +var imgdata = ctx.getImageData(0, 0, 10, 10); +_assertSame(imgdata.data[0], 0, "imgdata.data[\""+(0)+"\"]", "0"); +_assertSame(imgdata.data[Math.floor(imgdata.width/2*4)], 0, "imgdata.data[Math.floor(imgdata.width/2*4)]", "0"); +_assertSame(imgdata.data[(imgdata.height/2)*imgdata.width*4], 255, "imgdata.data[(imgdata.height/2)*imgdata.width*4]", "255"); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.order.rows.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.order.rows.worker.js new file mode 100644 index 0000000000..1f75f9301c --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.order.rows.worker.js @@ -0,0 +1,30 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.get.order.rows +// Description:getImageData() returns topmost rows first +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("getImageData() returns topmost rows first"); +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'); + +ctx.fillStyle = '#fff'; +ctx.fillRect(0, 0, 100, 50); +ctx.fillStyle = '#000'; +ctx.fillRect(0, 0, 100, 2); +var imgdata = ctx.getImageData(0, 0, 10, 10); +_assertSame(imgdata.data[0], 0, "imgdata.data[\""+(0)+"\"]", "0"); +_assertSame(imgdata.data[Math.floor(imgdata.width/2*4)], 0, "imgdata.data[Math.floor(imgdata.width/2*4)]", "0"); +_assertSame(imgdata.data[(imgdata.height/2)*imgdata.width*4], 255, "imgdata.data[(imgdata.height/2)*imgdata.width*4]", "255"); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.range.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.range.html new file mode 100644 index 0000000000..283dd07b4c --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.range.html @@ -0,0 +1,34 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.get.range</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.get.range</h1> +<p class="desc">getImageData() returns values in the range [0, 255]</p> + + +<script> +var t = async_test("getImageData() returns values in the range [0, 255]"); +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'); + +ctx.fillStyle = '#000'; +ctx.fillRect(0, 0, 100, 50); +ctx.fillStyle = '#fff'; +ctx.fillRect(20, 10, 60, 10); +var imgdata1 = ctx.getImageData(10, 5, 1, 1); +_assertSame(imgdata1.data[0], 0, "imgdata1.data[\""+(0)+"\"]", "0"); +var imgdata2 = ctx.getImageData(30, 15, 1, 1); +_assertSame(imgdata2.data[0], 255, "imgdata2.data[\""+(0)+"\"]", "255"); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.range.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.range.worker.js new file mode 100644 index 0000000000..9389c22bd3 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.range.worker.js @@ -0,0 +1,30 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.get.range +// Description:getImageData() returns values in the range [0, 255] +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("getImageData() returns values in the range [0, 255]"); +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'); + +ctx.fillStyle = '#000'; +ctx.fillRect(0, 0, 100, 50); +ctx.fillStyle = '#fff'; +ctx.fillRect(20, 10, 60, 10); +var imgdata1 = ctx.getImageData(10, 5, 1, 1); +_assertSame(imgdata1.data[0], 0, "imgdata1.data[\""+(0)+"\"]", "0"); +var imgdata2 = ctx.getImageData(30, 15, 1, 1); +_assertSame(imgdata2.data[0], 255, "imgdata2.data[\""+(0)+"\"]", "255"); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.source.negative.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.source.negative.html new file mode 100644 index 0000000000..a7e3d8574f --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.source.negative.html @@ -0,0 +1,44 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.get.source.negative</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.get.source.negative</h1> +<p class="desc">getImageData() works with negative width and height, and returns top-to-bottom left-to-right</p> + + +<script> +var t = async_test("getImageData() works with negative width and height, and returns top-to-bottom left-to-right"); +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'); + +ctx.fillStyle = '#000'; +ctx.fillRect(0, 0, 100, 50); +ctx.fillStyle = '#fff'; +ctx.fillRect(20, 10, 60, 10); +var imgdata1 = ctx.getImageData(85, 25, -10, -10); +_assertSame(imgdata1.data[0], 255, "imgdata1.data[\""+(0)+"\"]", "255"); +_assertSame(imgdata1.data[1], 255, "imgdata1.data[\""+(1)+"\"]", "255"); +_assertSame(imgdata1.data[2], 255, "imgdata1.data[\""+(2)+"\"]", "255"); +_assertSame(imgdata1.data[3], 255, "imgdata1.data[\""+(3)+"\"]", "255"); +_assertSame(imgdata1.data[imgdata1.data.length-4+0], 0, "imgdata1.data[imgdata1.data.length-4+0]", "0"); +_assertSame(imgdata1.data[imgdata1.data.length-4+1], 0, "imgdata1.data[imgdata1.data.length-4+1]", "0"); +_assertSame(imgdata1.data[imgdata1.data.length-4+2], 0, "imgdata1.data[imgdata1.data.length-4+2]", "0"); +_assertSame(imgdata1.data[imgdata1.data.length-4+3], 255, "imgdata1.data[imgdata1.data.length-4+3]", "255"); +var imgdata2 = ctx.getImageData(0, 0, -1, -1); +_assertSame(imgdata2.data[0], 0, "imgdata2.data[\""+(0)+"\"]", "0"); +_assertSame(imgdata2.data[1], 0, "imgdata2.data[\""+(1)+"\"]", "0"); +_assertSame(imgdata2.data[2], 0, "imgdata2.data[\""+(2)+"\"]", "0"); +_assertSame(imgdata2.data[3], 0, "imgdata2.data[\""+(3)+"\"]", "0"); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.source.negative.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.source.negative.worker.js new file mode 100644 index 0000000000..e057315d57 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.source.negative.worker.js @@ -0,0 +1,40 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.get.source.negative +// Description:getImageData() works with negative width and height, and returns top-to-bottom left-to-right +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("getImageData() works with negative width and height, and returns top-to-bottom left-to-right"); +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'); + +ctx.fillStyle = '#000'; +ctx.fillRect(0, 0, 100, 50); +ctx.fillStyle = '#fff'; +ctx.fillRect(20, 10, 60, 10); +var imgdata1 = ctx.getImageData(85, 25, -10, -10); +_assertSame(imgdata1.data[0], 255, "imgdata1.data[\""+(0)+"\"]", "255"); +_assertSame(imgdata1.data[1], 255, "imgdata1.data[\""+(1)+"\"]", "255"); +_assertSame(imgdata1.data[2], 255, "imgdata1.data[\""+(2)+"\"]", "255"); +_assertSame(imgdata1.data[3], 255, "imgdata1.data[\""+(3)+"\"]", "255"); +_assertSame(imgdata1.data[imgdata1.data.length-4+0], 0, "imgdata1.data[imgdata1.data.length-4+0]", "0"); +_assertSame(imgdata1.data[imgdata1.data.length-4+1], 0, "imgdata1.data[imgdata1.data.length-4+1]", "0"); +_assertSame(imgdata1.data[imgdata1.data.length-4+2], 0, "imgdata1.data[imgdata1.data.length-4+2]", "0"); +_assertSame(imgdata1.data[imgdata1.data.length-4+3], 255, "imgdata1.data[imgdata1.data.length-4+3]", "255"); +var imgdata2 = ctx.getImageData(0, 0, -1, -1); +_assertSame(imgdata2.data[0], 0, "imgdata2.data[\""+(0)+"\"]", "0"); +_assertSame(imgdata2.data[1], 0, "imgdata2.data[\""+(1)+"\"]", "0"); +_assertSame(imgdata2.data[2], 0, "imgdata2.data[\""+(2)+"\"]", "0"); +_assertSame(imgdata2.data[3], 0, "imgdata2.data[\""+(3)+"\"]", "0"); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.source.outside.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.source.outside.html new file mode 100644 index 0000000000..a071e44d55 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.source.outside.html @@ -0,0 +1,79 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.get.source.outside</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.get.source.outside</h1> +<p class="desc">getImageData() returns transparent black outside the canvas</p> + + +<script> +var t = async_test("getImageData() returns transparent black outside 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'); + +ctx.fillStyle = '#08f'; +ctx.fillRect(0, 0, 100, 50); +var imgdata1 = ctx.getImageData(-10, 5, 1, 1); +_assertSame(imgdata1.data[0], 0, "imgdata1.data[\""+(0)+"\"]", "0"); +_assertSame(imgdata1.data[1], 0, "imgdata1.data[\""+(1)+"\"]", "0"); +_assertSame(imgdata1.data[2], 0, "imgdata1.data[\""+(2)+"\"]", "0"); +_assertSame(imgdata1.data[3], 0, "imgdata1.data[\""+(3)+"\"]", "0"); +var imgdata2 = ctx.getImageData(10, -5, 1, 1); +_assertSame(imgdata2.data[0], 0, "imgdata2.data[\""+(0)+"\"]", "0"); +_assertSame(imgdata2.data[1], 0, "imgdata2.data[\""+(1)+"\"]", "0"); +_assertSame(imgdata2.data[2], 0, "imgdata2.data[\""+(2)+"\"]", "0"); +_assertSame(imgdata2.data[3], 0, "imgdata2.data[\""+(3)+"\"]", "0"); +var imgdata3 = ctx.getImageData(200, 5, 1, 1); +_assertSame(imgdata3.data[0], 0, "imgdata3.data[\""+(0)+"\"]", "0"); +_assertSame(imgdata3.data[1], 0, "imgdata3.data[\""+(1)+"\"]", "0"); +_assertSame(imgdata3.data[2], 0, "imgdata3.data[\""+(2)+"\"]", "0"); +_assertSame(imgdata3.data[3], 0, "imgdata3.data[\""+(3)+"\"]", "0"); +var imgdata4 = ctx.getImageData(10, 60, 1, 1); +_assertSame(imgdata4.data[0], 0, "imgdata4.data[\""+(0)+"\"]", "0"); +_assertSame(imgdata4.data[1], 0, "imgdata4.data[\""+(1)+"\"]", "0"); +_assertSame(imgdata4.data[2], 0, "imgdata4.data[\""+(2)+"\"]", "0"); +_assertSame(imgdata4.data[3], 0, "imgdata4.data[\""+(3)+"\"]", "0"); +var imgdata5 = ctx.getImageData(100, 10, 1, 1); +_assertSame(imgdata5.data[0], 0, "imgdata5.data[\""+(0)+"\"]", "0"); +_assertSame(imgdata5.data[1], 0, "imgdata5.data[\""+(1)+"\"]", "0"); +_assertSame(imgdata5.data[2], 0, "imgdata5.data[\""+(2)+"\"]", "0"); +_assertSame(imgdata5.data[3], 0, "imgdata5.data[\""+(3)+"\"]", "0"); +var imgdata6 = ctx.getImageData(0, 10, 1, 1); +_assertSame(imgdata6.data[0], 0, "imgdata6.data[\""+(0)+"\"]", "0"); +_assertSame(imgdata6.data[1], 136, "imgdata6.data[\""+(1)+"\"]", "136"); +_assertSame(imgdata6.data[2], 255, "imgdata6.data[\""+(2)+"\"]", "255"); +_assertSame(imgdata6.data[3], 255, "imgdata6.data[\""+(3)+"\"]", "255"); +var imgdata7 = ctx.getImageData(-10, 10, 20, 20); +_assertSame(imgdata7.data[ 0*4+0], 0, "imgdata7.data[ 0*4+0]", "0"); +_assertSame(imgdata7.data[ 0*4+1], 0, "imgdata7.data[ 0*4+1]", "0"); +_assertSame(imgdata7.data[ 0*4+2], 0, "imgdata7.data[ 0*4+2]", "0"); +_assertSame(imgdata7.data[ 0*4+3], 0, "imgdata7.data[ 0*4+3]", "0"); +_assertSame(imgdata7.data[ 9*4+0], 0, "imgdata7.data[ 9*4+0]", "0"); +_assertSame(imgdata7.data[ 9*4+1], 0, "imgdata7.data[ 9*4+1]", "0"); +_assertSame(imgdata7.data[ 9*4+2], 0, "imgdata7.data[ 9*4+2]", "0"); +_assertSame(imgdata7.data[ 9*4+3], 0, "imgdata7.data[ 9*4+3]", "0"); +_assertSame(imgdata7.data[10*4+0], 0, "imgdata7.data[10*4+0]", "0"); +_assertSame(imgdata7.data[10*4+1], 136, "imgdata7.data[10*4+1]", "136"); +_assertSame(imgdata7.data[10*4+2], 255, "imgdata7.data[10*4+2]", "255"); +_assertSame(imgdata7.data[10*4+3], 255, "imgdata7.data[10*4+3]", "255"); +_assertSame(imgdata7.data[19*4+0], 0, "imgdata7.data[19*4+0]", "0"); +_assertSame(imgdata7.data[19*4+1], 136, "imgdata7.data[19*4+1]", "136"); +_assertSame(imgdata7.data[19*4+2], 255, "imgdata7.data[19*4+2]", "255"); +_assertSame(imgdata7.data[19*4+3], 255, "imgdata7.data[19*4+3]", "255"); +_assertSame(imgdata7.data[20*4+0], 0, "imgdata7.data[20*4+0]", "0"); +_assertSame(imgdata7.data[20*4+1], 0, "imgdata7.data[20*4+1]", "0"); +_assertSame(imgdata7.data[20*4+2], 0, "imgdata7.data[20*4+2]", "0"); +_assertSame(imgdata7.data[20*4+3], 0, "imgdata7.data[20*4+3]", "0"); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.source.outside.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.source.outside.worker.js new file mode 100644 index 0000000000..4025ecd4be --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.source.outside.worker.js @@ -0,0 +1,75 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.get.source.outside +// Description:getImageData() returns transparent black outside the canvas +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("getImageData() returns transparent black outside 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'); + +ctx.fillStyle = '#08f'; +ctx.fillRect(0, 0, 100, 50); +var imgdata1 = ctx.getImageData(-10, 5, 1, 1); +_assertSame(imgdata1.data[0], 0, "imgdata1.data[\""+(0)+"\"]", "0"); +_assertSame(imgdata1.data[1], 0, "imgdata1.data[\""+(1)+"\"]", "0"); +_assertSame(imgdata1.data[2], 0, "imgdata1.data[\""+(2)+"\"]", "0"); +_assertSame(imgdata1.data[3], 0, "imgdata1.data[\""+(3)+"\"]", "0"); +var imgdata2 = ctx.getImageData(10, -5, 1, 1); +_assertSame(imgdata2.data[0], 0, "imgdata2.data[\""+(0)+"\"]", "0"); +_assertSame(imgdata2.data[1], 0, "imgdata2.data[\""+(1)+"\"]", "0"); +_assertSame(imgdata2.data[2], 0, "imgdata2.data[\""+(2)+"\"]", "0"); +_assertSame(imgdata2.data[3], 0, "imgdata2.data[\""+(3)+"\"]", "0"); +var imgdata3 = ctx.getImageData(200, 5, 1, 1); +_assertSame(imgdata3.data[0], 0, "imgdata3.data[\""+(0)+"\"]", "0"); +_assertSame(imgdata3.data[1], 0, "imgdata3.data[\""+(1)+"\"]", "0"); +_assertSame(imgdata3.data[2], 0, "imgdata3.data[\""+(2)+"\"]", "0"); +_assertSame(imgdata3.data[3], 0, "imgdata3.data[\""+(3)+"\"]", "0"); +var imgdata4 = ctx.getImageData(10, 60, 1, 1); +_assertSame(imgdata4.data[0], 0, "imgdata4.data[\""+(0)+"\"]", "0"); +_assertSame(imgdata4.data[1], 0, "imgdata4.data[\""+(1)+"\"]", "0"); +_assertSame(imgdata4.data[2], 0, "imgdata4.data[\""+(2)+"\"]", "0"); +_assertSame(imgdata4.data[3], 0, "imgdata4.data[\""+(3)+"\"]", "0"); +var imgdata5 = ctx.getImageData(100, 10, 1, 1); +_assertSame(imgdata5.data[0], 0, "imgdata5.data[\""+(0)+"\"]", "0"); +_assertSame(imgdata5.data[1], 0, "imgdata5.data[\""+(1)+"\"]", "0"); +_assertSame(imgdata5.data[2], 0, "imgdata5.data[\""+(2)+"\"]", "0"); +_assertSame(imgdata5.data[3], 0, "imgdata5.data[\""+(3)+"\"]", "0"); +var imgdata6 = ctx.getImageData(0, 10, 1, 1); +_assertSame(imgdata6.data[0], 0, "imgdata6.data[\""+(0)+"\"]", "0"); +_assertSame(imgdata6.data[1], 136, "imgdata6.data[\""+(1)+"\"]", "136"); +_assertSame(imgdata6.data[2], 255, "imgdata6.data[\""+(2)+"\"]", "255"); +_assertSame(imgdata6.data[3], 255, "imgdata6.data[\""+(3)+"\"]", "255"); +var imgdata7 = ctx.getImageData(-10, 10, 20, 20); +_assertSame(imgdata7.data[ 0*4+0], 0, "imgdata7.data[ 0*4+0]", "0"); +_assertSame(imgdata7.data[ 0*4+1], 0, "imgdata7.data[ 0*4+1]", "0"); +_assertSame(imgdata7.data[ 0*4+2], 0, "imgdata7.data[ 0*4+2]", "0"); +_assertSame(imgdata7.data[ 0*4+3], 0, "imgdata7.data[ 0*4+3]", "0"); +_assertSame(imgdata7.data[ 9*4+0], 0, "imgdata7.data[ 9*4+0]", "0"); +_assertSame(imgdata7.data[ 9*4+1], 0, "imgdata7.data[ 9*4+1]", "0"); +_assertSame(imgdata7.data[ 9*4+2], 0, "imgdata7.data[ 9*4+2]", "0"); +_assertSame(imgdata7.data[ 9*4+3], 0, "imgdata7.data[ 9*4+3]", "0"); +_assertSame(imgdata7.data[10*4+0], 0, "imgdata7.data[10*4+0]", "0"); +_assertSame(imgdata7.data[10*4+1], 136, "imgdata7.data[10*4+1]", "136"); +_assertSame(imgdata7.data[10*4+2], 255, "imgdata7.data[10*4+2]", "255"); +_assertSame(imgdata7.data[10*4+3], 255, "imgdata7.data[10*4+3]", "255"); +_assertSame(imgdata7.data[19*4+0], 0, "imgdata7.data[19*4+0]", "0"); +_assertSame(imgdata7.data[19*4+1], 136, "imgdata7.data[19*4+1]", "136"); +_assertSame(imgdata7.data[19*4+2], 255, "imgdata7.data[19*4+2]", "255"); +_assertSame(imgdata7.data[19*4+3], 255, "imgdata7.data[19*4+3]", "255"); +_assertSame(imgdata7.data[20*4+0], 0, "imgdata7.data[20*4+0]", "0"); +_assertSame(imgdata7.data[20*4+1], 0, "imgdata7.data[20*4+1]", "0"); +_assertSame(imgdata7.data[20*4+2], 0, "imgdata7.data[20*4+2]", "0"); +_assertSame(imgdata7.data[20*4+3], 0, "imgdata7.data[20*4+3]", "0"); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.source.size.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.source.size.html new file mode 100644 index 0000000000..4fd551db7d --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.source.size.html @@ -0,0 +1,30 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.get.source.size</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.get.source.size</h1> +<p class="desc">getImageData() returns bigger ImageData for bigger source rectangle</p> + + +<script> +var t = async_test("getImageData() returns bigger ImageData for bigger source rectangle"); +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'); + +var imgdata1 = ctx.getImageData(0, 0, 10, 10); +var imgdata2 = ctx.getImageData(0, 0, 20, 20); +_assert(imgdata2.width > imgdata1.width, "imgdata2.width > imgdata1.width"); +_assert(imgdata2.height > imgdata1.height, "imgdata2.height > imgdata1.height"); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.source.size.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.source.size.worker.js new file mode 100644 index 0000000000..111f4b5869 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.source.size.worker.js @@ -0,0 +1,26 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.get.source.size +// Description:getImageData() returns bigger ImageData for bigger source rectangle +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("getImageData() returns bigger ImageData for bigger source rectangle"); +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'); + +var imgdata1 = ctx.getImageData(0, 0, 10, 10); +var imgdata2 = ctx.getImageData(0, 0, 20, 20); +_assert(imgdata2.width > imgdata1.width, "imgdata2.width > imgdata1.width"); +_assert(imgdata2.height > imgdata1.height, "imgdata2.height > imgdata1.height"); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.unaffected.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.unaffected.html new file mode 100644 index 0000000000..f65f015e8f --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.unaffected.html @@ -0,0 +1,42 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.get.unaffected</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.get.unaffected</h1> +<p class="desc">getImageData() is not affected by context state</p> + + +<script> +var t = async_test("getImageData() is not affected by context state"); +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'); + +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 50, 50) +ctx.fillStyle = '#f00'; +ctx.fillRect(50, 0, 50, 50) +ctx.save(); +ctx.translate(50, 0); +ctx.globalAlpha = 0.1; +ctx.globalCompositeOperation = 'destination-atop'; +ctx.shadowColor = '#f00'; +ctx.rect(0, 0, 5, 5); +ctx.clip(); +var imgdata = ctx.getImageData(0, 0, 50, 50); +ctx.restore(); +ctx.putImageData(imgdata, 50, 0); +_assertPixelApprox(canvas, 25,25, 0,255,0,255, 2); +_assertPixelApprox(canvas, 75,25, 0,255,0,255, 2); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.unaffected.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.unaffected.worker.js new file mode 100644 index 0000000000..a733c6ffdf --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.unaffected.worker.js @@ -0,0 +1,38 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.get.unaffected +// Description:getImageData() is not affected by context state +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("getImageData() is not affected by context state"); +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'); + +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 50, 50) +ctx.fillStyle = '#f00'; +ctx.fillRect(50, 0, 50, 50) +ctx.save(); +ctx.translate(50, 0); +ctx.globalAlpha = 0.1; +ctx.globalCompositeOperation = 'destination-atop'; +ctx.shadowColor = '#f00'; +ctx.rect(0, 0, 5, 5); +ctx.clip(); +var imgdata = ctx.getImageData(0, 0, 50, 50); +ctx.restore(); +ctx.putImageData(imgdata, 50, 0); +_assertPixelApprox(canvas, 25,25, 0,255,0,255, 2); +_assertPixelApprox(canvas, 75,25, 0,255,0,255, 2); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.zero.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.zero.html new file mode 100644 index 0000000000..91cf5a25e2 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.zero.html @@ -0,0 +1,29 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.get.zero</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.get.zero</h1> +<p class="desc">getImageData() throws INDEX_SIZE_ERR if size is zero</p> + + +<script> +var t = async_test("getImageData() throws INDEX_SIZE_ERR if size is zero"); +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'); + +assert_throws_dom("INDEX_SIZE_ERR", function() { ctx.getImageData(1, 1, 10, 0); }); +assert_throws_dom("INDEX_SIZE_ERR", function() { ctx.getImageData(1, 1, 0, 10); }); +assert_throws_dom("INDEX_SIZE_ERR", function() { ctx.getImageData(1, 1, 0, 0); }); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.zero.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.zero.worker.js new file mode 100644 index 0000000000..07e8f3621b --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.get.zero.worker.js @@ -0,0 +1,25 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.get.zero +// Description:getImageData() throws INDEX_SIZE_ERR if size is zero +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("getImageData() throws INDEX_SIZE_ERR if size is zero"); +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'); + +assert_throws_dom("INDEX_SIZE_ERR", function() { ctx.getImageData(1, 1, 10, 0); }); +assert_throws_dom("INDEX_SIZE_ERR", function() { ctx.getImageData(1, 1, 0, 10); }); +assert_throws_dom("INDEX_SIZE_ERR", function() { ctx.getImageData(1, 1, 0, 0); }); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.clamp.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.clamp.html new file mode 100644 index 0000000000..8b1515c678 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.clamp.html @@ -0,0 +1,51 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.object.clamp</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.object.clamp</h1> +<p class="desc">ImageData.data clamps numbers to [0, 255]</p> + + +<script> +var t = async_test("ImageData.data clamps numbers to [0, 255]"); +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'); + +var imgdata = ctx.getImageData(0, 0, 10, 10); +imgdata.data[0] = 100; +imgdata.data[0] = 300; +_assertSame(imgdata.data[0], 255, "imgdata.data[\""+(0)+"\"]", "255"); +imgdata.data[0] = 100; +imgdata.data[0] = -100; +_assertSame(imgdata.data[0], 0, "imgdata.data[\""+(0)+"\"]", "0"); +imgdata.data[0] = 100; +imgdata.data[0] = 200+Math.pow(2, 32); +_assertSame(imgdata.data[0], 255, "imgdata.data[\""+(0)+"\"]", "255"); +imgdata.data[0] = 100; +imgdata.data[0] = -200-Math.pow(2, 32); +_assertSame(imgdata.data[0], 0, "imgdata.data[\""+(0)+"\"]", "0"); +imgdata.data[0] = 100; +imgdata.data[0] = Math.pow(10, 39); +_assertSame(imgdata.data[0], 255, "imgdata.data[\""+(0)+"\"]", "255"); +imgdata.data[0] = 100; +imgdata.data[0] = -Math.pow(10, 39); +_assertSame(imgdata.data[0], 0, "imgdata.data[\""+(0)+"\"]", "0"); +imgdata.data[0] = 100; +imgdata.data[0] = -Infinity; +_assertSame(imgdata.data[0], 0, "imgdata.data[\""+(0)+"\"]", "0"); +imgdata.data[0] = 100; +imgdata.data[0] = Infinity; +_assertSame(imgdata.data[0], 255, "imgdata.data[\""+(0)+"\"]", "255"); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.clamp.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.clamp.worker.js new file mode 100644 index 0000000000..0e2a33c75e --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.clamp.worker.js @@ -0,0 +1,47 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.object.clamp +// Description:ImageData.data clamps numbers to [0, 255] +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("ImageData.data clamps numbers to [0, 255]"); +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'); + +var imgdata = ctx.getImageData(0, 0, 10, 10); +imgdata.data[0] = 100; +imgdata.data[0] = 300; +_assertSame(imgdata.data[0], 255, "imgdata.data[\""+(0)+"\"]", "255"); +imgdata.data[0] = 100; +imgdata.data[0] = -100; +_assertSame(imgdata.data[0], 0, "imgdata.data[\""+(0)+"\"]", "0"); +imgdata.data[0] = 100; +imgdata.data[0] = 200+Math.pow(2, 32); +_assertSame(imgdata.data[0], 255, "imgdata.data[\""+(0)+"\"]", "255"); +imgdata.data[0] = 100; +imgdata.data[0] = -200-Math.pow(2, 32); +_assertSame(imgdata.data[0], 0, "imgdata.data[\""+(0)+"\"]", "0"); +imgdata.data[0] = 100; +imgdata.data[0] = Math.pow(10, 39); +_assertSame(imgdata.data[0], 255, "imgdata.data[\""+(0)+"\"]", "255"); +imgdata.data[0] = 100; +imgdata.data[0] = -Math.pow(10, 39); +_assertSame(imgdata.data[0], 0, "imgdata.data[\""+(0)+"\"]", "0"); +imgdata.data[0] = 100; +imgdata.data[0] = -Infinity; +_assertSame(imgdata.data[0], 0, "imgdata.data[\""+(0)+"\"]", "0"); +imgdata.data[0] = 100; +imgdata.data[0] = Infinity; +_assertSame(imgdata.data[0], 255, "imgdata.data[\""+(0)+"\"]", "255"); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.nan.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.nan.html new file mode 100644 index 0000000000..9fce409778 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.nan.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.object.nan</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.object.nan</h1> +<p class="desc">ImageData.data converts NaN to 0</p> + + +<script> +var t = async_test("ImageData.data converts NaN to 0"); +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'); + +var imgdata = ctx.getImageData(0, 0, 10, 10); +imgdata.data[0] = 100; +imgdata.data[0] = NaN; +_assertSame(imgdata.data[0], 0, "imgdata.data[\""+(0)+"\"]", "0"); +imgdata.data[0] = 100; +imgdata.data[0] = "cheese"; +_assertSame(imgdata.data[0], 0, "imgdata.data[\""+(0)+"\"]", "0"); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.nan.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.nan.worker.js new file mode 100644 index 0000000000..ef2eb21b37 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.nan.worker.js @@ -0,0 +1,29 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.object.nan +// Description:ImageData.data converts NaN to 0 +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("ImageData.data converts NaN to 0"); +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'); + +var imgdata = ctx.getImageData(0, 0, 10, 10); +imgdata.data[0] = 100; +imgdata.data[0] = NaN; +_assertSame(imgdata.data[0], 0, "imgdata.data[\""+(0)+"\"]", "0"); +imgdata.data[0] = 100; +imgdata.data[0] = "cheese"; +_assertSame(imgdata.data[0], 0, "imgdata.data[\""+(0)+"\"]", "0"); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.properties.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.properties.html new file mode 100644 index 0000000000..05a4106b6b --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.properties.html @@ -0,0 +1,30 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.object.properties</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.object.properties</h1> +<p class="desc">ImageData objects have the right properties</p> + + +<script> +var t = async_test("ImageData objects have the right properties"); +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'); + +var imgdata = ctx.getImageData(0, 0, 10, 10); +_assertSame(typeof(imgdata.width), 'number', "typeof(imgdata.width)", "'number'"); +_assertSame(typeof(imgdata.height), 'number', "typeof(imgdata.height)", "'number'"); +_assertSame(typeof(imgdata.data), 'object', "typeof(imgdata.data)", "'object'"); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.properties.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.properties.worker.js new file mode 100644 index 0000000000..42c89ef117 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.properties.worker.js @@ -0,0 +1,26 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.object.properties +// Description:ImageData objects have the right properties +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("ImageData objects have the right properties"); +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'); + +var imgdata = ctx.getImageData(0, 0, 10, 10); +_assertSame(typeof(imgdata.width), 'number', "typeof(imgdata.width)", "'number'"); +_assertSame(typeof(imgdata.height), 'number', "typeof(imgdata.height)", "'number'"); +_assertSame(typeof(imgdata.data), 'object', "typeof(imgdata.data)", "'object'"); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.readonly.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.readonly.html new file mode 100644 index 0000000000..5fbdfc5ce0 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.readonly.html @@ -0,0 +1,40 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.object.readonly</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.object.readonly</h1> +<p class="desc">ImageData objects properties are read-only</p> + + +<script> +var t = async_test("ImageData objects properties are read-only"); +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'); + +var imgdata = ctx.getImageData(0, 0, 10, 10); +var w = imgdata.width; +var h = imgdata.height; +var d = imgdata.data; +imgdata.width = 123; +imgdata.height = 123; +imgdata.data = [100,100,100,100]; +_assertSame(imgdata.width, w, "imgdata.width", "w"); +_assertSame(imgdata.height, h, "imgdata.height", "h"); +_assertSame(imgdata.data, d, "imgdata.data", "d"); +_assertSame(imgdata.data[0], 0, "imgdata.data[\""+(0)+"\"]", "0"); +_assertSame(imgdata.data[1], 0, "imgdata.data[\""+(1)+"\"]", "0"); +_assertSame(imgdata.data[2], 0, "imgdata.data[\""+(2)+"\"]", "0"); +_assertSame(imgdata.data[3], 0, "imgdata.data[\""+(3)+"\"]", "0"); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.readonly.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.readonly.worker.js new file mode 100644 index 0000000000..068761e2e6 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.readonly.worker.js @@ -0,0 +1,36 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.object.readonly +// Description:ImageData objects properties are read-only +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("ImageData objects properties are read-only"); +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'); + +var imgdata = ctx.getImageData(0, 0, 10, 10); +var w = imgdata.width; +var h = imgdata.height; +var d = imgdata.data; +imgdata.width = 123; +imgdata.height = 123; +imgdata.data = [100,100,100,100]; +_assertSame(imgdata.width, w, "imgdata.width", "w"); +_assertSame(imgdata.height, h, "imgdata.height", "h"); +_assertSame(imgdata.data, d, "imgdata.data", "d"); +_assertSame(imgdata.data[0], 0, "imgdata.data[\""+(0)+"\"]", "0"); +_assertSame(imgdata.data[1], 0, "imgdata.data[\""+(1)+"\"]", "0"); +_assertSame(imgdata.data[2], 0, "imgdata.data[\""+(2)+"\"]", "0"); +_assertSame(imgdata.data[3], 0, "imgdata.data[\""+(3)+"\"]", "0"); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.round.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.round.html new file mode 100644 index 0000000000..8b362a01c6 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.round.html @@ -0,0 +1,55 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.object.round</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.object.round</h1> +<p class="desc">ImageData.data rounds numbers with round-to-zero</p> + + +<script> +var t = async_test("ImageData.data rounds numbers with round-to-zero"); +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'); + +var imgdata = ctx.getImageData(0, 0, 10, 10); +imgdata.data[0] = 0.499; +_assertSame(imgdata.data[0], 0, "imgdata.data[\""+(0)+"\"]", "0"); +imgdata.data[0] = 0.5; +_assertSame(imgdata.data[0], 0, "imgdata.data[\""+(0)+"\"]", "0"); +imgdata.data[0] = 0.501; +_assertSame(imgdata.data[0], 1, "imgdata.data[\""+(0)+"\"]", "1"); +imgdata.data[0] = 1.499; +_assertSame(imgdata.data[0], 1, "imgdata.data[\""+(0)+"\"]", "1"); +imgdata.data[0] = 1.5; +_assertSame(imgdata.data[0], 2, "imgdata.data[\""+(0)+"\"]", "2"); +imgdata.data[0] = 1.501; +_assertSame(imgdata.data[0], 2, "imgdata.data[\""+(0)+"\"]", "2"); +imgdata.data[0] = 2.5; +_assertSame(imgdata.data[0], 2, "imgdata.data[\""+(0)+"\"]", "2"); +imgdata.data[0] = 3.5; +_assertSame(imgdata.data[0], 4, "imgdata.data[\""+(0)+"\"]", "4"); +imgdata.data[0] = 252.5; +_assertSame(imgdata.data[0], 252, "imgdata.data[\""+(0)+"\"]", "252"); +imgdata.data[0] = 253.5; +_assertSame(imgdata.data[0], 254, "imgdata.data[\""+(0)+"\"]", "254"); +imgdata.data[0] = 254.5; +_assertSame(imgdata.data[0], 254, "imgdata.data[\""+(0)+"\"]", "254"); +imgdata.data[0] = 256.5; +_assertSame(imgdata.data[0], 255, "imgdata.data[\""+(0)+"\"]", "255"); +imgdata.data[0] = -0.5; +_assertSame(imgdata.data[0], 0, "imgdata.data[\""+(0)+"\"]", "0"); +imgdata.data[0] = -1.5; +_assertSame(imgdata.data[0], 0, "imgdata.data[\""+(0)+"\"]", "0"); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.round.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.round.worker.js new file mode 100644 index 0000000000..4a88db9cdd --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.round.worker.js @@ -0,0 +1,51 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.object.round +// Description:ImageData.data rounds numbers with round-to-zero +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("ImageData.data rounds numbers with round-to-zero"); +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'); + +var imgdata = ctx.getImageData(0, 0, 10, 10); +imgdata.data[0] = 0.499; +_assertSame(imgdata.data[0], 0, "imgdata.data[\""+(0)+"\"]", "0"); +imgdata.data[0] = 0.5; +_assertSame(imgdata.data[0], 0, "imgdata.data[\""+(0)+"\"]", "0"); +imgdata.data[0] = 0.501; +_assertSame(imgdata.data[0], 1, "imgdata.data[\""+(0)+"\"]", "1"); +imgdata.data[0] = 1.499; +_assertSame(imgdata.data[0], 1, "imgdata.data[\""+(0)+"\"]", "1"); +imgdata.data[0] = 1.5; +_assertSame(imgdata.data[0], 2, "imgdata.data[\""+(0)+"\"]", "2"); +imgdata.data[0] = 1.501; +_assertSame(imgdata.data[0], 2, "imgdata.data[\""+(0)+"\"]", "2"); +imgdata.data[0] = 2.5; +_assertSame(imgdata.data[0], 2, "imgdata.data[\""+(0)+"\"]", "2"); +imgdata.data[0] = 3.5; +_assertSame(imgdata.data[0], 4, "imgdata.data[\""+(0)+"\"]", "4"); +imgdata.data[0] = 252.5; +_assertSame(imgdata.data[0], 252, "imgdata.data[\""+(0)+"\"]", "252"); +imgdata.data[0] = 253.5; +_assertSame(imgdata.data[0], 254, "imgdata.data[\""+(0)+"\"]", "254"); +imgdata.data[0] = 254.5; +_assertSame(imgdata.data[0], 254, "imgdata.data[\""+(0)+"\"]", "254"); +imgdata.data[0] = 256.5; +_assertSame(imgdata.data[0], 255, "imgdata.data[\""+(0)+"\"]", "255"); +imgdata.data[0] = -0.5; +_assertSame(imgdata.data[0], 0, "imgdata.data[\""+(0)+"\"]", "0"); +imgdata.data[0] = -1.5; +_assertSame(imgdata.data[0], 0, "imgdata.data[\""+(0)+"\"]", "0"); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.set.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.set.html new file mode 100644 index 0000000000..95305c5bc4 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.set.html @@ -0,0 +1,31 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.object.set</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.object.set</h1> +<p class="desc">ImageData.data can be modified</p> + + +<script> +var t = async_test("ImageData.data can be modified"); +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'); + +var imgdata = ctx.getImageData(0, 0, 10, 10); +imgdata.data[0] = 100; +_assertSame(imgdata.data[0], 100, "imgdata.data[\""+(0)+"\"]", "100"); +imgdata.data[0] = 200; +_assertSame(imgdata.data[0], 200, "imgdata.data[\""+(0)+"\"]", "200"); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.set.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.set.worker.js new file mode 100644 index 0000000000..fcb16ab577 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.set.worker.js @@ -0,0 +1,27 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.object.set +// Description:ImageData.data can be modified +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("ImageData.data can be modified"); +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'); + +var imgdata = ctx.getImageData(0, 0, 10, 10); +imgdata.data[0] = 100; +_assertSame(imgdata.data[0], 100, "imgdata.data[\""+(0)+"\"]", "100"); +imgdata.data[0] = 200; +_assertSame(imgdata.data[0], 200, "imgdata.data[\""+(0)+"\"]", "200"); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.string.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.string.html new file mode 100644 index 0000000000..a7b5d578d2 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.string.html @@ -0,0 +1,36 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.object.string</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.object.string</h1> +<p class="desc">ImageData.data converts strings to numbers with ToNumber</p> + + +<script> +var t = async_test("ImageData.data converts strings to numbers with ToNumber"); +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'); + +var imgdata = ctx.getImageData(0, 0, 10, 10); +imgdata.data[0] = 100; +imgdata.data[0] = "110"; +_assertSame(imgdata.data[0], 110, "imgdata.data[\""+(0)+"\"]", "110"); +imgdata.data[0] = 100; +imgdata.data[0] = "0x78"; +_assertSame(imgdata.data[0], 120, "imgdata.data[\""+(0)+"\"]", "120"); +imgdata.data[0] = 100; +imgdata.data[0] = " +130e0 "; +_assertSame(imgdata.data[0], 130, "imgdata.data[\""+(0)+"\"]", "130"); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.string.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.string.worker.js new file mode 100644 index 0000000000..6c2dcc8b42 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.string.worker.js @@ -0,0 +1,32 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.object.string +// Description:ImageData.data converts strings to numbers with ToNumber +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("ImageData.data converts strings to numbers with ToNumber"); +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'); + +var imgdata = ctx.getImageData(0, 0, 10, 10); +imgdata.data[0] = 100; +imgdata.data[0] = "110"; +_assertSame(imgdata.data[0], 110, "imgdata.data[\""+(0)+"\"]", "110"); +imgdata.data[0] = 100; +imgdata.data[0] = "0x78"; +_assertSame(imgdata.data[0], 120, "imgdata.data[\""+(0)+"\"]", "120"); +imgdata.data[0] = 100; +imgdata.data[0] = " +130e0 "; +_assertSame(imgdata.data[0], 130, "imgdata.data[\""+(0)+"\"]", "130"); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.undefined.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.undefined.html new file mode 100644 index 0000000000..a2533a52e6 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.undefined.html @@ -0,0 +1,30 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.object.undefined</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.object.undefined</h1> +<p class="desc">ImageData.data converts undefined to 0</p> + + +<script> +var t = async_test("ImageData.data converts undefined to 0"); +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'); + +var imgdata = ctx.getImageData(0, 0, 10, 10); +imgdata.data[0] = 100; +imgdata.data[0] = undefined; +_assertSame(imgdata.data[0], 0, "imgdata.data[\""+(0)+"\"]", "0"); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.undefined.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.undefined.worker.js new file mode 100644 index 0000000000..f6b62993f6 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.object.undefined.worker.js @@ -0,0 +1,26 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.object.undefined +// Description:ImageData.data converts undefined to 0 +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("ImageData.data converts undefined to 0"); +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'); + +var imgdata = ctx.getImageData(0, 0, 10, 10); +imgdata.data[0] = 100; +imgdata.data[0] = undefined; +_assertSame(imgdata.data[0], 0, "imgdata.data[\""+(0)+"\"]", "0"); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.alpha.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.alpha.html new file mode 100644 index 0000000000..ecda85bd12 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.alpha.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.put.alpha</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.put.alpha</h1> +<p class="desc">putImageData() puts non-solid image data correctly</p> + + +<script> +var t = async_test("putImageData() puts non-solid image data correctly"); +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'); + +ctx.fillStyle = 'rgba(0, 255, 0, 0.25)'; +ctx.fillRect(0, 0, 100, 50) +var imgdata = ctx.getImageData(0, 0, 100, 50); +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50) +ctx.putImageData(imgdata, 0, 0); +_assertPixelApprox(canvas, 50,25, 0,255,0,64, 2); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.alpha.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.alpha.worker.js new file mode 100644 index 0000000000..3349c69286 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.alpha.worker.js @@ -0,0 +1,29 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.put.alpha +// Description:putImageData() puts non-solid image data correctly +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("putImageData() puts non-solid image data correctly"); +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'); + +ctx.fillStyle = 'rgba(0, 255, 0, 0.25)'; +ctx.fillRect(0, 0, 100, 50) +var imgdata = ctx.getImageData(0, 0, 100, 50); +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50) +ctx.putImageData(imgdata, 0, 0); +_assertPixelApprox(canvas, 50,25, 0,255,0,64, 2); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.basic.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.basic.html new file mode 100644 index 0000000000..d140cc39ab --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.basic.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.put.basic</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.put.basic</h1> +<p class="desc">putImageData() puts image data from getImageData() onto the canvas</p> + + +<script> +var t = async_test("putImageData() puts 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'); + +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50) +var imgdata = ctx.getImageData(0, 0, 100, 50); +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50) +ctx.putImageData(imgdata, 0, 0); +_assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.basic.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.basic.worker.js new file mode 100644 index 0000000000..276fea2d12 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.basic.worker.js @@ -0,0 +1,29 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.put.basic +// Description:putImageData() puts 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 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'); + +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50) +var imgdata = ctx.getImageData(0, 0, 100, 50); +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50) +ctx.putImageData(imgdata, 0, 0); +_assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.clip.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.clip.html new file mode 100644 index 0000000000..121a45fae8 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.clip.html @@ -0,0 +1,37 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.put.clip</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.put.clip</h1> +<p class="desc">putImageData() is not affected by clipping regions</p> + + +<script> +var t = async_test("putImageData() is not affected by clipping regions"); +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'); + +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50) +var imgdata = ctx.getImageData(0, 0, 100, 50); +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50) +ctx.beginPath(); +ctx.rect(0, 0, 50, 50); +ctx.clip(); +ctx.putImageData(imgdata, 0, 0); +_assertPixelApprox(canvas, 25,25, 0,255,0,255, 2); +_assertPixelApprox(canvas, 75,25, 0,255,0,255, 2); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.clip.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.clip.worker.js new file mode 100644 index 0000000000..9188b3cf88 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.clip.worker.js @@ -0,0 +1,33 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.put.clip +// Description:putImageData() is not affected by clipping regions +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("putImageData() is not affected by clipping regions"); +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'); + +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50) +var imgdata = ctx.getImageData(0, 0, 100, 50); +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50) +ctx.beginPath(); +ctx.rect(0, 0, 50, 50); +ctx.clip(); +ctx.putImageData(imgdata, 0, 0); +_assertPixelApprox(canvas, 25,25, 0,255,0,255, 2); +_assertPixelApprox(canvas, 75,25, 0,255,0,255, 2); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.created.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.created.html new file mode 100644 index 0000000000..7ade3b1deb --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.created.html @@ -0,0 +1,37 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.put.created</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.put.created</h1> +<p class="desc">putImageData() puts image data from createImageData() onto the canvas</p> + + +<script> +var t = async_test("putImageData() puts image data from createImageData() 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'); + +var imgdata = ctx.createImageData(100, 50); +for (var i = 0; i < imgdata.data.length; i += 4) { + imgdata.data[i] = 0; + imgdata.data[i+1] = 255; + imgdata.data[i+2] = 0; + imgdata.data[i+3] = 255; +} +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50) +ctx.putImageData(imgdata, 0, 0); +_assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.created.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.created.worker.js new file mode 100644 index 0000000000..fd6b5ec8e0 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.created.worker.js @@ -0,0 +1,33 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.put.created +// Description:putImageData() puts image data from createImageData() onto the canvas +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("putImageData() puts image data from createImageData() 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'); + +var imgdata = ctx.createImageData(100, 50); +for (var i = 0; i < imgdata.data.length; i += 4) { + imgdata.data[i] = 0; + imgdata.data[i+1] = 255; + imgdata.data[i+2] = 0; + imgdata.data[i+3] = 255; +} +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50) +ctx.putImageData(imgdata, 0, 0); +_assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.cross.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.cross.html new file mode 100644 index 0000000000..af90d71991 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.cross.html @@ -0,0 +1,35 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.put.cross</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.put.cross</h1> +<p class="desc">putImageData() accepts image data got from a different canvas</p> + + +<script> +var t = async_test("putImageData() accepts image data got from a different 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'); + +var offscreenCanvas2 = new OffscreenCanvas(100, 50); +var ctx2 = offscreenCanvas2.getContext('2d'); +ctx2.fillStyle = '#0f0'; +ctx2.fillRect(0, 0, 100, 50) +var imgdata = ctx2.getImageData(0, 0, 100, 50); +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50) +ctx.putImageData(imgdata, 0, 0); +_assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.cross.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.cross.worker.js new file mode 100644 index 0000000000..bdeaa35245 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.cross.worker.js @@ -0,0 +1,31 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.put.cross +// Description:putImageData() accepts image data got from a different canvas +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("putImageData() accepts image data got from a different 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'); + +var offscreenCanvas2 = new OffscreenCanvas(100, 50); +var ctx2 = offscreenCanvas2.getContext('2d'); +ctx2.fillStyle = '#0f0'; +ctx2.fillRect(0, 0, 100, 50) +var imgdata = ctx2.getImageData(0, 0, 100, 50); +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50) +ctx.putImageData(imgdata, 0, 0); +_assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.dirty.negative.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.dirty.negative.html new file mode 100644 index 0000000000..e2fbcb2702 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.dirty.negative.html @@ -0,0 +1,41 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.put.dirty.negative</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.put.dirty.negative</h1> +<p class="desc">putImageData() handles negative-sized dirty rectangles correctly</p> + + +<script> +var t = async_test("putImageData() handles negative-sized dirty rectangles correctly"); +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'); + +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50) +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 20, 20) +var imgdata = ctx.getImageData(0, 0, 100, 50); +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50) +ctx.fillStyle = '#f00'; +ctx.fillRect(40, 20, 20, 20) +ctx.putImageData(imgdata, 40, 20, 20, 20, -20, -20); +_assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); +_assertPixelApprox(canvas, 35,25, 0,255,0,255, 2); +_assertPixelApprox(canvas, 65,25, 0,255,0,255, 2); +_assertPixelApprox(canvas, 50,15, 0,255,0,255, 2); +_assertPixelApprox(canvas, 50,45, 0,255,0,255, 2); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.dirty.negative.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.dirty.negative.worker.js new file mode 100644 index 0000000000..5eec264c75 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.dirty.negative.worker.js @@ -0,0 +1,37 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.put.dirty.negative +// Description:putImageData() handles negative-sized dirty rectangles correctly +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("putImageData() handles negative-sized dirty rectangles correctly"); +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'); + +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50) +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 20, 20) +var imgdata = ctx.getImageData(0, 0, 100, 50); +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50) +ctx.fillStyle = '#f00'; +ctx.fillRect(40, 20, 20, 20) +ctx.putImageData(imgdata, 40, 20, 20, 20, -20, -20); +_assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); +_assertPixelApprox(canvas, 35,25, 0,255,0,255, 2); +_assertPixelApprox(canvas, 65,25, 0,255,0,255, 2); +_assertPixelApprox(canvas, 50,15, 0,255,0,255, 2); +_assertPixelApprox(canvas, 50,45, 0,255,0,255, 2); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.dirty.outside.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.dirty.outside.html new file mode 100644 index 0000000000..aaf48a762b --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.dirty.outside.html @@ -0,0 +1,42 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.put.dirty.outside</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.put.dirty.outside</h1> +<p class="desc">putImageData() handles dirty rectangles outside the canvas correctly</p> + + +<script> +var t = async_test("putImageData() handles dirty rectangles outside the canvas correctly"); +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'); + +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50) +var imgdata = ctx.getImageData(0, 0, 100, 50); +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50) +ctx.putImageData(imgdata, 100, 20, 20, 20, -20, -20); +ctx.putImageData(imgdata, 200, 200, 0, 0, 100, 50); +ctx.putImageData(imgdata, 40, 20, -30, -20, 30, 20); +ctx.putImageData(imgdata, -30, 20, 0, 0, 30, 20); +_assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); +_assertPixelApprox(canvas, 98,15, 0,255,0,255, 2); +_assertPixelApprox(canvas, 98,25, 0,255,0,255, 2); +_assertPixelApprox(canvas, 98,45, 0,255,0,255, 2); +_assertPixelApprox(canvas, 1,5, 0,255,0,255, 2); +_assertPixelApprox(canvas, 1,25, 0,255,0,255, 2); +_assertPixelApprox(canvas, 1,45, 0,255,0,255, 2); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.dirty.outside.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.dirty.outside.worker.js new file mode 100644 index 0000000000..9f537135da --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.dirty.outside.worker.js @@ -0,0 +1,38 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.put.dirty.outside +// Description:putImageData() handles dirty rectangles outside the canvas correctly +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("putImageData() handles dirty rectangles outside the canvas correctly"); +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'); + +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50) +var imgdata = ctx.getImageData(0, 0, 100, 50); +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50) +ctx.putImageData(imgdata, 100, 20, 20, 20, -20, -20); +ctx.putImageData(imgdata, 200, 200, 0, 0, 100, 50); +ctx.putImageData(imgdata, 40, 20, -30, -20, 30, 20); +ctx.putImageData(imgdata, -30, 20, 0, 0, 30, 20); +_assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); +_assertPixelApprox(canvas, 98,15, 0,255,0,255, 2); +_assertPixelApprox(canvas, 98,25, 0,255,0,255, 2); +_assertPixelApprox(canvas, 98,45, 0,255,0,255, 2); +_assertPixelApprox(canvas, 1,5, 0,255,0,255, 2); +_assertPixelApprox(canvas, 1,25, 0,255,0,255, 2); +_assertPixelApprox(canvas, 1,45, 0,255,0,255, 2); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.dirty.rect1.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.dirty.rect1.html new file mode 100644 index 0000000000..e973eb6ca4 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.dirty.rect1.html @@ -0,0 +1,41 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.put.dirty.rect1</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.put.dirty.rect1</h1> +<p class="desc">putImageData() only modifies areas inside the dirty rectangle, using width and height</p> + + +<script> +var t = async_test("putImageData() only modifies areas inside the dirty rectangle, using width and height"); +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'); + +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50) +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 20, 20) +var imgdata = ctx.getImageData(0, 0, 100, 50); +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50) +ctx.fillStyle = '#f00'; +ctx.fillRect(40, 20, 20, 20) +ctx.putImageData(imgdata, 40, 20, 0, 0, 20, 20); +_assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); +_assertPixelApprox(canvas, 35,25, 0,255,0,255, 2); +_assertPixelApprox(canvas, 65,25, 0,255,0,255, 2); +_assertPixelApprox(canvas, 50,15, 0,255,0,255, 2); +_assertPixelApprox(canvas, 50,45, 0,255,0,255, 2); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.dirty.rect1.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.dirty.rect1.worker.js new file mode 100644 index 0000000000..fdbe6561ce --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.dirty.rect1.worker.js @@ -0,0 +1,37 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.put.dirty.rect1 +// Description:putImageData() only modifies areas inside the dirty rectangle, using width and height +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("putImageData() only modifies areas inside the dirty rectangle, using width and height"); +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'); + +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50) +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 20, 20) +var imgdata = ctx.getImageData(0, 0, 100, 50); +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50) +ctx.fillStyle = '#f00'; +ctx.fillRect(40, 20, 20, 20) +ctx.putImageData(imgdata, 40, 20, 0, 0, 20, 20); +_assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); +_assertPixelApprox(canvas, 35,25, 0,255,0,255, 2); +_assertPixelApprox(canvas, 65,25, 0,255,0,255, 2); +_assertPixelApprox(canvas, 50,15, 0,255,0,255, 2); +_assertPixelApprox(canvas, 50,45, 0,255,0,255, 2); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.dirty.rect2.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.dirty.rect2.html new file mode 100644 index 0000000000..9b275429e6 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.dirty.rect2.html @@ -0,0 +1,41 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.put.dirty.rect2</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.put.dirty.rect2</h1> +<p class="desc">putImageData() only modifies areas inside the dirty rectangle, using x and y</p> + + +<script> +var t = async_test("putImageData() only modifies areas inside the dirty rectangle, using x and y"); +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'); + +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50) +ctx.fillStyle = '#0f0'; +ctx.fillRect(60, 30, 20, 20) +var imgdata = ctx.getImageData(0, 0, 100, 50); +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50) +ctx.fillStyle = '#f00'; +ctx.fillRect(40, 20, 20, 20) +ctx.putImageData(imgdata, -20, -10, 60, 30, 20, 20); +_assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); +_assertPixelApprox(canvas, 35,25, 0,255,0,255, 2); +_assertPixelApprox(canvas, 65,25, 0,255,0,255, 2); +_assertPixelApprox(canvas, 50,15, 0,255,0,255, 2); +_assertPixelApprox(canvas, 50,45, 0,255,0,255, 2); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.dirty.rect2.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.dirty.rect2.worker.js new file mode 100644 index 0000000000..3578ceec25 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.dirty.rect2.worker.js @@ -0,0 +1,37 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.put.dirty.rect2 +// Description:putImageData() only modifies areas inside the dirty rectangle, using x and y +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("putImageData() only modifies areas inside the dirty rectangle, using x and y"); +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'); + +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50) +ctx.fillStyle = '#0f0'; +ctx.fillRect(60, 30, 20, 20) +var imgdata = ctx.getImageData(0, 0, 100, 50); +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50) +ctx.fillStyle = '#f00'; +ctx.fillRect(40, 20, 20, 20) +ctx.putImageData(imgdata, -20, -10, 60, 30, 20, 20); +_assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); +_assertPixelApprox(canvas, 35,25, 0,255,0,255, 2); +_assertPixelApprox(canvas, 65,25, 0,255,0,255, 2); +_assertPixelApprox(canvas, 50,15, 0,255,0,255, 2); +_assertPixelApprox(canvas, 50,45, 0,255,0,255, 2); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.dirty.zero.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.dirty.zero.html new file mode 100644 index 0000000000..c1b6735d25 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.dirty.zero.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.put.dirty.zero</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.put.dirty.zero</h1> +<p class="desc">putImageData() with zero-sized dirty rectangle puts nothing</p> + + +<script> +var t = async_test("putImageData() with zero-sized dirty rectangle puts nothing"); +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'); + +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50) +var imgdata = ctx.getImageData(0, 0, 100, 50); +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50) +ctx.putImageData(imgdata, 0, 0, 0, 0, 0, 0); +_assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.dirty.zero.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.dirty.zero.worker.js new file mode 100644 index 0000000000..db09379c62 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.dirty.zero.worker.js @@ -0,0 +1,29 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.put.dirty.zero +// Description:putImageData() with zero-sized dirty rectangle puts nothing +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("putImageData() with zero-sized dirty rectangle puts nothing"); +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'); + +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50) +var imgdata = ctx.getImageData(0, 0, 100, 50); +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50) +ctx.putImageData(imgdata, 0, 0, 0, 0, 0, 0); +_assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.modified.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.modified.html new file mode 100644 index 0000000000..543d9ff293 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.modified.html @@ -0,0 +1,38 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.put.modified</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.put.modified</h1> +<p class="desc">putImageData() puts modified image data correctly</p> + + +<script> +var t = async_test("putImageData() puts modified image data correctly"); +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'); + +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50) +ctx.fillStyle = '#f00'; +ctx.fillRect(45, 20, 10, 10) +var imgdata = ctx.getImageData(45, 20, 10, 10); +for (var i = 0, len = imgdata.width*imgdata.height*4; i < len; i += 4) +{ + imgdata.data[i] = 0; + imgdata.data[i+1] = 255; +} +ctx.putImageData(imgdata, 45, 20); +_assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.modified.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.modified.worker.js new file mode 100644 index 0000000000..b238d56cf9 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.modified.worker.js @@ -0,0 +1,34 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.put.modified +// Description:putImageData() puts modified image data correctly +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("putImageData() puts modified image data correctly"); +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'); + +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50) +ctx.fillStyle = '#f00'; +ctx.fillRect(45, 20, 10, 10) +var imgdata = ctx.getImageData(45, 20, 10, 10); +for (var i = 0, len = imgdata.width*imgdata.height*4; i < len; i += 4) +{ + imgdata.data[i] = 0; + imgdata.data[i+1] = 255; +} +ctx.putImageData(imgdata, 45, 20); +_assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.nonfinite.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.nonfinite.html new file mode 100644 index 0000000000..6590f761ad --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.nonfinite.html @@ -0,0 +1,109 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.put.nonfinite</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.put.nonfinite</h1> +<p class="desc">putImageData() throws TypeError if arguments are not finite</p> + + +<script> +var t = async_test("putImageData() throws TypeError if arguments are not finite"); +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'); + +var imgdata = ctx.getImageData(0, 0, 10, 10); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, -Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, NaN, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, -Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, NaN); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, 10, 10, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, -Infinity, 10, 10, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, NaN, 10, 10, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, Infinity, 10, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, -Infinity, 10, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, NaN, 10, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, Infinity, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, -Infinity, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, NaN, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, 10, Infinity, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, 10, -Infinity, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, 10, NaN, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, 10, 10, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, 10, 10, -Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, 10, 10, NaN, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, 10, 10, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, 10, 10, 10, -Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, 10, 10, 10, NaN); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, Infinity, 10, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, Infinity, Infinity, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, Infinity, Infinity, Infinity, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, Infinity, Infinity, Infinity, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, Infinity, Infinity, Infinity, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, Infinity, Infinity, 10, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, Infinity, Infinity, 10, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, Infinity, Infinity, 10, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, Infinity, 10, Infinity, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, Infinity, 10, Infinity, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, Infinity, 10, Infinity, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, Infinity, 10, Infinity, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, Infinity, 10, 10, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, Infinity, 10, 10, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, Infinity, 10, 10, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, 10, Infinity, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, 10, Infinity, Infinity, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, 10, Infinity, Infinity, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, 10, Infinity, Infinity, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, 10, Infinity, Infinity, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, 10, Infinity, 10, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, 10, Infinity, 10, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, 10, Infinity, 10, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, 10, 10, Infinity, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, 10, 10, Infinity, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, 10, 10, Infinity, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, 10, 10, Infinity, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, 10, 10, 10, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, 10, 10, 10, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, 10, 10, 10, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, Infinity, Infinity, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, Infinity, Infinity, Infinity, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, Infinity, Infinity, Infinity, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, Infinity, Infinity, Infinity, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, Infinity, Infinity, Infinity, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, Infinity, Infinity, 10, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, Infinity, Infinity, 10, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, Infinity, Infinity, 10, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, Infinity, 10, Infinity, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, Infinity, 10, Infinity, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, Infinity, 10, Infinity, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, Infinity, 10, Infinity, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, Infinity, 10, 10, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, Infinity, 10, 10, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, Infinity, 10, 10, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, Infinity, Infinity, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, Infinity, Infinity, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, Infinity, Infinity, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, Infinity, Infinity, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, Infinity, 10, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, Infinity, 10, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, Infinity, 10, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, 10, Infinity, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, 10, Infinity, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, 10, Infinity, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, 10, 10, Infinity, Infinity); }); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.nonfinite.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.nonfinite.worker.js new file mode 100644 index 0000000000..04298fa99f --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.nonfinite.worker.js @@ -0,0 +1,105 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.put.nonfinite +// Description:putImageData() throws TypeError if arguments are not finite +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("putImageData() throws TypeError if arguments are not finite"); +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'); + +var imgdata = ctx.getImageData(0, 0, 10, 10); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, -Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, NaN, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, -Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, NaN); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, 10, 10, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, -Infinity, 10, 10, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, NaN, 10, 10, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, Infinity, 10, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, -Infinity, 10, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, NaN, 10, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, Infinity, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, -Infinity, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, NaN, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, 10, Infinity, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, 10, -Infinity, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, 10, NaN, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, 10, 10, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, 10, 10, -Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, 10, 10, NaN, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, 10, 10, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, 10, 10, 10, -Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, 10, 10, 10, NaN); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, Infinity, 10, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, Infinity, Infinity, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, Infinity, Infinity, Infinity, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, Infinity, Infinity, Infinity, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, Infinity, Infinity, Infinity, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, Infinity, Infinity, 10, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, Infinity, Infinity, 10, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, Infinity, Infinity, 10, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, Infinity, 10, Infinity, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, Infinity, 10, Infinity, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, Infinity, 10, Infinity, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, Infinity, 10, Infinity, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, Infinity, 10, 10, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, Infinity, 10, 10, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, Infinity, 10, 10, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, 10, Infinity, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, 10, Infinity, Infinity, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, 10, Infinity, Infinity, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, 10, Infinity, Infinity, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, 10, Infinity, Infinity, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, 10, Infinity, 10, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, 10, Infinity, 10, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, 10, Infinity, 10, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, 10, 10, Infinity, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, 10, 10, Infinity, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, 10, 10, Infinity, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, 10, 10, Infinity, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, 10, 10, 10, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, 10, 10, 10, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, Infinity, 10, 10, 10, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, Infinity, Infinity, 10, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, Infinity, Infinity, Infinity, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, Infinity, Infinity, Infinity, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, Infinity, Infinity, Infinity, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, Infinity, Infinity, Infinity, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, Infinity, Infinity, 10, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, Infinity, Infinity, 10, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, Infinity, Infinity, 10, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, Infinity, 10, Infinity, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, Infinity, 10, Infinity, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, Infinity, 10, Infinity, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, Infinity, 10, Infinity, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, Infinity, 10, 10, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, Infinity, 10, 10, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, Infinity, 10, 10, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, Infinity, Infinity, 10, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, Infinity, Infinity, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, Infinity, Infinity, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, Infinity, Infinity, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, Infinity, 10, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, Infinity, 10, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, Infinity, 10, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, 10, Infinity, Infinity, 10); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, 10, Infinity, Infinity, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, 10, Infinity, 10, Infinity); }); +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 10, 10, 10, 10, Infinity, Infinity); }); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.null.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.null.html new file mode 100644 index 0000000000..3a51c9719c --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.null.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.put.null</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.put.null</h1> +<p class="desc">putImageData() with null imagedata throws TypeError</p> + + +<script> +var t = async_test("putImageData() with null imagedata throws TypeError"); +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'); + +assert_throws_js(TypeError, function() { ctx.putImageData(null, 0, 0); }); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.null.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.null.worker.js new file mode 100644 index 0000000000..0b5b746ba0 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.null.worker.js @@ -0,0 +1,23 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.put.null +// Description:putImageData() with null imagedata throws TypeError +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("putImageData() with null imagedata throws TypeError"); +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'); + +assert_throws_js(TypeError, function() { ctx.putImageData(null, 0, 0); }); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.path.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.path.html new file mode 100644 index 0000000000..53e3ac4fce --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.path.html @@ -0,0 +1,34 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.put.path</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.put.path</h1> +<p class="desc">putImageData() does not affect the current path</p> + + +<script> +var t = async_test("putImageData() does not affect the current path"); +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'); + +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50) +ctx.rect(0, 0, 100, 50); +var imgdata = ctx.getImageData(0, 0, 100, 50); +ctx.putImageData(imgdata, 0, 0); +ctx.fillStyle = '#0f0'; +ctx.fill(); +_assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.path.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.path.worker.js new file mode 100644 index 0000000000..81bd03eb4f --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.path.worker.js @@ -0,0 +1,30 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.put.path +// Description:putImageData() does not affect the current path +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("putImageData() does not affect the current path"); +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'); + +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50) +ctx.rect(0, 0, 100, 50); +var imgdata = ctx.getImageData(0, 0, 100, 50); +ctx.putImageData(imgdata, 0, 0); +ctx.fillStyle = '#0f0'; +ctx.fill(); +_assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.unaffected.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.unaffected.html new file mode 100644 index 0000000000..8d94f9bbf6 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.unaffected.html @@ -0,0 +1,39 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.put.unaffected</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.put.unaffected</h1> +<p class="desc">putImageData() is not affected by context state</p> + + +<script> +var t = async_test("putImageData() is not affected by context state"); +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'); + +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50) +var imgdata = ctx.getImageData(0, 0, 100, 50); +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50) +ctx.globalAlpha = 0.1; +ctx.globalCompositeOperation = 'destination-atop'; +ctx.shadowColor = '#f00'; +ctx.shadowBlur = 1; +ctx.translate(100, 50); +ctx.scale(0.1, 0.1); +ctx.putImageData(imgdata, 0, 0); +_assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.unaffected.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.unaffected.worker.js new file mode 100644 index 0000000000..9b931717f0 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.unaffected.worker.js @@ -0,0 +1,35 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.put.unaffected +// Description:putImageData() is not affected by context state +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("putImageData() is not affected by context state"); +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'); + +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50) +var imgdata = ctx.getImageData(0, 0, 100, 50); +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50) +ctx.globalAlpha = 0.1; +ctx.globalCompositeOperation = 'destination-atop'; +ctx.shadowColor = '#f00'; +ctx.shadowBlur = 1; +ctx.translate(100, 50); +ctx.scale(0.1, 0.1); +ctx.putImageData(imgdata, 0, 0); +_assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.unchanged.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.unchanged.html new file mode 100644 index 0000000000..b3aff6f49c --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.unchanged.html @@ -0,0 +1,42 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.put.unchanged</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.put.unchanged</h1> +<p class="desc">putImageData(getImageData(...), ...) has no effect</p> + + +<script> +var t = async_test("putImageData(getImageData(...), ...) has no effect"); +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'); + +var i = 0; +for (var y = 0; y < 16; ++y) { + for (var x = 0; x < 16; ++x, ++i) { + ctx.fillStyle = 'rgba(' + i + ',' + (Math.floor(i*1.5) % 256) + ',' + (Math.floor(i*23.3) % 256) + ',' + (i/256) + ')'; + ctx.fillRect(x, y, 1, 1); + } +} +var imgdata1 = ctx.getImageData(0.1, 0.2, 15.8, 15.9); +var olddata = []; +for (var i = 0; i < imgdata1.data.length; ++i) + olddata[i] = imgdata1.data[i]; +ctx.putImageData(imgdata1, 0.1, 0.2); +var imgdata2 = ctx.getImageData(0.1, 0.2, 15.8, 15.9); +for (var i = 0; i < imgdata2.data.length; ++i) { + _assertSame(olddata[i], imgdata2.data[i], "olddata[\""+(i)+"\"]", "imgdata2.data[\""+(i)+"\"]"); +} +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.unchanged.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.unchanged.worker.js new file mode 100644 index 0000000000..231ba3860d --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.unchanged.worker.js @@ -0,0 +1,38 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.put.unchanged +// Description:putImageData(getImageData(...), ...) has no effect +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("putImageData(getImageData(...), ...) has no effect"); +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'); + +var i = 0; +for (var y = 0; y < 16; ++y) { + for (var x = 0; x < 16; ++x, ++i) { + ctx.fillStyle = 'rgba(' + i + ',' + (Math.floor(i*1.5) % 256) + ',' + (Math.floor(i*23.3) % 256) + ',' + (i/256) + ')'; + ctx.fillRect(x, y, 1, 1); + } +} +var imgdata1 = ctx.getImageData(0.1, 0.2, 15.8, 15.9); +var olddata = []; +for (var i = 0; i < imgdata1.data.length; ++i) + olddata[i] = imgdata1.data[i]; +ctx.putImageData(imgdata1, 0.1, 0.2); +var imgdata2 = ctx.getImageData(0.1, 0.2, 15.8, 15.9); +for (var i = 0; i < imgdata2.data.length; ++i) { + _assertSame(olddata[i], imgdata2.data[i], "olddata[\""+(i)+"\"]", "imgdata2.data[\""+(i)+"\"]"); +} +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.wrongtype.html b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.wrongtype.html new file mode 100644 index 0000000000..8e8ca53a9a --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.wrongtype.html @@ -0,0 +1,30 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.imageData.put.wrongtype</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.imageData.put.wrongtype</h1> +<p class="desc">putImageData() does not accept non-ImageData objects</p> + + +<script> +var t = async_test("putImageData() does not accept non-ImageData objects"); +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'); + +var imgdata = { width: 1, height: 1, data: [255, 0, 0, 255] }; +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 0, 0); }); +assert_throws_js(TypeError, function() { ctx.putImageData("cheese", 0, 0); }); +assert_throws_js(TypeError, function() { ctx.putImageData(42, 0, 0); }); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.wrongtype.worker.js b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.wrongtype.worker.js new file mode 100644 index 0000000000..9c58133ac9 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/pixel-manipulation/2d.imageData.put.wrongtype.worker.js @@ -0,0 +1,26 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.imageData.put.wrongtype +// Description:putImageData() does not accept non-ImageData objects +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("putImageData() does not accept non-ImageData objects"); +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'); + +var imgdata = { width: 1, height: 1, data: [255, 0, 0, 255] }; +assert_throws_js(TypeError, function() { ctx.putImageData(imgdata, 0, 0); }); +assert_throws_js(TypeError, function() { ctx.putImageData("cheese", 0, 0); }); +assert_throws_js(TypeError, function() { ctx.putImageData(42, 0, 0); }); +t.done(); + +}); +done(); |