diff options
Diffstat (limited to 'testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas')
58 files changed, 3112 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.3arg.html b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.3arg.html new file mode 100644 index 0000000000..8e144b1ba6 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.3arg.html @@ -0,0 +1,59 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.drawImage.3arg</title> +<meta name="timeout" content="long"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.drawImage.3arg</h1> +<p class="desc"></p> + + +<script> +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +var promise1 = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/red.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +var promise2 = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/green.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +Promise.all([promise1, promise2]).then(function(response1, response2) { + var promise3 = createImageBitmap(response1); + var promise4 = createImageBitmap(response2); + Promise.all([promise3, promise4]).then(function(bitmap1, bitmap2) { + ctx.drawImage(bitmap2, 0, 0); + ctx.drawImage(bitmap1, -100, 0); + ctx.drawImage(bitmap1, 100, 0); + ctx.drawImage(bitmap1, 0, -50); + ctx.drawImage(bitmap1, 0, 50); + _assertPixelApprox(canvas, 0,0, 0,255,0,255, 2); + _assertPixelApprox(canvas, 99,0, 0,255,0,255, 2); + _assertPixelApprox(canvas, 0,49, 0,255,0,255, 2); + _assertPixelApprox(canvas, 99,49, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.3arg.worker.js b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.3arg.worker.js new file mode 100644 index 0000000000..22cb3653e4 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.3arg.worker.js @@ -0,0 +1,55 @@ +// META: timeout=long +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.drawImage.3arg +// Description: +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +var promise1 = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/red.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +var promise2 = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/green.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +Promise.all([promise1, promise2]).then(function(response1, response2) { + var promise3 = createImageBitmap(response1); + var promise4 = createImageBitmap(response2); + Promise.all([promise3, promise4]).then(function(bitmap1, bitmap2) { + ctx.drawImage(bitmap2, 0, 0); + ctx.drawImage(bitmap1, -100, 0); + ctx.drawImage(bitmap1, 100, 0); + ctx.drawImage(bitmap1, 0, -50); + ctx.drawImage(bitmap1, 0, 50); + _assertPixelApprox(canvas, 0,0, 0,255,0,255, 2); + _assertPixelApprox(canvas, 99,0, 0,255,0,255, 2); + _assertPixelApprox(canvas, 0,49, 0,255,0,255, 2); + _assertPixelApprox(canvas, 99,49, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.5arg.html b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.5arg.html new file mode 100644 index 0000000000..c383d1a417 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.5arg.html @@ -0,0 +1,60 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.drawImage.5arg</title> +<meta name="timeout" content="long"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.drawImage.5arg</h1> +<p class="desc"></p> + + +<script> +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50); +var promise1 = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/red.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +var promise2 = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/green.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +Promise.all([promise1, promise2]).then(function(response1, response2) { + var promise3 = createImageBitmap(response1); + var promise4 = createImageBitmap(response2); + Promise.all([promise3, promise4]).then(function(bitmap1, bitmap2) { + ctx.drawImage(bitmap2, 50, 0, 50, 50); + ctx.drawImage(bitmap1, 0, 0, 50, 50); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 50, 50); + _assertPixelApprox(canvas, 0,0, 0,255,0,255, 2); + _assertPixelApprox(canvas, 99,0, 0,255,0,255, 2); + _assertPixelApprox(canvas, 0,49, 0,255,0,255, 2); + _assertPixelApprox(canvas, 99,49, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.5arg.worker.js b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.5arg.worker.js new file mode 100644 index 0000000000..3906a5a00b --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.5arg.worker.js @@ -0,0 +1,56 @@ +// META: timeout=long +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.drawImage.5arg +// Description: +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50); +var promise1 = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/red.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +var promise2 = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/green.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +Promise.all([promise1, promise2]).then(function(response1, response2) { + var promise3 = createImageBitmap(response1); + var promise4 = createImageBitmap(response2); + Promise.all([promise3, promise4]).then(function(bitmap1, bitmap2) { + ctx.drawImage(bitmap2, 50, 0, 50, 50); + ctx.drawImage(bitmap1, 0, 0, 50, 50); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 50, 50); + _assertPixelApprox(canvas, 0,0, 0,255,0,255, 2); + _assertPixelApprox(canvas, 99,0, 0,255,0,255, 2); + _assertPixelApprox(canvas, 0,49, 0,255,0,255, 2); + _assertPixelApprox(canvas, 99,49, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.9arg.basic.html b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.9arg.basic.html new file mode 100644 index 0000000000..72ffb4ee3b --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.9arg.basic.html @@ -0,0 +1,46 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.drawImage.9arg.basic</title> +<meta name="timeout" content="long"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.drawImage.9arg.basic</h1> +<p class="desc"></p> + + +<script> +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50); +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/green.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, 0, 0, 100, 50, 0, 0, 100, 50); + _assertPixelApprox(canvas, 0,0, 0,255,0,255, 2); + _assertPixelApprox(canvas, 99,0, 0,255,0,255, 2); + _assertPixelApprox(canvas, 0,49, 0,255,0,255, 2); + _assertPixelApprox(canvas, 99,49, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.9arg.basic.worker.js b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.9arg.basic.worker.js new file mode 100644 index 0000000000..244bc90fe7 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.9arg.basic.worker.js @@ -0,0 +1,42 @@ +// META: timeout=long +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.drawImage.9arg.basic +// Description: +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50); +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/green.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, 0, 0, 100, 50, 0, 0, 100, 50); + _assertPixelApprox(canvas, 0,0, 0,255,0,255, 2); + _assertPixelApprox(canvas, 99,0, 0,255,0,255, 2); + _assertPixelApprox(canvas, 0,49, 0,255,0,255, 2); + _assertPixelApprox(canvas, 99,49, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.9arg.destpos.html b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.9arg.destpos.html new file mode 100644 index 0000000000..ddfa0cbf7c --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.9arg.destpos.html @@ -0,0 +1,61 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.drawImage.9arg.destpos</title> +<meta name="timeout" content="long"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.drawImage.9arg.destpos</h1> +<p class="desc"></p> + + +<script> +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50); +var promise1 = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/red.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +var promise2 = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/green.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +Promise.all([promise1, promise2]).then(function(response1, response2) { + var promise3 = createImageBitmap(response1); + var promise4 = createImageBitmap(response2); + Promise.all([promise3, promise4]).then(function(bitmap1, bitmap2) { + ctx.drawImage(bitmap2, 0, 0, 100, 50, 0, 0, 100, 50); + ctx.drawImage(bitmap1, 0, 0, 100, 50, -100, 0, 100, 50); + ctx.drawImage(bitmap1, 0, 0, 100, 50, 100, 0, 100, 50); + ctx.drawImage(bitmap1, 0, 0, 100, 50, 0, -50, 100, 50); + ctx.drawImage(bitmap1, 0, 0, 100, 50, 0, 50, 100, 50); + _assertPixelApprox(canvas, 0,0, 0,255,0,255, 2); + _assertPixelApprox(canvas, 99,0, 0,255,0,255, 2); + _assertPixelApprox(canvas, 0,49, 0,255,0,255, 2); + _assertPixelApprox(canvas, 99,49, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.9arg.destpos.worker.js b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.9arg.destpos.worker.js new file mode 100644 index 0000000000..81fdae81df --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.9arg.destpos.worker.js @@ -0,0 +1,57 @@ +// META: timeout=long +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.drawImage.9arg.destpos +// Description: +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50); +var promise1 = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/red.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +var promise2 = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/green.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +Promise.all([promise1, promise2]).then(function(response1, response2) { + var promise3 = createImageBitmap(response1); + var promise4 = createImageBitmap(response2); + Promise.all([promise3, promise4]).then(function(bitmap1, bitmap2) { + ctx.drawImage(bitmap2, 0, 0, 100, 50, 0, 0, 100, 50); + ctx.drawImage(bitmap1, 0, 0, 100, 50, -100, 0, 100, 50); + ctx.drawImage(bitmap1, 0, 0, 100, 50, 100, 0, 100, 50); + ctx.drawImage(bitmap1, 0, 0, 100, 50, 0, -50, 100, 50); + ctx.drawImage(bitmap1, 0, 0, 100, 50, 0, 50, 100, 50); + _assertPixelApprox(canvas, 0,0, 0,255,0,255, 2); + _assertPixelApprox(canvas, 99,0, 0,255,0,255, 2); + _assertPixelApprox(canvas, 0,49, 0,255,0,255, 2); + _assertPixelApprox(canvas, 99,49, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.9arg.destsize.html b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.9arg.destsize.html new file mode 100644 index 0000000000..d94daa861e --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.9arg.destsize.html @@ -0,0 +1,61 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.drawImage.9arg.destsize</title> +<meta name="timeout" content="long"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.drawImage.9arg.destsize</h1> +<p class="desc"></p> + + +<script> +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50); +var promise1 = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/red.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +var promise2 = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/green.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +Promise.all([promise1, promise2]).then(function(response1, response2) { + var promise3 = createImageBitmap(response1); + var promise4 = createImageBitmap(response2); + Promise.all([promise3, promise4]).then(function(bitmap1, bitmap2) { + ctx.drawImage(bitmap2, 1, 1, 1, 1, 0, 0, 100, 50); + ctx.drawImage(bitmap1, 0, 0, 100, 50, -50, 0, 50, 50); + ctx.drawImage(bitmap1, 0, 0, 100, 50, 100, 0, 50, 50); + ctx.drawImage(bitmap1, 0, 0, 100, 50, 0, -25, 100, 25); + ctx.drawImage(bitmap1, 0, 0, 100, 50, 0, 50, 100, 25); + _assertPixelApprox(canvas, 0,0, 0,255,0,255, 2); + _assertPixelApprox(canvas, 99,0, 0,255,0,255, 2); + _assertPixelApprox(canvas, 0,49, 0,255,0,255, 2); + _assertPixelApprox(canvas, 99,49, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.9arg.destsize.worker.js b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.9arg.destsize.worker.js new file mode 100644 index 0000000000..60fea26afe --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.9arg.destsize.worker.js @@ -0,0 +1,57 @@ +// META: timeout=long +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.drawImage.9arg.destsize +// Description: +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50); +var promise1 = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/red.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +var promise2 = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/green.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +Promise.all([promise1, promise2]).then(function(response1, response2) { + var promise3 = createImageBitmap(response1); + var promise4 = createImageBitmap(response2); + Promise.all([promise3, promise4]).then(function(bitmap1, bitmap2) { + ctx.drawImage(bitmap2, 1, 1, 1, 1, 0, 0, 100, 50); + ctx.drawImage(bitmap1, 0, 0, 100, 50, -50, 0, 50, 50); + ctx.drawImage(bitmap1, 0, 0, 100, 50, 100, 0, 50, 50); + ctx.drawImage(bitmap1, 0, 0, 100, 50, 0, -25, 100, 25); + ctx.drawImage(bitmap1, 0, 0, 100, 50, 0, 50, 100, 25); + _assertPixelApprox(canvas, 0,0, 0,255,0,255, 2); + _assertPixelApprox(canvas, 99,0, 0,255,0,255, 2); + _assertPixelApprox(canvas, 0,49, 0,255,0,255, 2); + _assertPixelApprox(canvas, 99,49, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.9arg.sourcepos.html b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.9arg.sourcepos.html new file mode 100644 index 0000000000..ffd60f5da9 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.9arg.sourcepos.html @@ -0,0 +1,46 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.drawImage.9arg.sourcepos</title> +<meta name="timeout" content="long"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.drawImage.9arg.sourcepos</h1> +<p class="desc"></p> + + +<script> +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50); +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/rgrg-256x256.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, 140, 20, 100, 50, 0, 0, 100, 50); + _assertPixelApprox(canvas, 0,0, 0,255,0,255, 2); + _assertPixelApprox(canvas, 99,0, 0,255,0,255, 2); + _assertPixelApprox(canvas, 0,49, 0,255,0,255, 2); + _assertPixelApprox(canvas, 99,49, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.9arg.sourcepos.worker.js b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.9arg.sourcepos.worker.js new file mode 100644 index 0000000000..1522353ad6 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.9arg.sourcepos.worker.js @@ -0,0 +1,42 @@ +// META: timeout=long +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.drawImage.9arg.sourcepos +// Description: +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50); +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/rgrg-256x256.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, 140, 20, 100, 50, 0, 0, 100, 50); + _assertPixelApprox(canvas, 0,0, 0,255,0,255, 2); + _assertPixelApprox(canvas, 99,0, 0,255,0,255, 2); + _assertPixelApprox(canvas, 0,49, 0,255,0,255, 2); + _assertPixelApprox(canvas, 99,49, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.9arg.sourcesize.html b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.9arg.sourcesize.html new file mode 100644 index 0000000000..91962b671b --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.9arg.sourcesize.html @@ -0,0 +1,53 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.drawImage.9arg.sourcesize</title> +<meta name="timeout" content="long"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.drawImage.9arg.sourcesize</h1> +<p class="desc"></p> + + +<script> +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50); +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/rgrg-256x256.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, 0, 0, 256, 256, 0, 0, 100, 50); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 51, 26); + ctx.fillRect(49, 24, 51, 26); + _assertPixelApprox(canvas, 0,0, 0,255,0,255, 2); + _assertPixelApprox(canvas, 99,0, 0,255,0,255, 2); + _assertPixelApprox(canvas, 0,49, 0,255,0,255, 2); + _assertPixelApprox(canvas, 99,49, 0,255,0,255, 2); + _assertPixelApprox(canvas, 20,20, 0,255,0,255, 2); + _assertPixelApprox(canvas, 80,20, 0,255,0,255, 2); + _assertPixelApprox(canvas, 20,30, 0,255,0,255, 2); + _assertPixelApprox(canvas, 80,30, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.9arg.sourcesize.worker.js b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.9arg.sourcesize.worker.js new file mode 100644 index 0000000000..6658e21750 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.9arg.sourcesize.worker.js @@ -0,0 +1,49 @@ +// META: timeout=long +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.drawImage.9arg.sourcesize +// Description: +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50); +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/rgrg-256x256.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, 0, 0, 256, 256, 0, 0, 100, 50); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 51, 26); + ctx.fillRect(49, 24, 51, 26); + _assertPixelApprox(canvas, 0,0, 0,255,0,255, 2); + _assertPixelApprox(canvas, 99,0, 0,255,0,255, 2); + _assertPixelApprox(canvas, 0,49, 0,255,0,255, 2); + _assertPixelApprox(canvas, 99,49, 0,255,0,255, 2); + _assertPixelApprox(canvas, 20,20, 0,255,0,255, 2); + _assertPixelApprox(canvas, 80,20, 0,255,0,255, 2); + _assertPixelApprox(canvas, 20,30, 0,255,0,255, 2); + _assertPixelApprox(canvas, 80,30, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.alpha.html b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.alpha.html new file mode 100644 index 0000000000..505c3fde5d --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.alpha.html @@ -0,0 +1,44 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.drawImage.alpha</title> +<meta name="timeout" content="long"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.drawImage.alpha</h1> +<p class="desc"></p> + + +<script> +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50); +ctx.globalAlpha = 0; +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/red.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, 0, 0); + _assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.alpha.worker.js b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.alpha.worker.js new file mode 100644 index 0000000000..92cb23fe14 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.alpha.worker.js @@ -0,0 +1,40 @@ +// META: timeout=long +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.drawImage.alpha +// Description: +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50); +ctx.globalAlpha = 0; +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/red.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, 0, 0); + _assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.animated.poster.html b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.animated.poster.html new file mode 100644 index 0000000000..59d79fd717 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.animated.poster.html @@ -0,0 +1,41 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.drawImage.animated.poster</title> +<meta name="timeout" content="long"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.drawImage.animated.poster</h1> +<p class="desc">drawImage() of an APNG draws the poster frame</p> + + +<script> +var t = async_test("drawImage() of an APNG draws the poster frame"); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/anim-poster-gr.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, 0, 0); + _assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.animated.poster.worker.js b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.animated.poster.worker.js new file mode 100644 index 0000000000..94ca08a075 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.animated.poster.worker.js @@ -0,0 +1,37 @@ +// META: timeout=long +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.drawImage.animated.poster +// Description:drawImage() of an APNG draws the poster frame +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("drawImage() of an APNG draws the poster frame"); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/anim-poster-gr.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, 0, 0); + _assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.broken.html b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.broken.html new file mode 100644 index 0000000000..3324bebcbf --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.broken.html @@ -0,0 +1,43 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.drawImage.broken</title> +<meta name="timeout" content="long"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.drawImage.broken</h1> +<p class="desc"></p> + + +<script> +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/broken.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.drawImage(bitmap, 0, 0); + _assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.broken.worker.js b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.broken.worker.js new file mode 100644 index 0000000000..d3f1b7e4a1 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.broken.worker.js @@ -0,0 +1,39 @@ +// META: timeout=long +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.drawImage.broken +// Description: +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/broken.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.drawImage(bitmap, 0, 0); + _assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.canvas.html b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.canvas.html new file mode 100644 index 0000000000..9b12871086 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.canvas.html @@ -0,0 +1,37 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.drawImage.canvas</title> +<meta name="timeout" content="long"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.drawImage.canvas</h1> +<p class="desc"></p> + + +<script> +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +var offscreenCanvas2 = new OffscreenCanvas(100, 50); +var ctx2 = offscreenCanvas2.getContext('2d'); +ctx2.fillStyle = '#0f0'; +ctx2.fillRect(0, 0, 100, 50); +ctx.fillStyle = '#f00'; +ctx.drawImage(offscreenCanvas2, 0, 0); +_assertPixelApprox(canvas, 0,0, 0,255,0,255, 2); +_assertPixelApprox(canvas, 99,0, 0,255,0,255, 2); +_assertPixelApprox(canvas, 0,49, 0,255,0,255, 2); +_assertPixelApprox(canvas, 99,49, 0,255,0,255, 2); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.canvas.worker.js b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.canvas.worker.js new file mode 100644 index 0000000000..da01a86ba0 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.canvas.worker.js @@ -0,0 +1,33 @@ +// META: timeout=long +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.drawImage.canvas +// Description: +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +var offscreenCanvas2 = new OffscreenCanvas(100, 50); +var ctx2 = offscreenCanvas2.getContext('2d'); +ctx2.fillStyle = '#0f0'; +ctx2.fillRect(0, 0, 100, 50); +ctx.fillStyle = '#f00'; +ctx.drawImage(offscreenCanvas2, 0, 0); +_assertPixelApprox(canvas, 0,0, 0,255,0,255, 2); +_assertPixelApprox(canvas, 99,0, 0,255,0,255, 2); +_assertPixelApprox(canvas, 0,49, 0,255,0,255, 2); +_assertPixelApprox(canvas, 99,49, 0,255,0,255, 2); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.clip.html b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.clip.html new file mode 100644 index 0000000000..fa31852158 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.clip.html @@ -0,0 +1,45 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.drawImage.clip</title> +<meta name="timeout" content="long"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.drawImage.clip</h1> +<p class="desc"></p> + + +<script> +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50); +ctx.rect(-10, -10, 1, 1); +ctx.clip(); +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/red.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, 0, 0); + _assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.clip.worker.js b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.clip.worker.js new file mode 100644 index 0000000000..d30a05fa9d --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.clip.worker.js @@ -0,0 +1,41 @@ +// META: timeout=long +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.drawImage.clip +// Description: +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50); +ctx.rect(-10, -10, 1, 1); +ctx.clip(); +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/red.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, 0, 0); + _assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.composite.html b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.composite.html new file mode 100644 index 0000000000..de4ea40d7d --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.composite.html @@ -0,0 +1,44 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.drawImage.composite</title> +<meta name="timeout" content="long"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.drawImage.composite</h1> +<p class="desc"></p> + + +<script> +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50); +ctx.globalCompositeOperation = 'destination-over'; +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/red.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, 0, 0); + _assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.composite.worker.js b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.composite.worker.js new file mode 100644 index 0000000000..0c4a7fe10a --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.composite.worker.js @@ -0,0 +1,40 @@ +// META: timeout=long +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.drawImage.composite +// Description: +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50); +ctx.globalCompositeOperation = 'destination-over'; +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/red.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, 0, 0); + _assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.floatsource.html b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.floatsource.html new file mode 100644 index 0000000000..5f72973782 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.floatsource.html @@ -0,0 +1,41 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.drawImage.floatsource</title> +<meta name="timeout" content="long"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.drawImage.floatsource</h1> +<p class="desc"></p> + + +<script> +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/green.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, 10.1, 10.1, 0.1, 0.1, 0, 0, 100, 50); + _assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.floatsource.worker.js b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.floatsource.worker.js new file mode 100644 index 0000000000..7b16cbb4f5 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.floatsource.worker.js @@ -0,0 +1,37 @@ +// META: timeout=long +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.drawImage.floatsource +// Description: +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/green.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, 10.1, 10.1, 0.1, 0.1, 0, 0, 100, 50); + _assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.negativedest.html b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.negativedest.html new file mode 100644 index 0000000000..5851fcfb03 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.negativedest.html @@ -0,0 +1,53 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.drawImage.negativedest</title> +<meta name="timeout" content="long"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.drawImage.negativedest</h1> +<p class="desc">Negative destination width/height represents the correct rectangle</p> + + +<script> +var t = async_test("Negative destination width/height represents the correct rectangle"); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50); +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/ggrr-256x256.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, 100, 78, 50, 50, 0, 50, 50, -50); + ctx.drawImage(bitmap, 100, 128, 50, -50, 100, 50, -50, -50); + _assertPixelApprox(canvas, 1,1, 0,255,0,255, 2); + _assertPixelApprox(canvas, 1,48, 0,255,0,255, 2); + _assertPixelApprox(canvas, 98,1, 0,255,0,255, 2); + _assertPixelApprox(canvas, 98,48, 0,255,0,255, 2); + _assertPixelApprox(canvas, 48,1, 0,255,0,255, 2); + _assertPixelApprox(canvas, 48,48, 0,255,0,255, 2); + _assertPixelApprox(canvas, 51,1, 0,255,0,255, 2); + _assertPixelApprox(canvas, 51,48, 0,255,0,255, 2); + _assertPixelApprox(canvas, 25,25, 0,255,0,255, 2); + _assertPixelApprox(canvas, 75,25, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.negativedest.worker.js b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.negativedest.worker.js new file mode 100644 index 0000000000..5ca4d14ef6 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.negativedest.worker.js @@ -0,0 +1,49 @@ +// META: timeout=long +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.drawImage.negativedest +// Description:Negative destination width/height represents the correct rectangle +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("Negative destination width/height represents the correct rectangle"); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50); +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/ggrr-256x256.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, 100, 78, 50, 50, 0, 50, 50, -50); + ctx.drawImage(bitmap, 100, 128, 50, -50, 100, 50, -50, -50); + _assertPixelApprox(canvas, 1,1, 0,255,0,255, 2); + _assertPixelApprox(canvas, 1,48, 0,255,0,255, 2); + _assertPixelApprox(canvas, 98,1, 0,255,0,255, 2); + _assertPixelApprox(canvas, 98,48, 0,255,0,255, 2); + _assertPixelApprox(canvas, 48,1, 0,255,0,255, 2); + _assertPixelApprox(canvas, 48,48, 0,255,0,255, 2); + _assertPixelApprox(canvas, 51,1, 0,255,0,255, 2); + _assertPixelApprox(canvas, 51,48, 0,255,0,255, 2); + _assertPixelApprox(canvas, 25,25, 0,255,0,255, 2); + _assertPixelApprox(canvas, 75,25, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.negativedir.html b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.negativedir.html new file mode 100644 index 0000000000..f9d820733d --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.negativedir.html @@ -0,0 +1,53 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.drawImage.negativedir</title> +<meta name="timeout" content="long"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.drawImage.negativedir</h1> +<p class="desc">Negative dimensions do not affect the direction of the image</p> + + +<script> +var t = async_test("Negative dimensions do not affect the direction of the image"); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50); +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/ggrr-256x256.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, 0, 178, 50, -100, 0, 0, 50, 100); + ctx.drawImage(bitmap, 0, 78, 50, 100, 50, 100, 50, -100); + _assertPixelApprox(canvas, 1,1, 0,255,0,255, 2); + _assertPixelApprox(canvas, 1,48, 0,255,0,255, 2); + _assertPixelApprox(canvas, 98,1, 0,255,0,255, 2); + _assertPixelApprox(canvas, 98,48, 0,255,0,255, 2); + _assertPixelApprox(canvas, 48,1, 0,255,0,255, 2); + _assertPixelApprox(canvas, 48,48, 0,255,0,255, 2); + _assertPixelApprox(canvas, 51,1, 0,255,0,255, 2); + _assertPixelApprox(canvas, 51,48, 0,255,0,255, 2); + _assertPixelApprox(canvas, 25,25, 0,255,0,255, 2); + _assertPixelApprox(canvas, 75,25, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.negativedir.worker.js b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.negativedir.worker.js new file mode 100644 index 0000000000..2a6cc81058 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.negativedir.worker.js @@ -0,0 +1,49 @@ +// META: timeout=long +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.drawImage.negativedir +// Description:Negative dimensions do not affect the direction of the image +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("Negative dimensions do not affect the direction of the image"); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50); +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/ggrr-256x256.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, 0, 178, 50, -100, 0, 0, 50, 100); + ctx.drawImage(bitmap, 0, 78, 50, 100, 50, 100, 50, -100); + _assertPixelApprox(canvas, 1,1, 0,255,0,255, 2); + _assertPixelApprox(canvas, 1,48, 0,255,0,255, 2); + _assertPixelApprox(canvas, 98,1, 0,255,0,255, 2); + _assertPixelApprox(canvas, 98,48, 0,255,0,255, 2); + _assertPixelApprox(canvas, 48,1, 0,255,0,255, 2); + _assertPixelApprox(canvas, 48,48, 0,255,0,255, 2); + _assertPixelApprox(canvas, 51,1, 0,255,0,255, 2); + _assertPixelApprox(canvas, 51,48, 0,255,0,255, 2); + _assertPixelApprox(canvas, 25,25, 0,255,0,255, 2); + _assertPixelApprox(canvas, 75,25, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.negativesource.html b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.negativesource.html new file mode 100644 index 0000000000..9c2a2a1b10 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.negativesource.html @@ -0,0 +1,53 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.drawImage.negativesource</title> +<meta name="timeout" content="long"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.drawImage.negativesource</h1> +<p class="desc">Negative source width/height represents the correct rectangle</p> + + +<script> +var t = async_test("Negative source width/height represents the correct rectangle"); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50); +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/ggrr-256x256.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, 100, 78, -100, 50, 0, 0, 50, 50); + ctx.drawImage(bitmap, 100, 128, -100, -50, 50, 0, 50, 50); + _assertPixelApprox(canvas, 1,1, 0,255,0,255, 2); + _assertPixelApprox(canvas, 1,48, 0,255,0,255, 2); + _assertPixelApprox(canvas, 98,1, 0,255,0,255, 2); + _assertPixelApprox(canvas, 98,48, 0,255,0,255, 2); + _assertPixelApprox(canvas, 48,1, 0,255,0,255, 2); + _assertPixelApprox(canvas, 48,48, 0,255,0,255, 2); + _assertPixelApprox(canvas, 51,1, 0,255,0,255, 2); + _assertPixelApprox(canvas, 51,48, 0,255,0,255, 2); + _assertPixelApprox(canvas, 25,25, 0,255,0,255, 2); + _assertPixelApprox(canvas, 75,25, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.negativesource.worker.js b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.negativesource.worker.js new file mode 100644 index 0000000000..ada79f9137 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.negativesource.worker.js @@ -0,0 +1,49 @@ +// META: timeout=long +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.drawImage.negativesource +// Description:Negative source width/height represents the correct rectangle +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("Negative source width/height represents the correct rectangle"); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 50); +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/ggrr-256x256.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, 100, 78, -100, 50, 0, 0, 50, 50); + ctx.drawImage(bitmap, 100, 128, -100, -50, 50, 0, 50, 50); + _assertPixelApprox(canvas, 1,1, 0,255,0,255, 2); + _assertPixelApprox(canvas, 1,48, 0,255,0,255, 2); + _assertPixelApprox(canvas, 98,1, 0,255,0,255, 2); + _assertPixelApprox(canvas, 98,48, 0,255,0,255, 2); + _assertPixelApprox(canvas, 48,1, 0,255,0,255, 2); + _assertPixelApprox(canvas, 48,48, 0,255,0,255, 2); + _assertPixelApprox(canvas, 51,1, 0,255,0,255, 2); + _assertPixelApprox(canvas, 51,48, 0,255,0,255, 2); + _assertPixelApprox(canvas, 25,25, 0,255,0,255, 2); + _assertPixelApprox(canvas, 75,25, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.nonfinite.html b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.nonfinite.html new file mode 100644 index 0000000000..54f8d95269 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.nonfinite.html @@ -0,0 +1,343 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.drawImage.nonfinite</title> +<meta name="timeout" content="long"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.drawImage.nonfinite</h1> +<p class="desc">drawImage() with Infinity/NaN is ignored</p> + + +<script> +var t = async_test("drawImage() with Infinity/NaN is ignored"); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50); +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/redtransparent.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, Infinity, 0); +ctx.drawImage(bitmap, -Infinity, 0); +ctx.drawImage(bitmap, NaN, 0); +ctx.drawImage(bitmap, 0, Infinity); +ctx.drawImage(bitmap, 0, -Infinity); +ctx.drawImage(bitmap, 0, NaN); +ctx.drawImage(bitmap, Infinity, Infinity); + ctx.drawImage(bitmap, Infinity, 0, 100, 50); +ctx.drawImage(bitmap, -Infinity, 0, 100, 50); +ctx.drawImage(bitmap, NaN, 0, 100, 50); +ctx.drawImage(bitmap, 0, Infinity, 100, 50); +ctx.drawImage(bitmap, 0, -Infinity, 100, 50); +ctx.drawImage(bitmap, 0, NaN, 100, 50); +ctx.drawImage(bitmap, 0, 0, Infinity, 50); +ctx.drawImage(bitmap, 0, 0, -Infinity, 50); +ctx.drawImage(bitmap, 0, 0, NaN, 50); +ctx.drawImage(bitmap, 0, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, 100, -Infinity); +ctx.drawImage(bitmap, 0, 0, 100, NaN); +ctx.drawImage(bitmap, Infinity, Infinity, 100, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, 100, Infinity); +ctx.drawImage(bitmap, Infinity, 0, Infinity, 50); +ctx.drawImage(bitmap, Infinity, 0, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, Infinity, Infinity, 50); +ctx.drawImage(bitmap, 0, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, 0, Infinity, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, Infinity, Infinity); + ctx.drawImage(bitmap, Infinity, 0, 100, 50, 0, 0, 100, 50); +ctx.drawImage(bitmap, -Infinity, 0, 100, 50, 0, 0, 100, 50); +ctx.drawImage(bitmap, NaN, 0, 100, 50, 0, 0, 100, 50); +ctx.drawImage(bitmap, 0, Infinity, 100, 50, 0, 0, 100, 50); +ctx.drawImage(bitmap, 0, -Infinity, 100, 50, 0, 0, 100, 50); +ctx.drawImage(bitmap, 0, NaN, 100, 50, 0, 0, 100, 50); +ctx.drawImage(bitmap, 0, 0, Infinity, 50, 0, 0, 100, 50); +ctx.drawImage(bitmap, 0, 0, -Infinity, 50, 0, 0, 100, 50); +ctx.drawImage(bitmap, 0, 0, NaN, 50, 0, 0, 100, 50); +ctx.drawImage(bitmap, 0, 0, 100, Infinity, 0, 0, 100, 50); +ctx.drawImage(bitmap, 0, 0, 100, -Infinity, 0, 0, 100, 50); +ctx.drawImage(bitmap, 0, 0, 100, NaN, 0, 0, 100, 50); +ctx.drawImage(bitmap, 0, 0, 100, 50, Infinity, 0, 100, 50); +ctx.drawImage(bitmap, 0, 0, 100, 50, -Infinity, 0, 100, 50); +ctx.drawImage(bitmap, 0, 0, 100, 50, NaN, 0, 100, 50); +ctx.drawImage(bitmap, 0, 0, 100, 50, 0, Infinity, 100, 50); +ctx.drawImage(bitmap, 0, 0, 100, 50, 0, -Infinity, 100, 50); +ctx.drawImage(bitmap, 0, 0, 100, 50, 0, NaN, 100, 50); +ctx.drawImage(bitmap, 0, 0, 100, 50, 0, 0, Infinity, 50); +ctx.drawImage(bitmap, 0, 0, 100, 50, 0, 0, -Infinity, 50); +ctx.drawImage(bitmap, 0, 0, 100, 50, 0, 0, NaN, 50); +ctx.drawImage(bitmap, 0, 0, 100, 50, 0, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, 100, 50, 0, 0, 100, -Infinity); +ctx.drawImage(bitmap, 0, 0, 100, 50, 0, 0, 100, NaN); +ctx.drawImage(bitmap, Infinity, Infinity, 100, 50, 0, 0, 100, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, 50, 0, 0, 100, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, Infinity, 0, 0, 100, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, Infinity, Infinity, 0, 100, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, 100, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, 100, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, Infinity, Infinity, 0, Infinity, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, Infinity, Infinity, 0, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, Infinity, Infinity, 0, 100, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, Infinity, 0, Infinity, 100, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, Infinity, 0, Infinity, Infinity, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, Infinity, 0, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, Infinity, 0, Infinity, 100, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, Infinity, 0, 0, Infinity, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, Infinity, 0, 0, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, Infinity, 0, 0, 100, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, 50, Infinity, 0, 100, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, 50, Infinity, Infinity, 100, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, 50, Infinity, Infinity, Infinity, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, 50, Infinity, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, 50, Infinity, Infinity, 100, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, 50, Infinity, 0, Infinity, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, 50, Infinity, 0, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, 50, Infinity, 0, 100, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, 50, 0, Infinity, 100, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, 50, 0, Infinity, Infinity, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, 50, 0, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, 50, 0, Infinity, 100, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, 50, 0, 0, Infinity, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, 50, 0, 0, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, 50, 0, 0, 100, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, 100, Infinity, 0, 0, 100, 50); +ctx.drawImage(bitmap, Infinity, Infinity, 100, Infinity, Infinity, 0, 100, 50); +ctx.drawImage(bitmap, Infinity, Infinity, 100, Infinity, Infinity, Infinity, 100, 50); +ctx.drawImage(bitmap, Infinity, Infinity, 100, Infinity, Infinity, Infinity, Infinity, 50); +ctx.drawImage(bitmap, Infinity, Infinity, 100, Infinity, Infinity, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, 100, Infinity, Infinity, Infinity, 100, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, 100, Infinity, Infinity, 0, Infinity, 50); +ctx.drawImage(bitmap, Infinity, Infinity, 100, Infinity, Infinity, 0, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, 100, Infinity, Infinity, 0, 100, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, 100, Infinity, 0, Infinity, 100, 50); +ctx.drawImage(bitmap, Infinity, Infinity, 100, Infinity, 0, Infinity, Infinity, 50); +ctx.drawImage(bitmap, Infinity, Infinity, 100, Infinity, 0, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, 100, Infinity, 0, Infinity, 100, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, 100, Infinity, 0, 0, Infinity, 50); +ctx.drawImage(bitmap, Infinity, Infinity, 100, Infinity, 0, 0, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, 100, Infinity, 0, 0, 100, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, 100, 50, Infinity, 0, 100, 50); +ctx.drawImage(bitmap, Infinity, Infinity, 100, 50, Infinity, Infinity, 100, 50); +ctx.drawImage(bitmap, Infinity, Infinity, 100, 50, Infinity, Infinity, Infinity, 50); +ctx.drawImage(bitmap, Infinity, Infinity, 100, 50, Infinity, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, 100, 50, Infinity, Infinity, 100, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, 100, 50, Infinity, 0, Infinity, 50); +ctx.drawImage(bitmap, Infinity, Infinity, 100, 50, Infinity, 0, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, 100, 50, Infinity, 0, 100, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, 100, 50, 0, Infinity, 100, 50); +ctx.drawImage(bitmap, Infinity, Infinity, 100, 50, 0, Infinity, Infinity, 50); +ctx.drawImage(bitmap, Infinity, Infinity, 100, 50, 0, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, 100, 50, 0, Infinity, 100, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, 100, 50, 0, 0, Infinity, 50); +ctx.drawImage(bitmap, Infinity, Infinity, 100, 50, 0, 0, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, 100, 50, 0, 0, 100, Infinity); +ctx.drawImage(bitmap, Infinity, 0, Infinity, 50, 0, 0, 100, 50); +ctx.drawImage(bitmap, Infinity, 0, Infinity, Infinity, 0, 0, 100, 50); +ctx.drawImage(bitmap, Infinity, 0, Infinity, Infinity, Infinity, 0, 100, 50); +ctx.drawImage(bitmap, Infinity, 0, Infinity, Infinity, Infinity, Infinity, 100, 50); +ctx.drawImage(bitmap, Infinity, 0, Infinity, Infinity, Infinity, Infinity, Infinity, 50); +ctx.drawImage(bitmap, Infinity, 0, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, 0, Infinity, Infinity, Infinity, Infinity, 100, Infinity); +ctx.drawImage(bitmap, Infinity, 0, Infinity, Infinity, Infinity, 0, Infinity, 50); +ctx.drawImage(bitmap, Infinity, 0, Infinity, Infinity, Infinity, 0, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, 0, Infinity, Infinity, Infinity, 0, 100, Infinity); +ctx.drawImage(bitmap, Infinity, 0, Infinity, Infinity, 0, Infinity, 100, 50); +ctx.drawImage(bitmap, Infinity, 0, Infinity, Infinity, 0, Infinity, Infinity, 50); +ctx.drawImage(bitmap, Infinity, 0, Infinity, Infinity, 0, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, 0, Infinity, Infinity, 0, Infinity, 100, Infinity); +ctx.drawImage(bitmap, Infinity, 0, Infinity, Infinity, 0, 0, Infinity, 50); +ctx.drawImage(bitmap, Infinity, 0, Infinity, Infinity, 0, 0, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, 0, Infinity, Infinity, 0, 0, 100, Infinity); +ctx.drawImage(bitmap, Infinity, 0, Infinity, 50, Infinity, 0, 100, 50); +ctx.drawImage(bitmap, Infinity, 0, Infinity, 50, Infinity, Infinity, 100, 50); +ctx.drawImage(bitmap, Infinity, 0, Infinity, 50, Infinity, Infinity, Infinity, 50); +ctx.drawImage(bitmap, Infinity, 0, Infinity, 50, Infinity, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, 0, Infinity, 50, Infinity, Infinity, 100, Infinity); +ctx.drawImage(bitmap, Infinity, 0, Infinity, 50, Infinity, 0, Infinity, 50); +ctx.drawImage(bitmap, Infinity, 0, Infinity, 50, Infinity, 0, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, 0, Infinity, 50, Infinity, 0, 100, Infinity); +ctx.drawImage(bitmap, Infinity, 0, Infinity, 50, 0, Infinity, 100, 50); +ctx.drawImage(bitmap, Infinity, 0, Infinity, 50, 0, Infinity, Infinity, 50); +ctx.drawImage(bitmap, Infinity, 0, Infinity, 50, 0, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, 0, Infinity, 50, 0, Infinity, 100, Infinity); +ctx.drawImage(bitmap, Infinity, 0, Infinity, 50, 0, 0, Infinity, 50); +ctx.drawImage(bitmap, Infinity, 0, Infinity, 50, 0, 0, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, 0, Infinity, 50, 0, 0, 100, Infinity); +ctx.drawImage(bitmap, Infinity, 0, 100, Infinity, 0, 0, 100, 50); +ctx.drawImage(bitmap, Infinity, 0, 100, Infinity, Infinity, 0, 100, 50); +ctx.drawImage(bitmap, Infinity, 0, 100, Infinity, Infinity, Infinity, 100, 50); +ctx.drawImage(bitmap, Infinity, 0, 100, Infinity, Infinity, Infinity, Infinity, 50); +ctx.drawImage(bitmap, Infinity, 0, 100, Infinity, Infinity, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, 0, 100, Infinity, Infinity, Infinity, 100, Infinity); +ctx.drawImage(bitmap, Infinity, 0, 100, Infinity, Infinity, 0, Infinity, 50); +ctx.drawImage(bitmap, Infinity, 0, 100, Infinity, Infinity, 0, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, 0, 100, Infinity, Infinity, 0, 100, Infinity); +ctx.drawImage(bitmap, Infinity, 0, 100, Infinity, 0, Infinity, 100, 50); +ctx.drawImage(bitmap, Infinity, 0, 100, Infinity, 0, Infinity, Infinity, 50); +ctx.drawImage(bitmap, Infinity, 0, 100, Infinity, 0, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, 0, 100, Infinity, 0, Infinity, 100, Infinity); +ctx.drawImage(bitmap, Infinity, 0, 100, Infinity, 0, 0, Infinity, 50); +ctx.drawImage(bitmap, Infinity, 0, 100, Infinity, 0, 0, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, 0, 100, Infinity, 0, 0, 100, Infinity); +ctx.drawImage(bitmap, Infinity, 0, 100, 50, Infinity, 0, 100, 50); +ctx.drawImage(bitmap, Infinity, 0, 100, 50, Infinity, Infinity, 100, 50); +ctx.drawImage(bitmap, Infinity, 0, 100, 50, Infinity, Infinity, Infinity, 50); +ctx.drawImage(bitmap, Infinity, 0, 100, 50, Infinity, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, 0, 100, 50, Infinity, Infinity, 100, Infinity); +ctx.drawImage(bitmap, Infinity, 0, 100, 50, Infinity, 0, Infinity, 50); +ctx.drawImage(bitmap, Infinity, 0, 100, 50, Infinity, 0, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, 0, 100, 50, Infinity, 0, 100, Infinity); +ctx.drawImage(bitmap, Infinity, 0, 100, 50, 0, Infinity, 100, 50); +ctx.drawImage(bitmap, Infinity, 0, 100, 50, 0, Infinity, Infinity, 50); +ctx.drawImage(bitmap, Infinity, 0, 100, 50, 0, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, 0, 100, 50, 0, Infinity, 100, Infinity); +ctx.drawImage(bitmap, Infinity, 0, 100, 50, 0, 0, Infinity, 50); +ctx.drawImage(bitmap, Infinity, 0, 100, 50, 0, 0, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, 0, 100, 50, 0, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, Infinity, Infinity, 50, 0, 0, 100, 50); +ctx.drawImage(bitmap, 0, Infinity, Infinity, Infinity, 0, 0, 100, 50); +ctx.drawImage(bitmap, 0, Infinity, Infinity, Infinity, Infinity, 0, 100, 50); +ctx.drawImage(bitmap, 0, Infinity, Infinity, Infinity, Infinity, Infinity, 100, 50); +ctx.drawImage(bitmap, 0, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, 50); +ctx.drawImage(bitmap, 0, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, 0, Infinity, Infinity, Infinity, Infinity, Infinity, 100, Infinity); +ctx.drawImage(bitmap, 0, Infinity, Infinity, Infinity, Infinity, 0, Infinity, 50); +ctx.drawImage(bitmap, 0, Infinity, Infinity, Infinity, Infinity, 0, Infinity, Infinity); +ctx.drawImage(bitmap, 0, Infinity, Infinity, Infinity, Infinity, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, Infinity, Infinity, Infinity, 0, Infinity, 100, 50); +ctx.drawImage(bitmap, 0, Infinity, Infinity, Infinity, 0, Infinity, Infinity, 50); +ctx.drawImage(bitmap, 0, Infinity, Infinity, Infinity, 0, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, 0, Infinity, Infinity, Infinity, 0, Infinity, 100, Infinity); +ctx.drawImage(bitmap, 0, Infinity, Infinity, Infinity, 0, 0, Infinity, 50); +ctx.drawImage(bitmap, 0, Infinity, Infinity, Infinity, 0, 0, Infinity, Infinity); +ctx.drawImage(bitmap, 0, Infinity, Infinity, Infinity, 0, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, Infinity, Infinity, 50, Infinity, 0, 100, 50); +ctx.drawImage(bitmap, 0, Infinity, Infinity, 50, Infinity, Infinity, 100, 50); +ctx.drawImage(bitmap, 0, Infinity, Infinity, 50, Infinity, Infinity, Infinity, 50); +ctx.drawImage(bitmap, 0, Infinity, Infinity, 50, Infinity, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, 0, Infinity, Infinity, 50, Infinity, Infinity, 100, Infinity); +ctx.drawImage(bitmap, 0, Infinity, Infinity, 50, Infinity, 0, Infinity, 50); +ctx.drawImage(bitmap, 0, Infinity, Infinity, 50, Infinity, 0, Infinity, Infinity); +ctx.drawImage(bitmap, 0, Infinity, Infinity, 50, Infinity, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, Infinity, Infinity, 50, 0, Infinity, 100, 50); +ctx.drawImage(bitmap, 0, Infinity, Infinity, 50, 0, Infinity, Infinity, 50); +ctx.drawImage(bitmap, 0, Infinity, Infinity, 50, 0, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, 0, Infinity, Infinity, 50, 0, Infinity, 100, Infinity); +ctx.drawImage(bitmap, 0, Infinity, Infinity, 50, 0, 0, Infinity, 50); +ctx.drawImage(bitmap, 0, Infinity, Infinity, 50, 0, 0, Infinity, Infinity); +ctx.drawImage(bitmap, 0, Infinity, Infinity, 50, 0, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, Infinity, 100, Infinity, 0, 0, 100, 50); +ctx.drawImage(bitmap, 0, Infinity, 100, Infinity, Infinity, 0, 100, 50); +ctx.drawImage(bitmap, 0, Infinity, 100, Infinity, Infinity, Infinity, 100, 50); +ctx.drawImage(bitmap, 0, Infinity, 100, Infinity, Infinity, Infinity, Infinity, 50); +ctx.drawImage(bitmap, 0, Infinity, 100, Infinity, Infinity, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, 0, Infinity, 100, Infinity, Infinity, Infinity, 100, Infinity); +ctx.drawImage(bitmap, 0, Infinity, 100, Infinity, Infinity, 0, Infinity, 50); +ctx.drawImage(bitmap, 0, Infinity, 100, Infinity, Infinity, 0, Infinity, Infinity); +ctx.drawImage(bitmap, 0, Infinity, 100, Infinity, Infinity, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, Infinity, 100, Infinity, 0, Infinity, 100, 50); +ctx.drawImage(bitmap, 0, Infinity, 100, Infinity, 0, Infinity, Infinity, 50); +ctx.drawImage(bitmap, 0, Infinity, 100, Infinity, 0, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, 0, Infinity, 100, Infinity, 0, Infinity, 100, Infinity); +ctx.drawImage(bitmap, 0, Infinity, 100, Infinity, 0, 0, Infinity, 50); +ctx.drawImage(bitmap, 0, Infinity, 100, Infinity, 0, 0, Infinity, Infinity); +ctx.drawImage(bitmap, 0, Infinity, 100, Infinity, 0, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, Infinity, 100, 50, Infinity, 0, 100, 50); +ctx.drawImage(bitmap, 0, Infinity, 100, 50, Infinity, Infinity, 100, 50); +ctx.drawImage(bitmap, 0, Infinity, 100, 50, Infinity, Infinity, Infinity, 50); +ctx.drawImage(bitmap, 0, Infinity, 100, 50, Infinity, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, 0, Infinity, 100, 50, Infinity, Infinity, 100, Infinity); +ctx.drawImage(bitmap, 0, Infinity, 100, 50, Infinity, 0, Infinity, 50); +ctx.drawImage(bitmap, 0, Infinity, 100, 50, Infinity, 0, Infinity, Infinity); +ctx.drawImage(bitmap, 0, Infinity, 100, 50, Infinity, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, Infinity, 100, 50, 0, Infinity, 100, 50); +ctx.drawImage(bitmap, 0, Infinity, 100, 50, 0, Infinity, Infinity, 50); +ctx.drawImage(bitmap, 0, Infinity, 100, 50, 0, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, 0, Infinity, 100, 50, 0, Infinity, 100, Infinity); +ctx.drawImage(bitmap, 0, Infinity, 100, 50, 0, 0, Infinity, 50); +ctx.drawImage(bitmap, 0, Infinity, 100, 50, 0, 0, Infinity, Infinity); +ctx.drawImage(bitmap, 0, Infinity, 100, 50, 0, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, Infinity, Infinity, 0, 0, 100, 50); +ctx.drawImage(bitmap, 0, 0, Infinity, Infinity, Infinity, 0, 100, 50); +ctx.drawImage(bitmap, 0, 0, Infinity, Infinity, Infinity, Infinity, 100, 50); +ctx.drawImage(bitmap, 0, 0, Infinity, Infinity, Infinity, Infinity, Infinity, 50); +ctx.drawImage(bitmap, 0, 0, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, 0, 0, Infinity, Infinity, Infinity, Infinity, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, Infinity, Infinity, Infinity, 0, Infinity, 50); +ctx.drawImage(bitmap, 0, 0, Infinity, Infinity, Infinity, 0, Infinity, Infinity); +ctx.drawImage(bitmap, 0, 0, Infinity, Infinity, Infinity, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, Infinity, Infinity, 0, Infinity, 100, 50); +ctx.drawImage(bitmap, 0, 0, Infinity, Infinity, 0, Infinity, Infinity, 50); +ctx.drawImage(bitmap, 0, 0, Infinity, Infinity, 0, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, 0, 0, Infinity, Infinity, 0, Infinity, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, Infinity, Infinity, 0, 0, Infinity, 50); +ctx.drawImage(bitmap, 0, 0, Infinity, Infinity, 0, 0, Infinity, Infinity); +ctx.drawImage(bitmap, 0, 0, Infinity, Infinity, 0, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, Infinity, 50, Infinity, 0, 100, 50); +ctx.drawImage(bitmap, 0, 0, Infinity, 50, Infinity, Infinity, 100, 50); +ctx.drawImage(bitmap, 0, 0, Infinity, 50, Infinity, Infinity, Infinity, 50); +ctx.drawImage(bitmap, 0, 0, Infinity, 50, Infinity, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, 0, 0, Infinity, 50, Infinity, Infinity, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, Infinity, 50, Infinity, 0, Infinity, 50); +ctx.drawImage(bitmap, 0, 0, Infinity, 50, Infinity, 0, Infinity, Infinity); +ctx.drawImage(bitmap, 0, 0, Infinity, 50, Infinity, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, Infinity, 50, 0, Infinity, 100, 50); +ctx.drawImage(bitmap, 0, 0, Infinity, 50, 0, Infinity, Infinity, 50); +ctx.drawImage(bitmap, 0, 0, Infinity, 50, 0, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, 0, 0, Infinity, 50, 0, Infinity, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, Infinity, 50, 0, 0, Infinity, 50); +ctx.drawImage(bitmap, 0, 0, Infinity, 50, 0, 0, Infinity, Infinity); +ctx.drawImage(bitmap, 0, 0, Infinity, 50, 0, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, 100, Infinity, Infinity, 0, 100, 50); +ctx.drawImage(bitmap, 0, 0, 100, Infinity, Infinity, Infinity, 100, 50); +ctx.drawImage(bitmap, 0, 0, 100, Infinity, Infinity, Infinity, Infinity, 50); +ctx.drawImage(bitmap, 0, 0, 100, Infinity, Infinity, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, 0, 0, 100, Infinity, Infinity, Infinity, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, 100, Infinity, Infinity, 0, Infinity, 50); +ctx.drawImage(bitmap, 0, 0, 100, Infinity, Infinity, 0, Infinity, Infinity); +ctx.drawImage(bitmap, 0, 0, 100, Infinity, Infinity, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, 100, Infinity, 0, Infinity, 100, 50); +ctx.drawImage(bitmap, 0, 0, 100, Infinity, 0, Infinity, Infinity, 50); +ctx.drawImage(bitmap, 0, 0, 100, Infinity, 0, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, 0, 0, 100, Infinity, 0, Infinity, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, 100, Infinity, 0, 0, Infinity, 50); +ctx.drawImage(bitmap, 0, 0, 100, Infinity, 0, 0, Infinity, Infinity); +ctx.drawImage(bitmap, 0, 0, 100, Infinity, 0, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, 100, 50, Infinity, Infinity, 100, 50); +ctx.drawImage(bitmap, 0, 0, 100, 50, Infinity, Infinity, Infinity, 50); +ctx.drawImage(bitmap, 0, 0, 100, 50, Infinity, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, 0, 0, 100, 50, Infinity, Infinity, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, 100, 50, Infinity, 0, Infinity, 50); +ctx.drawImage(bitmap, 0, 0, 100, 50, Infinity, 0, Infinity, Infinity); +ctx.drawImage(bitmap, 0, 0, 100, 50, Infinity, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, 100, 50, 0, Infinity, Infinity, 50); +ctx.drawImage(bitmap, 0, 0, 100, 50, 0, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, 0, 0, 100, 50, 0, Infinity, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, 100, 50, 0, 0, Infinity, Infinity); + _assertPixel(canvas, 50,25, 0,255,0,255); + }, t_fail); +}).then(t_pass, t_fail); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.nonfinite.worker.js b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.nonfinite.worker.js new file mode 100644 index 0000000000..a2e77832a2 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.nonfinite.worker.js @@ -0,0 +1,339 @@ +// META: timeout=long +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.drawImage.nonfinite +// Description:drawImage() with Infinity/NaN is ignored +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("drawImage() with Infinity/NaN is ignored"); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50); +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/redtransparent.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, Infinity, 0); +ctx.drawImage(bitmap, -Infinity, 0); +ctx.drawImage(bitmap, NaN, 0); +ctx.drawImage(bitmap, 0, Infinity); +ctx.drawImage(bitmap, 0, -Infinity); +ctx.drawImage(bitmap, 0, NaN); +ctx.drawImage(bitmap, Infinity, Infinity); + ctx.drawImage(bitmap, Infinity, 0, 100, 50); +ctx.drawImage(bitmap, -Infinity, 0, 100, 50); +ctx.drawImage(bitmap, NaN, 0, 100, 50); +ctx.drawImage(bitmap, 0, Infinity, 100, 50); +ctx.drawImage(bitmap, 0, -Infinity, 100, 50); +ctx.drawImage(bitmap, 0, NaN, 100, 50); +ctx.drawImage(bitmap, 0, 0, Infinity, 50); +ctx.drawImage(bitmap, 0, 0, -Infinity, 50); +ctx.drawImage(bitmap, 0, 0, NaN, 50); +ctx.drawImage(bitmap, 0, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, 100, -Infinity); +ctx.drawImage(bitmap, 0, 0, 100, NaN); +ctx.drawImage(bitmap, Infinity, Infinity, 100, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, 100, Infinity); +ctx.drawImage(bitmap, Infinity, 0, Infinity, 50); +ctx.drawImage(bitmap, Infinity, 0, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, Infinity, Infinity, 50); +ctx.drawImage(bitmap, 0, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, 0, Infinity, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, Infinity, Infinity); + ctx.drawImage(bitmap, Infinity, 0, 100, 50, 0, 0, 100, 50); +ctx.drawImage(bitmap, -Infinity, 0, 100, 50, 0, 0, 100, 50); +ctx.drawImage(bitmap, NaN, 0, 100, 50, 0, 0, 100, 50); +ctx.drawImage(bitmap, 0, Infinity, 100, 50, 0, 0, 100, 50); +ctx.drawImage(bitmap, 0, -Infinity, 100, 50, 0, 0, 100, 50); +ctx.drawImage(bitmap, 0, NaN, 100, 50, 0, 0, 100, 50); +ctx.drawImage(bitmap, 0, 0, Infinity, 50, 0, 0, 100, 50); +ctx.drawImage(bitmap, 0, 0, -Infinity, 50, 0, 0, 100, 50); +ctx.drawImage(bitmap, 0, 0, NaN, 50, 0, 0, 100, 50); +ctx.drawImage(bitmap, 0, 0, 100, Infinity, 0, 0, 100, 50); +ctx.drawImage(bitmap, 0, 0, 100, -Infinity, 0, 0, 100, 50); +ctx.drawImage(bitmap, 0, 0, 100, NaN, 0, 0, 100, 50); +ctx.drawImage(bitmap, 0, 0, 100, 50, Infinity, 0, 100, 50); +ctx.drawImage(bitmap, 0, 0, 100, 50, -Infinity, 0, 100, 50); +ctx.drawImage(bitmap, 0, 0, 100, 50, NaN, 0, 100, 50); +ctx.drawImage(bitmap, 0, 0, 100, 50, 0, Infinity, 100, 50); +ctx.drawImage(bitmap, 0, 0, 100, 50, 0, -Infinity, 100, 50); +ctx.drawImage(bitmap, 0, 0, 100, 50, 0, NaN, 100, 50); +ctx.drawImage(bitmap, 0, 0, 100, 50, 0, 0, Infinity, 50); +ctx.drawImage(bitmap, 0, 0, 100, 50, 0, 0, -Infinity, 50); +ctx.drawImage(bitmap, 0, 0, 100, 50, 0, 0, NaN, 50); +ctx.drawImage(bitmap, 0, 0, 100, 50, 0, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, 100, 50, 0, 0, 100, -Infinity); +ctx.drawImage(bitmap, 0, 0, 100, 50, 0, 0, 100, NaN); +ctx.drawImage(bitmap, Infinity, Infinity, 100, 50, 0, 0, 100, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, 50, 0, 0, 100, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, Infinity, 0, 0, 100, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, Infinity, Infinity, 0, 100, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, 100, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, 100, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, Infinity, Infinity, 0, Infinity, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, Infinity, Infinity, 0, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, Infinity, Infinity, 0, 100, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, Infinity, 0, Infinity, 100, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, Infinity, 0, Infinity, Infinity, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, Infinity, 0, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, Infinity, 0, Infinity, 100, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, Infinity, 0, 0, Infinity, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, Infinity, 0, 0, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, Infinity, 0, 0, 100, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, 50, Infinity, 0, 100, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, 50, Infinity, Infinity, 100, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, 50, Infinity, Infinity, Infinity, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, 50, Infinity, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, 50, Infinity, Infinity, 100, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, 50, Infinity, 0, Infinity, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, 50, Infinity, 0, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, 50, Infinity, 0, 100, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, 50, 0, Infinity, 100, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, 50, 0, Infinity, Infinity, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, 50, 0, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, 50, 0, Infinity, 100, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, 50, 0, 0, Infinity, 50); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, 50, 0, 0, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, Infinity, 50, 0, 0, 100, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, 100, Infinity, 0, 0, 100, 50); +ctx.drawImage(bitmap, Infinity, Infinity, 100, Infinity, Infinity, 0, 100, 50); +ctx.drawImage(bitmap, Infinity, Infinity, 100, Infinity, Infinity, Infinity, 100, 50); +ctx.drawImage(bitmap, Infinity, Infinity, 100, Infinity, Infinity, Infinity, Infinity, 50); +ctx.drawImage(bitmap, Infinity, Infinity, 100, Infinity, Infinity, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, 100, Infinity, Infinity, Infinity, 100, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, 100, Infinity, Infinity, 0, Infinity, 50); +ctx.drawImage(bitmap, Infinity, Infinity, 100, Infinity, Infinity, 0, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, 100, Infinity, Infinity, 0, 100, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, 100, Infinity, 0, Infinity, 100, 50); +ctx.drawImage(bitmap, Infinity, Infinity, 100, Infinity, 0, Infinity, Infinity, 50); +ctx.drawImage(bitmap, Infinity, Infinity, 100, Infinity, 0, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, 100, Infinity, 0, Infinity, 100, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, 100, Infinity, 0, 0, Infinity, 50); +ctx.drawImage(bitmap, Infinity, Infinity, 100, Infinity, 0, 0, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, 100, Infinity, 0, 0, 100, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, 100, 50, Infinity, 0, 100, 50); +ctx.drawImage(bitmap, Infinity, Infinity, 100, 50, Infinity, Infinity, 100, 50); +ctx.drawImage(bitmap, Infinity, Infinity, 100, 50, Infinity, Infinity, Infinity, 50); +ctx.drawImage(bitmap, Infinity, Infinity, 100, 50, Infinity, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, 100, 50, Infinity, Infinity, 100, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, 100, 50, Infinity, 0, Infinity, 50); +ctx.drawImage(bitmap, Infinity, Infinity, 100, 50, Infinity, 0, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, 100, 50, Infinity, 0, 100, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, 100, 50, 0, Infinity, 100, 50); +ctx.drawImage(bitmap, Infinity, Infinity, 100, 50, 0, Infinity, Infinity, 50); +ctx.drawImage(bitmap, Infinity, Infinity, 100, 50, 0, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, 100, 50, 0, Infinity, 100, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, 100, 50, 0, 0, Infinity, 50); +ctx.drawImage(bitmap, Infinity, Infinity, 100, 50, 0, 0, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, Infinity, 100, 50, 0, 0, 100, Infinity); +ctx.drawImage(bitmap, Infinity, 0, Infinity, 50, 0, 0, 100, 50); +ctx.drawImage(bitmap, Infinity, 0, Infinity, Infinity, 0, 0, 100, 50); +ctx.drawImage(bitmap, Infinity, 0, Infinity, Infinity, Infinity, 0, 100, 50); +ctx.drawImage(bitmap, Infinity, 0, Infinity, Infinity, Infinity, Infinity, 100, 50); +ctx.drawImage(bitmap, Infinity, 0, Infinity, Infinity, Infinity, Infinity, Infinity, 50); +ctx.drawImage(bitmap, Infinity, 0, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, 0, Infinity, Infinity, Infinity, Infinity, 100, Infinity); +ctx.drawImage(bitmap, Infinity, 0, Infinity, Infinity, Infinity, 0, Infinity, 50); +ctx.drawImage(bitmap, Infinity, 0, Infinity, Infinity, Infinity, 0, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, 0, Infinity, Infinity, Infinity, 0, 100, Infinity); +ctx.drawImage(bitmap, Infinity, 0, Infinity, Infinity, 0, Infinity, 100, 50); +ctx.drawImage(bitmap, Infinity, 0, Infinity, Infinity, 0, Infinity, Infinity, 50); +ctx.drawImage(bitmap, Infinity, 0, Infinity, Infinity, 0, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, 0, Infinity, Infinity, 0, Infinity, 100, Infinity); +ctx.drawImage(bitmap, Infinity, 0, Infinity, Infinity, 0, 0, Infinity, 50); +ctx.drawImage(bitmap, Infinity, 0, Infinity, Infinity, 0, 0, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, 0, Infinity, Infinity, 0, 0, 100, Infinity); +ctx.drawImage(bitmap, Infinity, 0, Infinity, 50, Infinity, 0, 100, 50); +ctx.drawImage(bitmap, Infinity, 0, Infinity, 50, Infinity, Infinity, 100, 50); +ctx.drawImage(bitmap, Infinity, 0, Infinity, 50, Infinity, Infinity, Infinity, 50); +ctx.drawImage(bitmap, Infinity, 0, Infinity, 50, Infinity, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, 0, Infinity, 50, Infinity, Infinity, 100, Infinity); +ctx.drawImage(bitmap, Infinity, 0, Infinity, 50, Infinity, 0, Infinity, 50); +ctx.drawImage(bitmap, Infinity, 0, Infinity, 50, Infinity, 0, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, 0, Infinity, 50, Infinity, 0, 100, Infinity); +ctx.drawImage(bitmap, Infinity, 0, Infinity, 50, 0, Infinity, 100, 50); +ctx.drawImage(bitmap, Infinity, 0, Infinity, 50, 0, Infinity, Infinity, 50); +ctx.drawImage(bitmap, Infinity, 0, Infinity, 50, 0, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, 0, Infinity, 50, 0, Infinity, 100, Infinity); +ctx.drawImage(bitmap, Infinity, 0, Infinity, 50, 0, 0, Infinity, 50); +ctx.drawImage(bitmap, Infinity, 0, Infinity, 50, 0, 0, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, 0, Infinity, 50, 0, 0, 100, Infinity); +ctx.drawImage(bitmap, Infinity, 0, 100, Infinity, 0, 0, 100, 50); +ctx.drawImage(bitmap, Infinity, 0, 100, Infinity, Infinity, 0, 100, 50); +ctx.drawImage(bitmap, Infinity, 0, 100, Infinity, Infinity, Infinity, 100, 50); +ctx.drawImage(bitmap, Infinity, 0, 100, Infinity, Infinity, Infinity, Infinity, 50); +ctx.drawImage(bitmap, Infinity, 0, 100, Infinity, Infinity, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, 0, 100, Infinity, Infinity, Infinity, 100, Infinity); +ctx.drawImage(bitmap, Infinity, 0, 100, Infinity, Infinity, 0, Infinity, 50); +ctx.drawImage(bitmap, Infinity, 0, 100, Infinity, Infinity, 0, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, 0, 100, Infinity, Infinity, 0, 100, Infinity); +ctx.drawImage(bitmap, Infinity, 0, 100, Infinity, 0, Infinity, 100, 50); +ctx.drawImage(bitmap, Infinity, 0, 100, Infinity, 0, Infinity, Infinity, 50); +ctx.drawImage(bitmap, Infinity, 0, 100, Infinity, 0, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, 0, 100, Infinity, 0, Infinity, 100, Infinity); +ctx.drawImage(bitmap, Infinity, 0, 100, Infinity, 0, 0, Infinity, 50); +ctx.drawImage(bitmap, Infinity, 0, 100, Infinity, 0, 0, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, 0, 100, Infinity, 0, 0, 100, Infinity); +ctx.drawImage(bitmap, Infinity, 0, 100, 50, Infinity, 0, 100, 50); +ctx.drawImage(bitmap, Infinity, 0, 100, 50, Infinity, Infinity, 100, 50); +ctx.drawImage(bitmap, Infinity, 0, 100, 50, Infinity, Infinity, Infinity, 50); +ctx.drawImage(bitmap, Infinity, 0, 100, 50, Infinity, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, 0, 100, 50, Infinity, Infinity, 100, Infinity); +ctx.drawImage(bitmap, Infinity, 0, 100, 50, Infinity, 0, Infinity, 50); +ctx.drawImage(bitmap, Infinity, 0, 100, 50, Infinity, 0, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, 0, 100, 50, Infinity, 0, 100, Infinity); +ctx.drawImage(bitmap, Infinity, 0, 100, 50, 0, Infinity, 100, 50); +ctx.drawImage(bitmap, Infinity, 0, 100, 50, 0, Infinity, Infinity, 50); +ctx.drawImage(bitmap, Infinity, 0, 100, 50, 0, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, 0, 100, 50, 0, Infinity, 100, Infinity); +ctx.drawImage(bitmap, Infinity, 0, 100, 50, 0, 0, Infinity, 50); +ctx.drawImage(bitmap, Infinity, 0, 100, 50, 0, 0, Infinity, Infinity); +ctx.drawImage(bitmap, Infinity, 0, 100, 50, 0, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, Infinity, Infinity, 50, 0, 0, 100, 50); +ctx.drawImage(bitmap, 0, Infinity, Infinity, Infinity, 0, 0, 100, 50); +ctx.drawImage(bitmap, 0, Infinity, Infinity, Infinity, Infinity, 0, 100, 50); +ctx.drawImage(bitmap, 0, Infinity, Infinity, Infinity, Infinity, Infinity, 100, 50); +ctx.drawImage(bitmap, 0, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, 50); +ctx.drawImage(bitmap, 0, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, 0, Infinity, Infinity, Infinity, Infinity, Infinity, 100, Infinity); +ctx.drawImage(bitmap, 0, Infinity, Infinity, Infinity, Infinity, 0, Infinity, 50); +ctx.drawImage(bitmap, 0, Infinity, Infinity, Infinity, Infinity, 0, Infinity, Infinity); +ctx.drawImage(bitmap, 0, Infinity, Infinity, Infinity, Infinity, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, Infinity, Infinity, Infinity, 0, Infinity, 100, 50); +ctx.drawImage(bitmap, 0, Infinity, Infinity, Infinity, 0, Infinity, Infinity, 50); +ctx.drawImage(bitmap, 0, Infinity, Infinity, Infinity, 0, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, 0, Infinity, Infinity, Infinity, 0, Infinity, 100, Infinity); +ctx.drawImage(bitmap, 0, Infinity, Infinity, Infinity, 0, 0, Infinity, 50); +ctx.drawImage(bitmap, 0, Infinity, Infinity, Infinity, 0, 0, Infinity, Infinity); +ctx.drawImage(bitmap, 0, Infinity, Infinity, Infinity, 0, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, Infinity, Infinity, 50, Infinity, 0, 100, 50); +ctx.drawImage(bitmap, 0, Infinity, Infinity, 50, Infinity, Infinity, 100, 50); +ctx.drawImage(bitmap, 0, Infinity, Infinity, 50, Infinity, Infinity, Infinity, 50); +ctx.drawImage(bitmap, 0, Infinity, Infinity, 50, Infinity, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, 0, Infinity, Infinity, 50, Infinity, Infinity, 100, Infinity); +ctx.drawImage(bitmap, 0, Infinity, Infinity, 50, Infinity, 0, Infinity, 50); +ctx.drawImage(bitmap, 0, Infinity, Infinity, 50, Infinity, 0, Infinity, Infinity); +ctx.drawImage(bitmap, 0, Infinity, Infinity, 50, Infinity, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, Infinity, Infinity, 50, 0, Infinity, 100, 50); +ctx.drawImage(bitmap, 0, Infinity, Infinity, 50, 0, Infinity, Infinity, 50); +ctx.drawImage(bitmap, 0, Infinity, Infinity, 50, 0, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, 0, Infinity, Infinity, 50, 0, Infinity, 100, Infinity); +ctx.drawImage(bitmap, 0, Infinity, Infinity, 50, 0, 0, Infinity, 50); +ctx.drawImage(bitmap, 0, Infinity, Infinity, 50, 0, 0, Infinity, Infinity); +ctx.drawImage(bitmap, 0, Infinity, Infinity, 50, 0, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, Infinity, 100, Infinity, 0, 0, 100, 50); +ctx.drawImage(bitmap, 0, Infinity, 100, Infinity, Infinity, 0, 100, 50); +ctx.drawImage(bitmap, 0, Infinity, 100, Infinity, Infinity, Infinity, 100, 50); +ctx.drawImage(bitmap, 0, Infinity, 100, Infinity, Infinity, Infinity, Infinity, 50); +ctx.drawImage(bitmap, 0, Infinity, 100, Infinity, Infinity, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, 0, Infinity, 100, Infinity, Infinity, Infinity, 100, Infinity); +ctx.drawImage(bitmap, 0, Infinity, 100, Infinity, Infinity, 0, Infinity, 50); +ctx.drawImage(bitmap, 0, Infinity, 100, Infinity, Infinity, 0, Infinity, Infinity); +ctx.drawImage(bitmap, 0, Infinity, 100, Infinity, Infinity, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, Infinity, 100, Infinity, 0, Infinity, 100, 50); +ctx.drawImage(bitmap, 0, Infinity, 100, Infinity, 0, Infinity, Infinity, 50); +ctx.drawImage(bitmap, 0, Infinity, 100, Infinity, 0, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, 0, Infinity, 100, Infinity, 0, Infinity, 100, Infinity); +ctx.drawImage(bitmap, 0, Infinity, 100, Infinity, 0, 0, Infinity, 50); +ctx.drawImage(bitmap, 0, Infinity, 100, Infinity, 0, 0, Infinity, Infinity); +ctx.drawImage(bitmap, 0, Infinity, 100, Infinity, 0, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, Infinity, 100, 50, Infinity, 0, 100, 50); +ctx.drawImage(bitmap, 0, Infinity, 100, 50, Infinity, Infinity, 100, 50); +ctx.drawImage(bitmap, 0, Infinity, 100, 50, Infinity, Infinity, Infinity, 50); +ctx.drawImage(bitmap, 0, Infinity, 100, 50, Infinity, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, 0, Infinity, 100, 50, Infinity, Infinity, 100, Infinity); +ctx.drawImage(bitmap, 0, Infinity, 100, 50, Infinity, 0, Infinity, 50); +ctx.drawImage(bitmap, 0, Infinity, 100, 50, Infinity, 0, Infinity, Infinity); +ctx.drawImage(bitmap, 0, Infinity, 100, 50, Infinity, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, Infinity, 100, 50, 0, Infinity, 100, 50); +ctx.drawImage(bitmap, 0, Infinity, 100, 50, 0, Infinity, Infinity, 50); +ctx.drawImage(bitmap, 0, Infinity, 100, 50, 0, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, 0, Infinity, 100, 50, 0, Infinity, 100, Infinity); +ctx.drawImage(bitmap, 0, Infinity, 100, 50, 0, 0, Infinity, 50); +ctx.drawImage(bitmap, 0, Infinity, 100, 50, 0, 0, Infinity, Infinity); +ctx.drawImage(bitmap, 0, Infinity, 100, 50, 0, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, Infinity, Infinity, 0, 0, 100, 50); +ctx.drawImage(bitmap, 0, 0, Infinity, Infinity, Infinity, 0, 100, 50); +ctx.drawImage(bitmap, 0, 0, Infinity, Infinity, Infinity, Infinity, 100, 50); +ctx.drawImage(bitmap, 0, 0, Infinity, Infinity, Infinity, Infinity, Infinity, 50); +ctx.drawImage(bitmap, 0, 0, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, 0, 0, Infinity, Infinity, Infinity, Infinity, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, Infinity, Infinity, Infinity, 0, Infinity, 50); +ctx.drawImage(bitmap, 0, 0, Infinity, Infinity, Infinity, 0, Infinity, Infinity); +ctx.drawImage(bitmap, 0, 0, Infinity, Infinity, Infinity, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, Infinity, Infinity, 0, Infinity, 100, 50); +ctx.drawImage(bitmap, 0, 0, Infinity, Infinity, 0, Infinity, Infinity, 50); +ctx.drawImage(bitmap, 0, 0, Infinity, Infinity, 0, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, 0, 0, Infinity, Infinity, 0, Infinity, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, Infinity, Infinity, 0, 0, Infinity, 50); +ctx.drawImage(bitmap, 0, 0, Infinity, Infinity, 0, 0, Infinity, Infinity); +ctx.drawImage(bitmap, 0, 0, Infinity, Infinity, 0, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, Infinity, 50, Infinity, 0, 100, 50); +ctx.drawImage(bitmap, 0, 0, Infinity, 50, Infinity, Infinity, 100, 50); +ctx.drawImage(bitmap, 0, 0, Infinity, 50, Infinity, Infinity, Infinity, 50); +ctx.drawImage(bitmap, 0, 0, Infinity, 50, Infinity, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, 0, 0, Infinity, 50, Infinity, Infinity, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, Infinity, 50, Infinity, 0, Infinity, 50); +ctx.drawImage(bitmap, 0, 0, Infinity, 50, Infinity, 0, Infinity, Infinity); +ctx.drawImage(bitmap, 0, 0, Infinity, 50, Infinity, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, Infinity, 50, 0, Infinity, 100, 50); +ctx.drawImage(bitmap, 0, 0, Infinity, 50, 0, Infinity, Infinity, 50); +ctx.drawImage(bitmap, 0, 0, Infinity, 50, 0, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, 0, 0, Infinity, 50, 0, Infinity, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, Infinity, 50, 0, 0, Infinity, 50); +ctx.drawImage(bitmap, 0, 0, Infinity, 50, 0, 0, Infinity, Infinity); +ctx.drawImage(bitmap, 0, 0, Infinity, 50, 0, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, 100, Infinity, Infinity, 0, 100, 50); +ctx.drawImage(bitmap, 0, 0, 100, Infinity, Infinity, Infinity, 100, 50); +ctx.drawImage(bitmap, 0, 0, 100, Infinity, Infinity, Infinity, Infinity, 50); +ctx.drawImage(bitmap, 0, 0, 100, Infinity, Infinity, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, 0, 0, 100, Infinity, Infinity, Infinity, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, 100, Infinity, Infinity, 0, Infinity, 50); +ctx.drawImage(bitmap, 0, 0, 100, Infinity, Infinity, 0, Infinity, Infinity); +ctx.drawImage(bitmap, 0, 0, 100, Infinity, Infinity, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, 100, Infinity, 0, Infinity, 100, 50); +ctx.drawImage(bitmap, 0, 0, 100, Infinity, 0, Infinity, Infinity, 50); +ctx.drawImage(bitmap, 0, 0, 100, Infinity, 0, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, 0, 0, 100, Infinity, 0, Infinity, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, 100, Infinity, 0, 0, Infinity, 50); +ctx.drawImage(bitmap, 0, 0, 100, Infinity, 0, 0, Infinity, Infinity); +ctx.drawImage(bitmap, 0, 0, 100, Infinity, 0, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, 100, 50, Infinity, Infinity, 100, 50); +ctx.drawImage(bitmap, 0, 0, 100, 50, Infinity, Infinity, Infinity, 50); +ctx.drawImage(bitmap, 0, 0, 100, 50, Infinity, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, 0, 0, 100, 50, Infinity, Infinity, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, 100, 50, Infinity, 0, Infinity, 50); +ctx.drawImage(bitmap, 0, 0, 100, 50, Infinity, 0, Infinity, Infinity); +ctx.drawImage(bitmap, 0, 0, 100, 50, Infinity, 0, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, 100, 50, 0, Infinity, Infinity, 50); +ctx.drawImage(bitmap, 0, 0, 100, 50, 0, Infinity, Infinity, Infinity); +ctx.drawImage(bitmap, 0, 0, 100, 50, 0, Infinity, 100, Infinity); +ctx.drawImage(bitmap, 0, 0, 100, 50, 0, 0, Infinity, Infinity); + _assertPixel(canvas, 50,25, 0,255,0,255); + }, t_fail); +}).then(t_pass, t_fail); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.nowrap.html b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.nowrap.html new file mode 100644 index 0000000000..6ec22c45d6 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.nowrap.html @@ -0,0 +1,45 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.drawImage.nowrap</title> +<meta name="timeout" content="long"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.drawImage.nowrap</h1> +<p class="desc">Stretched images do not get pixels wrapping around the edges</p> + + +<script> +var t = async_test("Stretched images do not get pixels wrapping around the edges"); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50); +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/redtransparent.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, -1950, 0, 2000, 50); + _assertPixelApprox(canvas, 45,25, 0,255,0,255, 2); + _assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); + _assertPixelApprox(canvas, 55,25, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.nowrap.worker.js b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.nowrap.worker.js new file mode 100644 index 0000000000..ab3a9367dd --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.nowrap.worker.js @@ -0,0 +1,41 @@ +// META: timeout=long +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.drawImage.nowrap +// Description:Stretched images do not get pixels wrapping around the edges +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("Stretched images do not get pixels wrapping around the edges"); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50); +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/redtransparent.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, -1950, 0, 2000, 50); + _assertPixelApprox(canvas, 45,25, 0,255,0,255, 2); + _assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); + _assertPixelApprox(canvas, 55,25, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.null.html b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.null.html new file mode 100644 index 0000000000..c32d836ce4 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.null.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.drawImage.null</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.drawImage.null</h1> +<p class="desc"></p> + + +<script> +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +assert_throws_js(TypeError, function() { ctx.drawImage(null, 0, 0); }); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.null.worker.js b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.null.worker.js new file mode 100644 index 0000000000..792dc6ef41 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.null.worker.js @@ -0,0 +1,23 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.drawImage.null +// Description: +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +assert_throws_js(TypeError, function() { ctx.drawImage(null, 0, 0); }); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.path.html b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.path.html new file mode 100644 index 0000000000..b6bad65df5 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.path.html @@ -0,0 +1,44 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.drawImage.path</title> +<meta name="timeout" content="long"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.drawImage.path</h1> +<p class="desc"></p> + + +<script> +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#0f0'; +ctx.rect(0, 0, 100, 50); +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/red.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, 0, 0); + ctx.fill(); + _assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.path.worker.js b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.path.worker.js new file mode 100644 index 0000000000..5521290977 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.path.worker.js @@ -0,0 +1,40 @@ +// META: timeout=long +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.drawImage.path +// Description: +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#0f0'; +ctx.rect(0, 0, 100, 50); +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/red.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, 0, 0); + ctx.fill(); + _assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.self.1.html b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.self.1.html new file mode 100644 index 0000000000..38857453a4 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.self.1.html @@ -0,0 +1,36 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.drawImage.self.1</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.drawImage.self.1</h1> +<p class="desc"></p> + + +<script> +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 50, 50); +ctx.fillStyle = '#f00'; +ctx.fillRect(50, 0, 50, 50); +ctx.drawImage(canvas, 50, 0); + +_assertPixelApprox(canvas, 0,0, 0,255,0,255, 2); +_assertPixelApprox(canvas, 99,0, 0,255,0,255, 2); +_assertPixelApprox(canvas, 0,49, 0,255,0,255, 2); +_assertPixelApprox(canvas, 99,49, 0,255,0,255, 2); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.self.1.worker.js b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.self.1.worker.js new file mode 100644 index 0000000000..01d47cb334 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.self.1.worker.js @@ -0,0 +1,32 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.drawImage.self.1 +// Description: +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 50, 50); +ctx.fillStyle = '#f00'; +ctx.fillRect(50, 0, 50, 50); +ctx.drawImage(canvas, 50, 0); + +_assertPixelApprox(canvas, 0,0, 0,255,0,255, 2); +_assertPixelApprox(canvas, 99,0, 0,255,0,255, 2); +_assertPixelApprox(canvas, 0,49, 0,255,0,255, 2); +_assertPixelApprox(canvas, 99,49, 0,255,0,255, 2); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.self.2.html b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.self.2.html new file mode 100644 index 0000000000..74d383f7e3 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.self.2.html @@ -0,0 +1,38 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.drawImage.self.2</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.drawImage.self.2</h1> +<p class="desc"></p> + + +<script> +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 1, 100, 49); +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 1); +ctx.drawImage(canvas, 0, 1); +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 2); + +_assertPixelApprox(canvas, 0,0, 0,255,0,255, 2); +_assertPixelApprox(canvas, 99,0, 0,255,0,255, 2); +_assertPixelApprox(canvas, 0,49, 0,255,0,255, 2); +_assertPixelApprox(canvas, 99,49, 0,255,0,255, 2); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.self.2.worker.js b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.self.2.worker.js new file mode 100644 index 0000000000..61a02c87a6 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.self.2.worker.js @@ -0,0 +1,34 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.drawImage.self.2 +// Description: +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 1, 100, 49); +ctx.fillStyle = '#f00'; +ctx.fillRect(0, 0, 100, 1); +ctx.drawImage(canvas, 0, 1); +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 2); + +_assertPixelApprox(canvas, 0,0, 0,255,0,255, 2); +_assertPixelApprox(canvas, 99,0, 0,255,0,255, 2); +_assertPixelApprox(canvas, 0,49, 0,255,0,255, 2); +_assertPixelApprox(canvas, 99,49, 0,255,0,255, 2); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.svg.html b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.svg.html new file mode 100644 index 0000000000..d275bf9567 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.svg.html @@ -0,0 +1,41 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.drawImage.svg</title> +<meta name="timeout" content="long"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.drawImage.svg</h1> +<p class="desc">drawImage() of an SVG image</p> + + +<script> +var t = async_test("drawImage() of an SVG image"); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/green.svg'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, 0, 0); + _assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.svg.worker.js b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.svg.worker.js new file mode 100644 index 0000000000..2d832be363 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.svg.worker.js @@ -0,0 +1,37 @@ +// META: timeout=long +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.drawImage.svg +// Description:drawImage() of an SVG image +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("drawImage() of an SVG image"); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/green.svg'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, 0, 0); + _assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.transform.html b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.transform.html new file mode 100644 index 0000000000..741c5efb9f --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.transform.html @@ -0,0 +1,44 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.drawImage.transform</title> +<meta name="timeout" content="long"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.drawImage.transform</h1> +<p class="desc"></p> + + +<script> +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50); +ctx.translate(100, 0); +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/red.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, 0, 0); + _assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.transform.worker.js b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.transform.worker.js new file mode 100644 index 0000000000..2fc0caf1c3 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.transform.worker.js @@ -0,0 +1,40 @@ +// META: timeout=long +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.drawImage.transform +// Description: +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50); +ctx.translate(100, 0); +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/red.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, 0, 0); + _assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.wrongtype.html b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.wrongtype.html new file mode 100644 index 0000000000..84cfaef1a7 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.wrongtype.html @@ -0,0 +1,29 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.drawImage.wrongtype</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.drawImage.wrongtype</h1> +<p class="desc">Incorrect image types in drawImage do not match any defined overloads, so WebIDL throws a TypeError</p> + + +<script> +var t = async_test("Incorrect image types in drawImage do not match any defined overloads, so WebIDL throws a TypeError"); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +assert_throws_js(TypeError, function() { ctx.drawImage(undefined, 0, 0); }); +assert_throws_js(TypeError, function() { ctx.drawImage(0, 0, 0); }); +assert_throws_js(TypeError, function() { ctx.drawImage("", 0, 0); }); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.wrongtype.worker.js b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.wrongtype.worker.js new file mode 100644 index 0000000000..9a52628c61 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.wrongtype.worker.js @@ -0,0 +1,25 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.drawImage.wrongtype +// Description:Incorrect image types in drawImage do not match any defined overloads, so WebIDL throws a TypeError +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("Incorrect image types in drawImage do not match any defined overloads, so WebIDL throws a TypeError"); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +assert_throws_js(TypeError, function() { ctx.drawImage(undefined, 0, 0); }); +assert_throws_js(TypeError, function() { ctx.drawImage(0, 0, 0); }); +assert_throws_js(TypeError, function() { ctx.drawImage("", 0, 0); }); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.zerocanvas.html b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.zerocanvas.html new file mode 100644 index 0000000000..9d59ba70bc --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.zerocanvas.html @@ -0,0 +1,37 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.drawImage.zerocanvas</title> +<meta name="timeout" content="long"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.drawImage.zerocanvas</h1> +<p class="desc"></p> + + +<script> +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +var offscreenCanvas2 = new OffscreenCanvas(0, 10); +assert_throws_dom("INVALID_STATE_ERR", function() { ctx.drawImage(offscreenCanvas2, 0, 0); }); + +offscreenCanvas2.width = 10; +offscreenCanvas2.height = 0; +assert_throws_dom("INVALID_STATE_ERR", function() { ctx.drawImage(offscreenCanvas2, 0, 0); }); + +offscreenCanvas2.width = 0; +offscreenCanvas2.height = 0; +assert_throws_dom("INVALID_STATE_ERR", function() { ctx.drawImage(offscreenCanvas2, 0, 0); }); +t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.zerocanvas.worker.js b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.zerocanvas.worker.js new file mode 100644 index 0000000000..5f3764b157 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.zerocanvas.worker.js @@ -0,0 +1,33 @@ +// META: timeout=long +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.drawImage.zerocanvas +// Description: +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test(""); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +var offscreenCanvas2 = new OffscreenCanvas(0, 10); +assert_throws_dom("INVALID_STATE_ERR", function() { ctx.drawImage(offscreenCanvas2, 0, 0); }); + +offscreenCanvas2.width = 10; +offscreenCanvas2.height = 0; +assert_throws_dom("INVALID_STATE_ERR", function() { ctx.drawImage(offscreenCanvas2, 0, 0); }); + +offscreenCanvas2.width = 0; +offscreenCanvas2.height = 0; +assert_throws_dom("INVALID_STATE_ERR", function() { ctx.drawImage(offscreenCanvas2, 0, 0); }); +t.done(); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.zerosource.html b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.zerosource.html new file mode 100644 index 0000000000..cc610399db --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.zerosource.html @@ -0,0 +1,45 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.drawImage.zerosource</title> +<meta name="timeout" content="long"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.drawImage.zerosource</h1> +<p class="desc">drawImage with zero-sized source rectangle draws nothing without exception</p> + + +<script> +var t = async_test("drawImage with zero-sized source rectangle draws nothing without exception"); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50); +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/green.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, 10, 10, 0, 1, 0, 0, 100, 50); + ctx.drawImage(bitmap, 10, 10, 1, 0, 0, 0, 100, 50); + ctx.drawImage(bitmap, 10, 10, 0, 0, 0, 0, 100, 50); + _assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.zerosource.image.html b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.zerosource.image.html new file mode 100644 index 0000000000..d79f821d44 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.zerosource.image.html @@ -0,0 +1,45 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.drawImage.zerosource.image</title> +<meta name="timeout" content="long"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.drawImage.zerosource.image</h1> +<p class="desc">drawImage with zero-sized source rectangle from image draws nothing without exception</p> + + +<script> +var t = async_test("drawImage with zero-sized source rectangle from image draws nothing without exception"); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50); +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/red-zerowidth.svg'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, 0, 0, 100, 50); + ctx.drawImage(bitmap, 0, 0, 100, 50); + ctx.drawImage(bitmap, 0, 0, 100, 50); + _assertPixel(canvas, 50,25, 0,255,0,255); + }, t_fail); +}).then(t_pass, t_fail); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.zerosource.image.worker.js b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.zerosource.image.worker.js new file mode 100644 index 0000000000..1465d6c1bc --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.zerosource.image.worker.js @@ -0,0 +1,41 @@ +// META: timeout=long +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.drawImage.zerosource.image +// Description:drawImage with zero-sized source rectangle from image draws nothing without exception +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("drawImage with zero-sized source rectangle from image draws nothing without exception"); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50); +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/red-zerowidth.svg'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, 0, 0, 100, 50); + ctx.drawImage(bitmap, 0, 0, 100, 50); + ctx.drawImage(bitmap, 0, 0, 100, 50); + _assertPixel(canvas, 50,25, 0,255,0,255); + }, t_fail); +}).then(t_pass, t_fail); + +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.zerosource.worker.js b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.zerosource.worker.js new file mode 100644 index 0000000000..654e9bdd74 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.zerosource.worker.js @@ -0,0 +1,41 @@ +// META: timeout=long +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.drawImage.zerosource +// Description:drawImage with zero-sized source rectangle draws nothing without exception +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("drawImage with zero-sized source rectangle draws nothing without exception"); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + +var canvas = new OffscreenCanvas(100, 50); +var ctx = canvas.getContext('2d'); + +ctx.fillStyle = '#0f0'; +ctx.fillRect(0, 0, 100, 50); +var promise = new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", '/images/green.png'); + xhr.responseType = 'blob'; + xhr.send(); + xhr.onload = function() { + resolve(xhr.response); + }; +}); +promise.then(function(response) { + createImageBitmap(response).then(bitmap => { + ctx.drawImage(bitmap, 10, 10, 0, 1, 0, 0, 100, 50); + ctx.drawImage(bitmap, 10, 10, 1, 0, 0, 0, 100, 50); + ctx.drawImage(bitmap, 10, 10, 0, 0, 0, 0, 100, 50); + _assertPixelApprox(canvas, 50,25, 0,255,0,255, 2); + }, t_fail); +}).then(t_pass, t_fail); + +}); +done(); |