diff options
Diffstat (limited to 'testing/web-platform/tests/2dcontext/pixel-manipulation')
60 files changed, 2197 insertions, 0 deletions
diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/.gitkeep b/testing/web-platform/tests/2dcontext/pixel-manipulation/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/.gitkeep diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create1.basic.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create1.basic.html new file mode 100644 index 000000000..cf236cd33 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create1.basic.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.create1.basic</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.create1.basic</h1> +<p class="desc">createImageData(imgdata) exists and returns something</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("createImageData(imgdata) exists and returns something"); +_addTest(function(canvas, ctx) { + +_assertDifferent(ctx.createImageData(ctx.createImageData(1, 1)), null, "ctx.createImageData(ctx.createImageData(1, 1))", "null"); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create1.initial.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create1.initial.html new file mode 100644 index 000000000..15f67b72b --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create1.initial.html @@ -0,0 +1,38 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.create1.initial</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.create1.initial</h1> +<p class="desc">createImageData(imgdata) returns transparent black data of the right size</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("createImageData(imgdata) returns transparent black data of the right size"); +_addTest(function(canvas, ctx) { + +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"); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create1.this.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create1.this.html new file mode 100644 index 000000000..1b9b2e095 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create1.this.html @@ -0,0 +1,30 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.create1.this</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.create1.this</h1> +<p class="desc">createImageData(imgdata) should throw when called with the wrong |this|</p> + +<p class="notes">Defined in "Web IDL" (draft) +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("createImageData(imgdata) should throw when called with the wrong |this|"); +_addTest(function(canvas, ctx) { + +var imgdata = ctx.createImageData(1, 1); +assert_throws(new TypeError(), function() { CanvasRenderingContext2D.prototype.createImageData.call(null, imgdata); }); +assert_throws(new TypeError(), function() { CanvasRenderingContext2D.prototype.createImageData.call(undefined, imgdata); }); +assert_throws(new TypeError(), function() { CanvasRenderingContext2D.prototype.createImageData.call({}, imgdata); }); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create1.type.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create1.type.html new file mode 100644 index 000000000..888403550 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create1.type.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.create1.type</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.create1.type</h1> +<p class="desc">createImageData(imgdata) returns an ImageData object containing a Uint8ClampedArray object</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("createImageData(imgdata) returns an ImageData object containing a Uint8ClampedArray object"); +_addTest(function(canvas, ctx) { + +_assertDifferent(window.ImageData, undefined, "window.ImageData", "undefined"); +_assertDifferent(window.Uint8ClampedArray, undefined, "window.Uint8ClampedArray", "undefined"); +window.ImageData.prototype.thisImplementsImageData = true; +window.Uint8ClampedArray.prototype.thisImplementsUint8ClampedArray = true; +var imgdata = ctx.createImageData(ctx.createImageData(1, 1)); +_assert(imgdata.thisImplementsImageData, "imgdata.thisImplementsImageData"); +_assert(imgdata.data.thisImplementsUint8ClampedArray, "imgdata.data.thisImplementsUint8ClampedArray"); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create1.zero.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create1.zero.html new file mode 100644 index 000000000..928c430f8 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create1.zero.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.create1.zero</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.create1.zero</h1> +<p class="desc">createImageData(null) throws TypeError</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("createImageData(null) throws TypeError"); +_addTest(function(canvas, ctx) { + +assert_throws(new TypeError(), function() { ctx.createImageData(null); }); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create2.basic.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create2.basic.html new file mode 100644 index 000000000..51d3c13f9 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create2.basic.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.create2.basic</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.create2.basic</h1> +<p class="desc">createImageData(sw, sh) exists and returns something</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("createImageData(sw, sh) exists and returns something"); +_addTest(function(canvas, ctx) { + +_assertDifferent(ctx.createImageData(1, 1), null, "ctx.createImageData(1, 1)", "null"); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create2.initial.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create2.initial.html new file mode 100644 index 000000000..a858c2437 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create2.initial.html @@ -0,0 +1,35 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.create2.initial</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.create2.initial</h1> +<p class="desc">createImageData(sw, sh) returns transparent black data of the right size</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("createImageData(sw, sh) returns transparent black data of the right size"); +_addTest(function(canvas, ctx) { + +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"); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create2.large.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create2.large.html new file mode 100644 index 000000000..113a23194 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create2.large.html @@ -0,0 +1,35 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.create2.large</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.create2.large</h1> +<p class="desc">createImageData(sw, sh) works for sizes much larger than the canvas</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("createImageData(sw, sh) works for sizes much larger than the canvas"); +_addTest(function(canvas, ctx) { + +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"); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create2.negative.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create2.negative.html new file mode 100644 index 000000000..7a06ed45c --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create2.negative.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.create2.negative</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.create2.negative</h1> +<p class="desc">createImageData(sw, sh) takes the absolute magnitude of the size arguments</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("createImageData(sw, sh) takes the absolute magnitude of the size arguments"); +_addTest(function(canvas, ctx) { + +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"); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create2.nonfinite.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create2.nonfinite.html new file mode 100644 index 000000000..3dabc30a6 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create2.nonfinite.html @@ -0,0 +1,43 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.create2.nonfinite</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.create2.nonfinite</h1> +<p class="desc">createImageData() throws TypeError if arguments are not finite</p> + +<p class="notes">Defined in "Web IDL" (draft) +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("createImageData() throws TypeError if arguments are not finite"); +_addTest(function(canvas, ctx) { + +assert_throws(new TypeError(), function() { ctx.createImageData(Infinity, 10); }); +assert_throws(new TypeError(), function() { ctx.createImageData(-Infinity, 10); }); +assert_throws(new TypeError(), function() { ctx.createImageData(NaN, 10); }); +assert_throws(new TypeError(), function() { ctx.createImageData(10, Infinity); }); +assert_throws(new TypeError(), function() { ctx.createImageData(10, -Infinity); }); +assert_throws(new TypeError(), function() { ctx.createImageData(10, NaN); }); +assert_throws(new TypeError(), function() { ctx.createImageData(Infinity, Infinity); }); +var posinfobj = { valueOf: function() { return Infinity; } }, + neginfobj = { valueOf: function() { return -Infinity; } }, + nanobj = { valueOf: function() { return -Infinity; } }; +assert_throws(new TypeError(), function() { ctx.createImageData(posinfobj, 10); }); +assert_throws(new TypeError(), function() { ctx.createImageData(neginfobj, 10); }); +assert_throws(new TypeError(), function() { ctx.createImageData(nanobj, 10); }); +assert_throws(new TypeError(), function() { ctx.createImageData(10, posinfobj); }); +assert_throws(new TypeError(), function() { ctx.createImageData(10, neginfobj); }); +assert_throws(new TypeError(), function() { ctx.createImageData(10, nanobj); }); +assert_throws(new TypeError(), function() { ctx.createImageData(posinfobj, posinfobj); }); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create2.round.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create2.round.html new file mode 100644 index 000000000..84c200178 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create2.round.html @@ -0,0 +1,30 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.create2.round</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.create2.round</h1> +<p class="desc">createImageData(w, h) is rounded the same as getImageData(0, 0, w, h)</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("createImageData(w, h) is rounded the same as getImageData(0, 0, w, h)"); +_addTest(function(canvas, ctx) { + +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"); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create2.this.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create2.this.html new file mode 100644 index 000000000..ff55218cf --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create2.this.html @@ -0,0 +1,29 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.create2.this</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.create2.this</h1> +<p class="desc">createImageData(sw, sh) should throw when called with the wrong |this|</p> + +<p class="notes">Defined in "Web IDL" (draft) +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("createImageData(sw, sh) should throw when called with the wrong |this|"); +_addTest(function(canvas, ctx) { + +assert_throws(new TypeError(), function() { CanvasRenderingContext2D.prototype.createImageData.call(null, 1, 1); }); +assert_throws(new TypeError(), function() { CanvasRenderingContext2D.prototype.createImageData.call(undefined, 1, 1); }); +assert_throws(new TypeError(), function() { CanvasRenderingContext2D.prototype.createImageData.call({}, 1, 1); }); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create2.tiny.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create2.tiny.html new file mode 100644 index 000000000..dac0e5e60 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create2.tiny.html @@ -0,0 +1,35 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.create2.tiny</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.create2.tiny</h1> +<p class="desc">createImageData(sw, sh) works for sizes smaller than one pixel</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("createImageData(sw, sh) works for sizes smaller than one pixel"); +_addTest(function(canvas, ctx) { + +var imgdata = ctx.createImageData(0.0001, 0.0001); +_assertSame(imgdata.data.length, imgdata.width*imgdata.height*4, "imgdata.data.length", "imgdata.width*imgdata.height*4"); +_assertSame(imgdata.width, 1, "imgdata.width", "1"); +_assertSame(imgdata.height, 1, "imgdata.height", "1"); +var isTransparentBlack = true; +for (var i = 0; i < imgdata.data.length; ++i) + if (imgdata.data[i] !== 0) + isTransparentBlack = false; +_assert(isTransparentBlack, "isTransparentBlack"); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create2.type.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create2.type.html new file mode 100644 index 000000000..4e7b444cc --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create2.type.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.create2.type</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.create2.type</h1> +<p class="desc">createImageData(sw, sh) returns an ImageData object containing a Uint8ClampedArray object</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("createImageData(sw, sh) returns an ImageData object containing a Uint8ClampedArray object"); +_addTest(function(canvas, ctx) { + +_assertDifferent(window.ImageData, undefined, "window.ImageData", "undefined"); +_assertDifferent(window.Uint8ClampedArray, undefined, "window.Uint8ClampedArray", "undefined"); +window.ImageData.prototype.thisImplementsImageData = true; +window.Uint8ClampedArray.prototype.thisImplementsUint8ClampedArray = true; +var imgdata = ctx.createImageData(1, 1); +_assert(imgdata.thisImplementsImageData, "imgdata.thisImplementsImageData"); +_assert(imgdata.data.thisImplementsUint8ClampedArray, "imgdata.data.thisImplementsUint8ClampedArray"); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create2.zero.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create2.zero.html new file mode 100644 index 000000000..c8957caac --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.create2.zero.html @@ -0,0 +1,29 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.create2.zero</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.create2.zero</h1> +<p class="desc">createImageData(sw, sh) throws INDEX_SIZE_ERR if size is zero</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("createImageData(sw, sh) throws INDEX_SIZE_ERR if size is zero"); +_addTest(function(canvas, ctx) { + +assert_throws("INDEX_SIZE_ERR", function() { ctx.createImageData(10, 0); }); +assert_throws("INDEX_SIZE_ERR", function() { ctx.createImageData(0, 10); }); +assert_throws("INDEX_SIZE_ERR", function() { ctx.createImageData(0, 0); }); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.basic.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.basic.html new file mode 100644 index 000000000..d8bad1fd5 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.basic.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.get.basic</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.get.basic</h1> +<p class="desc">getImageData() exists and returns something</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("getImageData() exists and returns something"); +_addTest(function(canvas, ctx) { + +_assertDifferent(ctx.getImageData(0, 0, 100, 50), null, "ctx.getImageData(0, 0, 100, 50)", "null"); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.clamp.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.clamp.html new file mode 100644 index 000000000..cc235bac0 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.clamp.html @@ -0,0 +1,38 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.get.clamp</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.get.clamp</h1> +<p class="desc">getImageData() clamps colours to the range [0, 255]</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("getImageData() clamps colours to the range [0, 255]"); +_addTest(function(canvas, ctx) { + +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"); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.length.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.length.html new file mode 100644 index 000000000..8bc30621c --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.length.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.get.length</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.get.length</h1> +<p class="desc">getImageData() returns a correctly-sized Uint8ClampedArray</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("getImageData() returns a correctly-sized Uint8ClampedArray"); +_addTest(function(canvas, ctx) { + +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"); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.nonfinite.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.nonfinite.html new file mode 100644 index 000000000..176b7d8bb --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.nonfinite.html @@ -0,0 +1,75 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.get.nonfinite</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.get.nonfinite</h1> +<p class="desc">getImageData() throws TypeError if arguments are not finite</p> + +<p class="notes">Defined in "Web IDL" (draft) +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("getImageData() throws TypeError if arguments are not finite"); +_addTest(function(canvas, ctx) { + +assert_throws(new TypeError(), function() { ctx.getImageData(Infinity, 10, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.getImageData(-Infinity, 10, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.getImageData(NaN, 10, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.getImageData(10, Infinity, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.getImageData(10, -Infinity, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.getImageData(10, NaN, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.getImageData(10, 10, Infinity, 10); }); +assert_throws(new TypeError(), function() { ctx.getImageData(10, 10, -Infinity, 10); }); +assert_throws(new TypeError(), function() { ctx.getImageData(10, 10, NaN, 10); }); +assert_throws(new TypeError(), function() { ctx.getImageData(10, 10, 10, Infinity); }); +assert_throws(new TypeError(), function() { ctx.getImageData(10, 10, 10, -Infinity); }); +assert_throws(new TypeError(), function() { ctx.getImageData(10, 10, 10, NaN); }); +assert_throws(new TypeError(), function() { ctx.getImageData(Infinity, Infinity, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.getImageData(Infinity, Infinity, Infinity, 10); }); +assert_throws(new TypeError(), function() { ctx.getImageData(Infinity, Infinity, Infinity, Infinity); }); +assert_throws(new TypeError(), function() { ctx.getImageData(Infinity, Infinity, 10, Infinity); }); +assert_throws(new TypeError(), function() { ctx.getImageData(Infinity, 10, Infinity, 10); }); +assert_throws(new TypeError(), function() { ctx.getImageData(Infinity, 10, Infinity, Infinity); }); +assert_throws(new TypeError(), function() { ctx.getImageData(Infinity, 10, 10, Infinity); }); +assert_throws(new TypeError(), function() { ctx.getImageData(10, Infinity, Infinity, 10); }); +assert_throws(new TypeError(), function() { ctx.getImageData(10, Infinity, Infinity, Infinity); }); +assert_throws(new TypeError(), function() { ctx.getImageData(10, Infinity, 10, Infinity); }); +assert_throws(new 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(new TypeError(), function() { ctx.getImageData(posinfobj, 10, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.getImageData(neginfobj, 10, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.getImageData(nanobj, 10, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.getImageData(10, posinfobj, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.getImageData(10, neginfobj, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.getImageData(10, nanobj, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.getImageData(10, 10, posinfobj, 10); }); +assert_throws(new TypeError(), function() { ctx.getImageData(10, 10, neginfobj, 10); }); +assert_throws(new TypeError(), function() { ctx.getImageData(10, 10, nanobj, 10); }); +assert_throws(new TypeError(), function() { ctx.getImageData(10, 10, 10, posinfobj); }); +assert_throws(new TypeError(), function() { ctx.getImageData(10, 10, 10, neginfobj); }); +assert_throws(new TypeError(), function() { ctx.getImageData(10, 10, 10, nanobj); }); +assert_throws(new TypeError(), function() { ctx.getImageData(posinfobj, posinfobj, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.getImageData(posinfobj, posinfobj, posinfobj, 10); }); +assert_throws(new TypeError(), function() { ctx.getImageData(posinfobj, posinfobj, posinfobj, posinfobj); }); +assert_throws(new TypeError(), function() { ctx.getImageData(posinfobj, posinfobj, 10, posinfobj); }); +assert_throws(new TypeError(), function() { ctx.getImageData(posinfobj, 10, posinfobj, 10); }); +assert_throws(new TypeError(), function() { ctx.getImageData(posinfobj, 10, posinfobj, posinfobj); }); +assert_throws(new TypeError(), function() { ctx.getImageData(posinfobj, 10, 10, posinfobj); }); +assert_throws(new TypeError(), function() { ctx.getImageData(10, posinfobj, posinfobj, 10); }); +assert_throws(new TypeError(), function() { ctx.getImageData(10, posinfobj, posinfobj, posinfobj); }); +assert_throws(new TypeError(), function() { ctx.getImageData(10, posinfobj, 10, posinfobj); }); +assert_throws(new TypeError(), function() { ctx.getImageData(10, 10, posinfobj, posinfobj); }); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.nonpremul.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.nonpremul.html new file mode 100644 index 000000000..e8bce96f8 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.nonpremul.html @@ -0,0 +1,34 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.get.nonpremul</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.get.nonpremul</h1> +<p class="desc">getImageData() returns non-premultiplied colours</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("getImageData() returns non-premultiplied colours"); +_addTest(function(canvas, ctx) { + +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"); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.order.alpha.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.order.alpha.html new file mode 100644 index 000000000..e2453c497 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.order.alpha.html @@ -0,0 +1,31 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.get.order.alpha</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.get.order.alpha</h1> +<p class="desc">getImageData() returns A in the fourth component</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("getImageData() returns A in the fourth component"); +_addTest(function(canvas, ctx) { + +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"); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.order.cols.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.order.cols.html new file mode 100644 index 000000000..123831380 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.order.cols.html @@ -0,0 +1,34 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.get.order.cols</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.get.order.cols</h1> +<p class="desc">getImageData() returns leftmost columns first</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("getImageData() returns leftmost columns first"); +_addTest(function(canvas, ctx) { + +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"); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.order.rgb.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.order.rgb.html new file mode 100644 index 000000000..37531ecfa --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.order.rgb.html @@ -0,0 +1,37 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.get.order.rgb</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.get.order.rgb</h1> +<p class="desc">getImageData() returns R then G then B</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("getImageData() returns R then G then B"); +_addTest(function(canvas, ctx) { + +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"); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.order.rows.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.order.rows.html new file mode 100644 index 000000000..de77dc6dd --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.order.rows.html @@ -0,0 +1,34 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.get.order.rows</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.get.order.rows</h1> +<p class="desc">getImageData() returns topmost rows first</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("getImageData() returns topmost rows first"); +_addTest(function(canvas, ctx) { + +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"); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.range.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.range.html new file mode 100644 index 000000000..5f34e35df --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.range.html @@ -0,0 +1,34 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.get.range</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.get.range</h1> +<p class="desc">getImageData() returns values in the range [0, 255]</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("getImageData() returns values in the range [0, 255]"); +_addTest(function(canvas, ctx) { + +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"); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.source.negative.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.source.negative.html new file mode 100644 index 000000000..4bab359fb --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.source.negative.html @@ -0,0 +1,46 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.get.source.negative</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<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> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("getImageData() works with negative width and height, and returns top-to-bottom left-to-right"); +_addTest(function(canvas, ctx) { + +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"); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.source.outside.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.source.outside.html new file mode 100644 index 000000000..9950b60ff --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.source.outside.html @@ -0,0 +1,86 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.get.source.outside</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.get.source.outside</h1> +<p class="desc">getImageData() returns transparent black outside the canvas</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("getImageData() returns transparent black outside the canvas"); +_addTest(function(canvas, ctx) { + +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"); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.source.size.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.source.size.html new file mode 100644 index 000000000..0782b1151 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.source.size.html @@ -0,0 +1,30 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.get.source.size</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.get.source.size</h1> +<p class="desc">getImageData() returns bigger ImageData for bigger source rectangle</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("getImageData() returns bigger ImageData for bigger source rectangle"); +_addTest(function(canvas, ctx) { + +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"); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.tiny.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.tiny.html new file mode 100644 index 000000000..982f3f28b --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.tiny.html @@ -0,0 +1,30 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.get.tiny</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.get.tiny</h1> +<p class="desc">getImageData() works for sizes smaller than one pixel</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("getImageData() works for sizes smaller than one pixel"); +_addTest(function(canvas, ctx) { + +var imgdata = ctx.getImageData(0, 0, 0.0001, 0.0001); +_assertSame(imgdata.data.length, imgdata.width*imgdata.height*4, "imgdata.data.length", "imgdata.width*imgdata.height*4"); +_assertSame(imgdata.width, 1, "imgdata.width", "1"); +_assertSame(imgdata.height, 1, "imgdata.height", "1"); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.type.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.type.html new file mode 100644 index 000000000..76f711d58 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.type.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.get.type</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.get.type</h1> +<p class="desc">getImageData() returns an ImageData object containing a Uint8ClampedArray object</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("getImageData() returns an ImageData object containing a Uint8ClampedArray object"); +_addTest(function(canvas, ctx) { + +_assertDifferent(window.ImageData, undefined, "window.ImageData", "undefined"); +_assertDifferent(window.Uint8ClampedArray, undefined, "window.Uint8ClampedArray", "undefined"); +window.ImageData.prototype.thisImplementsImageData = true; +window.Uint8ClampedArray.prototype.thisImplementsUint8ClampedArray = true; +var imgdata = ctx.getImageData(0, 0, 1, 1); +_assert(imgdata.thisImplementsImageData, "imgdata.thisImplementsImageData"); +_assert(imgdata.data.thisImplementsUint8ClampedArray, "imgdata.data.thisImplementsUint8ClampedArray"); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.unaffected.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.unaffected.html new file mode 100644 index 000000000..06afdb960 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.unaffected.html @@ -0,0 +1,42 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.get.unaffected</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.get.unaffected</h1> +<p class="desc">getImageData() is not affected by context state</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("getImageData() is not affected by context state"); +_addTest(function(canvas, ctx) { + +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, "25,25", "0,255,0,255", 2); +_assertPixelApprox(canvas, 75,25, 0,255,0,255, "75,25", "0,255,0,255", 2); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.zero.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.zero.html new file mode 100644 index 000000000..ed1521723 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.get.zero.html @@ -0,0 +1,29 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.get.zero</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.get.zero</h1> +<p class="desc">getImageData() throws INDEX_SIZE_ERR if size is zero</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("getImageData() throws INDEX_SIZE_ERR if size is zero"); +_addTest(function(canvas, ctx) { + +assert_throws("INDEX_SIZE_ERR", function() { ctx.getImageData(1, 1, 10, 0); }); +assert_throws("INDEX_SIZE_ERR", function() { ctx.getImageData(1, 1, 0, 10); }); +assert_throws("INDEX_SIZE_ERR", function() { ctx.getImageData(1, 1, 0, 0); }); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.object.clamp.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.object.clamp.html new file mode 100644 index 000000000..61e10eea1 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.object.clamp.html @@ -0,0 +1,55 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.object.clamp</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.object.clamp</h1> +<p class="desc">ImageData.data clamps numbers to [0, 255]</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("ImageData.data clamps numbers to [0, 255]"); +_addTest(function(canvas, ctx) { + +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"); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.object.ctor.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.object.ctor.html new file mode 100644 index 000000000..c32596626 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.object.ctor.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.object.ctor</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.object.ctor</h1> +<p class="desc">ImageData does not have a usable constructor</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("ImageData does not have a usable constructor"); +_addTest(function(canvas, ctx) { + +_assertDifferent(window.ImageData, undefined, "window.ImageData", "undefined"); +assert_throws(new TypeError(), function() { new window.ImageData(1,1); }); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.object.nan.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.object.nan.html new file mode 100644 index 000000000..4294b12f6 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.object.nan.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.object.nan</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.object.nan</h1> +<p class="desc">ImageData.data converts NaN to 0</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("ImageData.data converts NaN to 0"); +_addTest(function(canvas, ctx) { + +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"); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.object.properties.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.object.properties.html new file mode 100644 index 000000000..a9ed94247 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.object.properties.html @@ -0,0 +1,30 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.object.properties</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.object.properties</h1> +<p class="desc">ImageData objects have the right properties</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("ImageData objects have the right properties"); +_addTest(function(canvas, ctx) { + +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'"); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.object.readonly.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.object.readonly.html new file mode 100644 index 000000000..6f1833733 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.object.readonly.html @@ -0,0 +1,40 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.object.readonly</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.object.readonly</h1> +<p class="desc">ImageData objects properties are read-only</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("ImageData objects properties are read-only"); +_addTest(function(canvas, ctx) { + +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"); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.object.round.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.object.round.html new file mode 100644 index 000000000..7f50a92c6 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.object.round.html @@ -0,0 +1,55 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.object.round</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.object.round</h1> +<p class="desc">ImageData.data rounds numbers with round-to-zero</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("ImageData.data rounds numbers with round-to-zero"); +_addTest(function(canvas, ctx) { + +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"); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.object.set.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.object.set.html new file mode 100644 index 000000000..dd63ceb90 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.object.set.html @@ -0,0 +1,31 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.object.set</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.object.set</h1> +<p class="desc">ImageData.data can be modified</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("ImageData.data can be modified"); +_addTest(function(canvas, ctx) { + +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"); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.object.string.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.object.string.html new file mode 100644 index 000000000..625b55750 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.object.string.html @@ -0,0 +1,36 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.object.string</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.object.string</h1> +<p class="desc">ImageData.data converts strings to numbers with ToNumber</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("ImageData.data converts strings to numbers with ToNumber"); +_addTest(function(canvas, ctx) { + +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"); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.object.undefined.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.object.undefined.html new file mode 100644 index 000000000..1abf84330 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.object.undefined.html @@ -0,0 +1,30 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.object.undefined</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.object.undefined</h1> +<p class="desc">ImageData.data converts undefined to 0</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("ImageData.data converts undefined to 0"); +_addTest(function(canvas, ctx) { + +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"); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.alpha.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.alpha.html new file mode 100644 index 000000000..9d1947149 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.alpha.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.put.alpha</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.put.alpha</h1> +<p class="desc">putImageData() puts non-solid image data correctly</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="2d.imageData.put.alpha.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("putImageData() puts non-solid image data correctly"); +_addTest(function(canvas, ctx) { + +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, "50,25", "0,255,0,64", 2); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.alpha.png b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.alpha.png Binary files differnew file mode 100644 index 000000000..5428c6552 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.alpha.png diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.basic.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.basic.html new file mode 100644 index 000000000..7d7de3cc4 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.basic.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.put.basic</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.put.basic</h1> +<p class="desc">putImageData() puts image data from getImageData() onto the canvas</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("putImageData() puts image data from getImageData() onto the canvas"); +_addTest(function(canvas, ctx) { + +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, "50,25", "0,255,0,255", 2); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.clip.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.clip.html new file mode 100644 index 000000000..8e8b19a60 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.clip.html @@ -0,0 +1,37 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.put.clip</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.put.clip</h1> +<p class="desc">putImageData() is not affected by clipping regions</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("putImageData() is not affected by clipping regions"); +_addTest(function(canvas, ctx) { + +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, "25,25", "0,255,0,255", 2); +_assertPixelApprox(canvas, 75,25, 0,255,0,255, "75,25", "0,255,0,255", 2); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.created.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.created.html new file mode 100644 index 000000000..4b1dd11bd --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.created.html @@ -0,0 +1,37 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.put.created</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.put.created</h1> +<p class="desc">putImageData() puts image data from createImageData() onto the canvas</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("putImageData() puts image data from createImageData() onto the canvas"); +_addTest(function(canvas, ctx) { + +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, "50,25", "0,255,0,255", 2); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.cross.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.cross.html new file mode 100644 index 000000000..5fc59090a --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.cross.html @@ -0,0 +1,35 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.put.cross</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.put.cross</h1> +<p class="desc">putImageData() accepts image data got from a different canvas</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("putImageData() accepts image data got from a different canvas"); +_addTest(function(canvas, ctx) { + +var canvas2 = document.createElement('canvas'); +var ctx2 = canvas2.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, "50,25", "0,255,0,255", 2); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.dirty.negative.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.dirty.negative.html new file mode 100644 index 000000000..67cf410cc --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.dirty.negative.html @@ -0,0 +1,44 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.put.dirty.negative</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.put.dirty.negative</h1> +<p class="desc">putImageData() handles negative-sized dirty rectangles correctly</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("putImageData() handles negative-sized dirty rectangles correctly"); +_addTest(function(canvas, ctx) { + +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, "50,25", "0,255,0,255", 2); +_assertPixelApprox(canvas, 35,25, 0,255,0,255, "35,25", "0,255,0,255", 2); +_assertPixelApprox(canvas, 65,25, 0,255,0,255, "65,25", "0,255,0,255", 2); +_assertPixelApprox(canvas, 50,15, 0,255,0,255, "50,15", "0,255,0,255", 2); +_assertPixelApprox(canvas, 50,45, 0,255,0,255, "50,45", "0,255,0,255", 2); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.dirty.outside.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.dirty.outside.html new file mode 100644 index 000000000..81dc98ca9 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.dirty.outside.html @@ -0,0 +1,46 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.put.dirty.outside</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.put.dirty.outside</h1> +<p class="desc">putImageData() handles dirty rectangles outside the canvas correctly</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("putImageData() handles dirty rectangles outside the canvas correctly"); +_addTest(function(canvas, ctx) { + +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, "50,25", "0,255,0,255", 2); +_assertPixelApprox(canvas, 98,15, 0,255,0,255, "98,15", "0,255,0,255", 2); +_assertPixelApprox(canvas, 98,25, 0,255,0,255, "98,25", "0,255,0,255", 2); +_assertPixelApprox(canvas, 98,45, 0,255,0,255, "98,45", "0,255,0,255", 2); +_assertPixelApprox(canvas, 1,5, 0,255,0,255, "1,5", "0,255,0,255", 2); +_assertPixelApprox(canvas, 1,25, 0,255,0,255, "1,25", "0,255,0,255", 2); +_assertPixelApprox(canvas, 1,45, 0,255,0,255, "1,45", "0,255,0,255", 2); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.dirty.rect1.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.dirty.rect1.html new file mode 100644 index 000000000..b94a9f581 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.dirty.rect1.html @@ -0,0 +1,44 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.put.dirty.rect1</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.put.dirty.rect1</h1> +<p class="desc">putImageData() only modifies areas inside the dirty rectangle, using width and height</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("putImageData() only modifies areas inside the dirty rectangle, using width and height"); +_addTest(function(canvas, ctx) { + +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, "50,25", "0,255,0,255", 2); +_assertPixelApprox(canvas, 35,25, 0,255,0,255, "35,25", "0,255,0,255", 2); +_assertPixelApprox(canvas, 65,25, 0,255,0,255, "65,25", "0,255,0,255", 2); +_assertPixelApprox(canvas, 50,15, 0,255,0,255, "50,15", "0,255,0,255", 2); +_assertPixelApprox(canvas, 50,45, 0,255,0,255, "50,45", "0,255,0,255", 2); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.dirty.rect2.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.dirty.rect2.html new file mode 100644 index 000000000..1fb5c1416 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.dirty.rect2.html @@ -0,0 +1,44 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.put.dirty.rect2</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.put.dirty.rect2</h1> +<p class="desc">putImageData() only modifies areas inside the dirty rectangle, using x and y</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("putImageData() only modifies areas inside the dirty rectangle, using x and y"); +_addTest(function(canvas, ctx) { + +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, "50,25", "0,255,0,255", 2); +_assertPixelApprox(canvas, 35,25, 0,255,0,255, "35,25", "0,255,0,255", 2); +_assertPixelApprox(canvas, 65,25, 0,255,0,255, "65,25", "0,255,0,255", 2); +_assertPixelApprox(canvas, 50,15, 0,255,0,255, "50,15", "0,255,0,255", 2); +_assertPixelApprox(canvas, 50,45, 0,255,0,255, "50,45", "0,255,0,255", 2); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.dirty.zero.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.dirty.zero.html new file mode 100644 index 000000000..726fdb809 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.dirty.zero.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.put.dirty.zero</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.put.dirty.zero</h1> +<p class="desc">putImageData() with zero-sized dirty rectangle puts nothing</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("putImageData() with zero-sized dirty rectangle puts nothing"); +_addTest(function(canvas, ctx) { + +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, "50,25", "0,255,0,255", 2); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.modified.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.modified.html new file mode 100644 index 000000000..5815aeb26 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.modified.html @@ -0,0 +1,38 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.put.modified</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.put.modified</h1> +<p class="desc">putImageData() puts modified image data correctly</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("putImageData() puts modified image data correctly"); +_addTest(function(canvas, ctx) { + +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, "50,25", "0,255,0,255", 2); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.nonfinite.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.nonfinite.html new file mode 100644 index 000000000..861545ff3 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.nonfinite.html @@ -0,0 +1,109 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.put.nonfinite</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.put.nonfinite</h1> +<p class="desc">putImageData() throws TypeError if arguments are not finite</p> + +<p class="notes">Defined in "Web IDL" (draft) +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("putImageData() throws TypeError if arguments are not finite"); +_addTest(function(canvas, ctx) { + +var imgdata = ctx.getImageData(0, 0, 10, 10); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, Infinity, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, -Infinity, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, NaN, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, Infinity); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, -Infinity); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, NaN); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, Infinity, Infinity); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, Infinity, 10, 10, 10, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, -Infinity, 10, 10, 10, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, NaN, 10, 10, 10, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, Infinity, 10, 10, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, -Infinity, 10, 10, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, NaN, 10, 10, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, 10, Infinity, 10, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, 10, -Infinity, 10, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, 10, NaN, 10, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, 10, 10, Infinity, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, 10, 10, -Infinity, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, 10, 10, NaN, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, 10, 10, 10, Infinity, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, 10, 10, 10, -Infinity, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, 10, 10, 10, NaN, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, 10, 10, 10, 10, Infinity); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, 10, 10, 10, 10, -Infinity); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, 10, 10, 10, 10, NaN); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, Infinity, Infinity, 10, 10, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, Infinity, Infinity, Infinity, 10, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, Infinity, Infinity, Infinity, Infinity, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, Infinity, Infinity, Infinity, Infinity, Infinity, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, Infinity, Infinity, Infinity, Infinity, 10, Infinity); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, Infinity, Infinity, Infinity, 10, Infinity, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, Infinity, Infinity, Infinity, 10, Infinity, Infinity); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, Infinity, Infinity, Infinity, 10, 10, Infinity); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, Infinity, Infinity, 10, Infinity, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, Infinity, Infinity, 10, Infinity, Infinity, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, Infinity, Infinity, 10, Infinity, Infinity, Infinity); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, Infinity, Infinity, 10, Infinity, 10, Infinity); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, Infinity, Infinity, 10, 10, Infinity, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, Infinity, Infinity, 10, 10, Infinity, Infinity); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, Infinity, Infinity, 10, 10, 10, Infinity); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, Infinity, 10, Infinity, 10, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, Infinity, 10, Infinity, Infinity, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, Infinity, 10, Infinity, Infinity, Infinity, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, Infinity, 10, Infinity, Infinity, Infinity, Infinity); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, Infinity, 10, Infinity, Infinity, 10, Infinity); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, Infinity, 10, Infinity, 10, Infinity, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, Infinity, 10, Infinity, 10, Infinity, Infinity); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, Infinity, 10, Infinity, 10, 10, Infinity); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, Infinity, 10, 10, Infinity, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, Infinity, 10, 10, Infinity, Infinity, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, Infinity, 10, 10, Infinity, Infinity, Infinity); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, Infinity, 10, 10, Infinity, 10, Infinity); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, Infinity, 10, 10, 10, Infinity, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, Infinity, 10, 10, 10, Infinity, Infinity); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, Infinity, 10, 10, 10, 10, Infinity); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, Infinity, Infinity, 10, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, Infinity, Infinity, Infinity, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, Infinity, Infinity, Infinity, Infinity, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, Infinity, Infinity, Infinity, Infinity, Infinity); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, Infinity, Infinity, Infinity, 10, Infinity); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, Infinity, Infinity, 10, Infinity, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, Infinity, Infinity, 10, Infinity, Infinity); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, Infinity, Infinity, 10, 10, Infinity); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, Infinity, 10, Infinity, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, Infinity, 10, Infinity, Infinity, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, Infinity, 10, Infinity, Infinity, Infinity); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, Infinity, 10, Infinity, 10, Infinity); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, Infinity, 10, 10, Infinity, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, Infinity, 10, 10, Infinity, Infinity); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, Infinity, 10, 10, 10, Infinity); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, 10, Infinity, Infinity, 10, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, 10, Infinity, Infinity, Infinity, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, 10, Infinity, Infinity, Infinity, Infinity); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, 10, Infinity, Infinity, 10, Infinity); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, 10, Infinity, 10, Infinity, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, 10, Infinity, 10, Infinity, Infinity); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, 10, Infinity, 10, 10, Infinity); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, 10, 10, Infinity, Infinity, 10); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, 10, 10, Infinity, Infinity, Infinity); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, 10, 10, Infinity, 10, Infinity); }); +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 10, 10, 10, 10, Infinity, Infinity); }); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.null.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.null.html new file mode 100644 index 000000000..f827babc5 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.null.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.put.null</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.put.null</h1> +<p class="desc">putImageData() with null imagedata throws TypeError</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("putImageData() with null imagedata throws TypeError"); +_addTest(function(canvas, ctx) { + +assert_throws(new TypeError(), function() { ctx.putImageData(null, 0, 0); }); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.path.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.path.html new file mode 100644 index 000000000..7994e8647 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.path.html @@ -0,0 +1,34 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.put.path</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.put.path</h1> +<p class="desc">putImageData() does not affect the current path</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("putImageData() does not affect the current path"); +_addTest(function(canvas, ctx) { + +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, "50,25", "0,255,0,255", 2); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.unaffected.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.unaffected.html new file mode 100644 index 000000000..8eee15995 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.unaffected.html @@ -0,0 +1,39 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.put.unaffected</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.put.unaffected</h1> +<p class="desc">putImageData() is not affected by context state</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("putImageData() is not affected by context state"); +_addTest(function(canvas, ctx) { + +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, "50,25", "0,255,0,255", 2); + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.unchanged.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.unchanged.html new file mode 100644 index 000000000..59e05fbce --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.unchanged.html @@ -0,0 +1,44 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.put.unchanged</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.put.unchanged</h1> +<p class="desc">putImageData(getImageData(...), ...) has no effect</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> + +<ul id="d"></ul> +<script> +var t = async_test("putImageData(getImageData(...), ...) has no effect"); +_addTest(function(canvas, ctx) { + +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)+"\"]"); +} + + +}); +</script> + diff --git a/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.wrongtype.html b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.wrongtype.html new file mode 100644 index 000000000..085097fd4 --- /dev/null +++ b/testing/web-platform/tests/2dcontext/pixel-manipulation/2d.imageData.put.wrongtype.html @@ -0,0 +1,30 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> +<title>Canvas test: 2d.imageData.put.wrongtype</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/canvas-tests.js"></script> +<link rel="stylesheet" href="/common/canvas-tests.css"> +<body class="show_output"> + +<h1>2d.imageData.put.wrongtype</h1> +<p class="desc">putImageData() does not accept non-ImageData objects</p> + + +<p class="output">Actual output:</p> +<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> +<p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt=""> +<ul id="d"></ul> +<script> +var t = async_test("putImageData() does not accept non-ImageData objects"); +_addTest(function(canvas, ctx) { + +var imgdata = { width: 1, height: 1, data: [255, 0, 0, 255] }; +assert_throws(new TypeError(), function() { ctx.putImageData(imgdata, 0, 0); }); +assert_throws(new TypeError(), function() { ctx.putImageData("cheese", 0, 0); }); +assert_throws(new TypeError(), function() { ctx.putImageData(42, 0, 0); }); + + +}); +</script> + |