diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/html/canvas/offscreen/filters | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/html/canvas/offscreen/filters')
42 files changed, 2200 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.blur.exceptions.tentative.html b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.blur.exceptions.tentative.html new file mode 100644 index 0000000000..d8f14529c5 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.blur.exceptions.tentative.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.filter.canvasFilterObject.blur.exceptions.tentative</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.filter.canvasFilterObject.blur.exceptions.tentative</h1> +<p class="desc">Test exceptions on CanvasFilter() blur.object</p> + + +<script> +var t = async_test("Test exceptions on CanvasFilter() blur.object"); +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.filter = new CanvasFilter({name: 'gaussianBlur'}); }); + assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter({name: 'gaussianBlur', stdDeviation: undefined}); }); + assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter({name: 'gaussianBlur', stdDeviation: 'foo'}); }); + assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter({name: 'gaussianBlur', stdDeviation: [1,2,3]}); }); + assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter({name: 'gaussianBlur', stdDeviation: NaN}); }); + assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter({name: 'gaussianBlur', stdDeviation: {}}); }); + t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.blur.exceptions.tentative.worker.js b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.blur.exceptions.tentative.worker.js new file mode 100644 index 0000000000..9b3fb3c04c --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.blur.exceptions.tentative.worker.js @@ -0,0 +1,27 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.filter.canvasFilterObject.blur.exceptions.tentative +// Description:Test exceptions on CanvasFilter() blur.object +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("Test exceptions on CanvasFilter() blur.object"); +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.filter = new CanvasFilter({name: 'gaussianBlur'}); }); + assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter({name: 'gaussianBlur', stdDeviation: undefined}); }); + assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter({name: 'gaussianBlur', stdDeviation: 'foo'}); }); + assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter({name: 'gaussianBlur', stdDeviation: [1,2,3]}); }); + assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter({name: 'gaussianBlur', stdDeviation: NaN}); }); + assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter({name: 'gaussianBlur', stdDeviation: {}}); }); + t.done(); +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.colorMatrix.tentative.html b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.colorMatrix.tentative.html new file mode 100644 index 0000000000..242094d9f9 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.colorMatrix.tentative.html @@ -0,0 +1,69 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.filter.canvasFilterObject.colorMatrix.tentative</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.filter.canvasFilterObject.colorMatrix.tentative</h1> +<p class="desc">Test the functionality of ColorMatrix filters in CanvasFilter objects</p> + + +<script> +var t = async_test("Test the functionality of ColorMatrix filters in CanvasFilter objects"); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + + var canvas = new OffscreenCanvas(100, 50); + var ctx = canvas.getContext('2d'); + + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'colorMatrix', values: undefined}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'colorMatrix', values: 'foo'}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'colorMatrix', values: null}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'colorMatrix', values: [1, 2, 3]}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'colorMatrix', values: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 'a']}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'colorMatrix', values: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, Infinity]}); }); + ctx.fillStyle = '#f00'; + ctx.filter = new CanvasFilter({name: 'colorMatrix', type: 'hueRotate', values: 0}); + ctx.fillRect(0, 0, 100, 50); + _assertPixelApprox(canvas, 10,10, 255,0,0,255, 2); + ctx.filter = new CanvasFilter({name: 'colorMatrix', type: 'hueRotate', values: 90}); + ctx.fillRect(0, 0, 100, 50); + _assertPixelApprox(canvas, 10,10, 0,91,0,255, 2); + ctx.filter = new CanvasFilter({name: 'colorMatrix', type: 'hueRotate', values: 180}); + ctx.fillRect(0, 0, 100, 50); + _assertPixelApprox(canvas, 10,10, 0,109,109,255, 2); + ctx.filter = new CanvasFilter({name: 'colorMatrix', type: 'hueRotate', values: 270}); + ctx.fillRect(0, 0, 100, 50); + _assertPixelApprox(canvas, 10,10, 109,18,255,255, 2); + ctx.filter = new CanvasFilter({name: 'colorMatrix', type: 'saturate', values: 0.5}); + ctx.fillRect(0, 0, 100, 50); + _assertPixelApprox(canvas, 10,10, 155,27,27,255, 2); + ctx.clearRect(0, 0, 100, 50); + ctx.filter = new CanvasFilter({name: 'colorMatrix', type: 'luminanceToAlpha'}); + ctx.fillRect(0, 0, 100, 50); + _assertPixelApprox(canvas, 10,10, 0,0,0,54, 2); + ctx.filter = new CanvasFilter({name: 'colorMatrix', values: [ + 0, 0, 0, 0, 0, + 1, 1, 1, 1, 0, + 0, 0, 0, 0, 0, + 0, 0, 0, 1, 0 + ]}); + ctx.fillRect(0, 0, 50, 25); + ctx.fillStyle = '#0f0'; + ctx.fillRect(50, 0, 50, 25); + ctx.fillStyle = '#00f'; + ctx.fillRect(0, 25, 50, 25); + ctx.fillStyle = '#fff'; + ctx.fillRect(50, 25, 50, 25); + _assertPixelApprox(canvas, 10,10, 0,255,0,255, 2); + _assertPixelApprox(canvas, 60,10, 0,255,0,255, 2); + _assertPixelApprox(canvas, 10,30, 0,255,0,255, 2); + _assertPixelApprox(canvas, 60,30, 0,255,0,255, 2); + t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.colorMatrix.tentative.worker.js b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.colorMatrix.tentative.worker.js new file mode 100644 index 0000000000..d214e1d836 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.colorMatrix.tentative.worker.js @@ -0,0 +1,64 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.filter.canvasFilterObject.colorMatrix.tentative +// Description:Test the functionality of ColorMatrix filters in CanvasFilter objects +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("Test the functionality of ColorMatrix filters in CanvasFilter objects"); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + + var canvas = new OffscreenCanvas(100, 50); + var ctx = canvas.getContext('2d'); + + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'colorMatrix', values: undefined}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'colorMatrix', values: 'foo'}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'colorMatrix', values: null}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'colorMatrix', values: [1, 2, 3]}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'colorMatrix', values: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 'a']}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'colorMatrix', values: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, Infinity]}); }); + ctx.fillStyle = '#f00'; + ctx.filter = new CanvasFilter({name: 'colorMatrix', type: 'hueRotate', values: 0}); + ctx.fillRect(0, 0, 100, 50); + _assertPixelApprox(canvas, 10,10, 255,0,0,255, 2); + ctx.filter = new CanvasFilter({name: 'colorMatrix', type: 'hueRotate', values: 90}); + ctx.fillRect(0, 0, 100, 50); + _assertPixelApprox(canvas, 10,10, 0,91,0,255, 2); + ctx.filter = new CanvasFilter({name: 'colorMatrix', type: 'hueRotate', values: 180}); + ctx.fillRect(0, 0, 100, 50); + _assertPixelApprox(canvas, 10,10, 0,109,109,255, 2); + ctx.filter = new CanvasFilter({name: 'colorMatrix', type: 'hueRotate', values: 270}); + ctx.fillRect(0, 0, 100, 50); + _assertPixelApprox(canvas, 10,10, 109,18,255,255, 2); + ctx.filter = new CanvasFilter({name: 'colorMatrix', type: 'saturate', values: 0.5}); + ctx.fillRect(0, 0, 100, 50); + _assertPixelApprox(canvas, 10,10, 155,27,27,255, 2); + ctx.clearRect(0, 0, 100, 50); + ctx.filter = new CanvasFilter({name: 'colorMatrix', type: 'luminanceToAlpha'}); + ctx.fillRect(0, 0, 100, 50); + _assertPixelApprox(canvas, 10,10, 0,0,0,54, 2); + ctx.filter = new CanvasFilter({name: 'colorMatrix', values: [ + 0, 0, 0, 0, 0, + 1, 1, 1, 1, 0, + 0, 0, 0, 0, 0, + 0, 0, 0, 1, 0 + ]}); + ctx.fillRect(0, 0, 50, 25); + ctx.fillStyle = '#0f0'; + ctx.fillRect(50, 0, 50, 25); + ctx.fillStyle = '#00f'; + ctx.fillRect(0, 25, 50, 25); + ctx.fillStyle = '#fff'; + ctx.fillRect(50, 25, 50, 25); + _assertPixelApprox(canvas, 10,10, 0,255,0,255, 2); + _assertPixelApprox(canvas, 60,10, 0,255,0,255, 2); + _assertPixelApprox(canvas, 10,30, 0,255,0,255, 2); + _assertPixelApprox(canvas, 60,30, 0,255,0,255, 2); + t.done(); +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.componentTransfer.discrete.tentative.html b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.componentTransfer.discrete.tentative.html new file mode 100644 index 0000000000..ff1de6bc9c --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.componentTransfer.discrete.tentative.html @@ -0,0 +1,67 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.filter.canvasFilterObject.componentTransfer.discrete.tentative</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.filter.canvasFilterObject.componentTransfer.discrete.tentative</h1> +<p class="desc">Test pixels on CanvasFilter() componentTransfer with discrete type</p> + + +<script> +var t = async_test("Test pixels on CanvasFilter() componentTransfer with discrete type"); +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'); + + // From https://www.w3.org/TR/SVG11/filters.html#feComponentTransferElement + function getTransformedValue(C, V) { + // Get the right interval + const n = V.length; + const k = C == 1 ? n - 1 : Math.floor(C * n); + return V[k]; + } + + function getColor(inputColor, tableValues) { + const result = [0, 0, 0]; + for (const i in inputColor) { + const C = inputColor[i]/255; + const Cprime = getTransformedValue(C, tableValues[i]); + result[i] = Math.max(0, Math.min(1, Cprime)) * 255; + } + return result; + } + + tableValuesR = [0, 0, 1, 1]; + tableValuesG = [2, 0, 0.5, 3]; + tableValuesB = [1, -1, 5, 0]; + ctx.filter = new CanvasFilter({name: 'componentTransfer', + funcR: {type: 'discrete', tableValues: tableValuesR}, + funcG: {type: 'discrete', tableValues: tableValuesG}, + funcB: {type: 'discrete', tableValues: tableValuesB}, + }); + + const inputColors = [ + [255, 255, 255], + [0, 0, 0], + [127, 0, 34], + [252, 186, 3], + [50, 68, 87], + ]; + + for (const color of inputColors) { + let outputColor = getColor(color, [tableValuesR, tableValuesG, tableValuesB]); + ctx.fillStyle = `rgb(${color[0]}, ${color[1]}, ${color[2]})`; + ctx.fillRect(0, 0, 10, 10); + _assertPixelApprox(canvas, 5, 5, outputColor[0],outputColor[1],outputColor[2],255, 2); + } + t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.componentTransfer.discrete.tentative.worker.js b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.componentTransfer.discrete.tentative.worker.js new file mode 100644 index 0000000000..0e68f4899f --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.componentTransfer.discrete.tentative.worker.js @@ -0,0 +1,62 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.filter.canvasFilterObject.componentTransfer.discrete.tentative +// Description:Test pixels on CanvasFilter() componentTransfer with discrete type +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("Test pixels on CanvasFilter() componentTransfer with discrete type"); +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'); + + // From https://www.w3.org/TR/SVG11/filters.html#feComponentTransferElement + function getTransformedValue(C, V) { + // Get the right interval + const n = V.length; + const k = C == 1 ? n - 1 : Math.floor(C * n); + return V[k]; + } + + function getColor(inputColor, tableValues) { + const result = [0, 0, 0]; + for (const i in inputColor) { + const C = inputColor[i]/255; + const Cprime = getTransformedValue(C, tableValues[i]); + result[i] = Math.max(0, Math.min(1, Cprime)) * 255; + } + return result; + } + + tableValuesR = [0, 0, 1, 1]; + tableValuesG = [2, 0, 0.5, 3]; + tableValuesB = [1, -1, 5, 0]; + ctx.filter = new CanvasFilter({name: 'componentTransfer', + funcR: {type: 'discrete', tableValues: tableValuesR}, + funcG: {type: 'discrete', tableValues: tableValuesG}, + funcB: {type: 'discrete', tableValues: tableValuesB}, + }); + + const inputColors = [ + [255, 255, 255], + [0, 0, 0], + [127, 0, 34], + [252, 186, 3], + [50, 68, 87], + ]; + + for (const color of inputColors) { + let outputColor = getColor(color, [tableValuesR, tableValuesG, tableValuesB]); + ctx.fillStyle = `rgb(${color[0]}, ${color[1]}, ${color[2]})`; + ctx.fillRect(0, 0, 10, 10); + _assertPixelApprox(canvas, 5, 5, outputColor[0],outputColor[1],outputColor[2],255, 2); + } + t.done(); +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.componentTransfer.gamma.tentative.html b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.componentTransfer.gamma.tentative.html new file mode 100644 index 0000000000..64c30fc417 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.componentTransfer.gamma.tentative.html @@ -0,0 +1,58 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.filter.canvasFilterObject.componentTransfer.gamma.tentative</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.filter.canvasFilterObject.componentTransfer.gamma.tentative</h1> +<p class="desc">Test pixels on CanvasFilter() componentTransfer with gamma type</p> + + +<script> +var t = async_test("Test pixels on CanvasFilter() componentTransfer with gamma type"); +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'); + + // From https://www.w3.org/TR/SVG11/filters.html#feComponentTransferElement + function getColor(inputColor, amplitude, exponent, offset) { + return [ + Math.max(0, Math.min(1, Math.pow(inputColor[0]/255, exponent[0]) * amplitude[0] + offset[0])) * 255, + Math.max(0, Math.min(1, Math.pow(inputColor[1]/255, exponent[1]) * amplitude[1] + offset[1])) * 255, + Math.max(0, Math.min(1, Math.pow(inputColor[2]/255, exponent[2]) * amplitude[2] + offset[2])) * 255, + ]; + } + + const amplitudes = [2, 1.1, 0.5]; + const exponents = [5, 3, 1]; + const offsets = [0.25, 0, 0.5]; + ctx.filter = new CanvasFilter({name: 'componentTransfer', + funcR: {type: 'gamma', amplitude: amplitudes[0], exponent: exponents[0], offset: offsets[0]}, + funcG: {type: 'gamma', amplitude: amplitudes[1], exponent: exponents[1], offset: offsets[1]}, + funcB: {type: 'gamma', amplitude: amplitudes[2], exponent: exponents[2], offset: offsets[2]}, + }); + + const inputColors = [ + [255, 255, 255], + [0, 0, 0], + [127, 0, 34], + [252, 186, 3], + [50, 68, 87], + ]; + + for (const color of inputColors) { + let outputColor = getColor(color, amplitudes, exponents, offsets); + ctx.fillStyle = `rgb(${color[0]}, ${color[1]}, ${color[2]})`; + ctx.fillRect(0, 0, 10, 10); + _assertPixelApprox(canvas, 5, 5, outputColor[0],outputColor[1],outputColor[2],255, 2); + } + t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.componentTransfer.gamma.tentative.worker.js b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.componentTransfer.gamma.tentative.worker.js new file mode 100644 index 0000000000..d59bc699df --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.componentTransfer.gamma.tentative.worker.js @@ -0,0 +1,53 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.filter.canvasFilterObject.componentTransfer.gamma.tentative +// Description:Test pixels on CanvasFilter() componentTransfer with gamma type +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("Test pixels on CanvasFilter() componentTransfer with gamma type"); +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'); + + // From https://www.w3.org/TR/SVG11/filters.html#feComponentTransferElement + function getColor(inputColor, amplitude, exponent, offset) { + return [ + Math.max(0, Math.min(1, Math.pow(inputColor[0]/255, exponent[0]) * amplitude[0] + offset[0])) * 255, + Math.max(0, Math.min(1, Math.pow(inputColor[1]/255, exponent[1]) * amplitude[1] + offset[1])) * 255, + Math.max(0, Math.min(1, Math.pow(inputColor[2]/255, exponent[2]) * amplitude[2] + offset[2])) * 255, + ]; + } + + const amplitudes = [2, 1.1, 0.5]; + const exponents = [5, 3, 1]; + const offsets = [0.25, 0, 0.5]; + ctx.filter = new CanvasFilter({name: 'componentTransfer', + funcR: {type: 'gamma', amplitude: amplitudes[0], exponent: exponents[0], offset: offsets[0]}, + funcG: {type: 'gamma', amplitude: amplitudes[1], exponent: exponents[1], offset: offsets[1]}, + funcB: {type: 'gamma', amplitude: amplitudes[2], exponent: exponents[2], offset: offsets[2]}, + }); + + const inputColors = [ + [255, 255, 255], + [0, 0, 0], + [127, 0, 34], + [252, 186, 3], + [50, 68, 87], + ]; + + for (const color of inputColors) { + let outputColor = getColor(color, amplitudes, exponents, offsets); + ctx.fillStyle = `rgb(${color[0]}, ${color[1]}, ${color[2]})`; + ctx.fillRect(0, 0, 10, 10); + _assertPixelApprox(canvas, 5, 5, outputColor[0],outputColor[1],outputColor[2],255, 2); + } + t.done(); +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.componentTransfer.identity.tentative.html b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.componentTransfer.identity.tentative.html new file mode 100644 index 0000000000..e0d628952e --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.componentTransfer.identity.tentative.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.filter.canvasFilterObject.componentTransfer.identity.tentative</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.filter.canvasFilterObject.componentTransfer.identity.tentative</h1> +<p class="desc">Test pixels on CanvasFilter() componentTransfer with identity type</p> + + +<script> +var t = async_test("Test pixels on CanvasFilter() componentTransfer with identity type"); +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.filter = new CanvasFilter({name: 'componentTransfer', + funcR: {type: 'identity'}, + funcG: {type: 'identity'}, + funcB: {type: 'identity'}, + }); + + const inputColors = [ + [255, 255, 255], + [0, 0, 0], + [127, 0, 34], + [252, 186, 3], + [50, 68, 87], + ]; + + for (const color of inputColors) { + ctx.fillStyle = `rgba(${color[0]}, ${color[1]}, ${color[2]}, 1)`, + ctx.fillRect(0, 0, 10, 10); + _assertPixel(canvas, 5, 5, color[0],color[1],color[2],255); + } + t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.componentTransfer.identity.tentative.worker.js b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.componentTransfer.identity.tentative.worker.js new file mode 100644 index 0000000000..1b714b58ff --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.componentTransfer.identity.tentative.worker.js @@ -0,0 +1,40 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.filter.canvasFilterObject.componentTransfer.identity.tentative +// Description:Test pixels on CanvasFilter() componentTransfer with identity type +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("Test pixels on CanvasFilter() componentTransfer with identity type"); +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.filter = new CanvasFilter({name: 'componentTransfer', + funcR: {type: 'identity'}, + funcG: {type: 'identity'}, + funcB: {type: 'identity'}, + }); + + const inputColors = [ + [255, 255, 255], + [0, 0, 0], + [127, 0, 34], + [252, 186, 3], + [50, 68, 87], + ]; + + for (const color of inputColors) { + ctx.fillStyle = `rgba(${color[0]}, ${color[1]}, ${color[2]}, 1)`, + ctx.fillRect(0, 0, 10, 10); + _assertPixel(canvas, 5, 5, color[0],color[1],color[2],255); + } + t.done(); +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.componentTransfer.linear.tentative.html b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.componentTransfer.linear.tentative.html new file mode 100644 index 0000000000..adbe557fd9 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.componentTransfer.linear.tentative.html @@ -0,0 +1,57 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.filter.canvasFilterObject.componentTransfer.linear.tentative</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.filter.canvasFilterObject.componentTransfer.linear.tentative</h1> +<p class="desc">Test pixels on CanvasFilter() componentTransfer with linear type</p> + + +<script> +var t = async_test("Test pixels on CanvasFilter() componentTransfer with linear type"); +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'); + + // From https://www.w3.org/TR/SVG11/filters.html#feComponentTransferElement + function getColor(inputColor, slopes, intercepts) { + return [ + Math.max(0, Math.min(1, inputColor[0]/255 * slopes[0] + intercepts[0])) * 255, + Math.max(0, Math.min(1, inputColor[1]/255 * slopes[1] + intercepts[1])) * 255, + Math.max(0, Math.min(1, inputColor[2]/255 * slopes[2] + intercepts[2])) * 255, + ]; + } + + const slopes = [0.5, 1.2, -0.2]; + const intercepts = [0.25, 0, 0.5]; + ctx.filter = new CanvasFilter({name: 'componentTransfer', + funcR: {type: 'linear', slope: slopes[0], intercept: intercepts[0]}, + funcG: {type: 'linear', slope: slopes[1], intercept: intercepts[1]}, + funcB: {type: 'linear', slope: slopes[2], intercept: intercepts[2]}, + }); + + const inputColors = [ + [255, 255, 255], + [0, 0, 0], + [127, 0, 34], + [252, 186, 3], + [50, 68, 87], + ]; + + for (const color of inputColors) { + let outputColor = getColor(color, slopes, intercepts); + ctx.fillStyle = `rgb(${color[0]}, ${color[1]}, ${color[2]})`; + ctx.fillRect(0, 0, 10, 10); + _assertPixelApprox(canvas, 5, 5, outputColor[0],outputColor[1],outputColor[2],255, 2); + } + t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.componentTransfer.linear.tentative.worker.js b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.componentTransfer.linear.tentative.worker.js new file mode 100644 index 0000000000..fb2e01876f --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.componentTransfer.linear.tentative.worker.js @@ -0,0 +1,52 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.filter.canvasFilterObject.componentTransfer.linear.tentative +// Description:Test pixels on CanvasFilter() componentTransfer with linear type +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("Test pixels on CanvasFilter() componentTransfer with linear type"); +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'); + + // From https://www.w3.org/TR/SVG11/filters.html#feComponentTransferElement + function getColor(inputColor, slopes, intercepts) { + return [ + Math.max(0, Math.min(1, inputColor[0]/255 * slopes[0] + intercepts[0])) * 255, + Math.max(0, Math.min(1, inputColor[1]/255 * slopes[1] + intercepts[1])) * 255, + Math.max(0, Math.min(1, inputColor[2]/255 * slopes[2] + intercepts[2])) * 255, + ]; + } + + const slopes = [0.5, 1.2, -0.2]; + const intercepts = [0.25, 0, 0.5]; + ctx.filter = new CanvasFilter({name: 'componentTransfer', + funcR: {type: 'linear', slope: slopes[0], intercept: intercepts[0]}, + funcG: {type: 'linear', slope: slopes[1], intercept: intercepts[1]}, + funcB: {type: 'linear', slope: slopes[2], intercept: intercepts[2]}, + }); + + const inputColors = [ + [255, 255, 255], + [0, 0, 0], + [127, 0, 34], + [252, 186, 3], + [50, 68, 87], + ]; + + for (const color of inputColors) { + let outputColor = getColor(color, slopes, intercepts); + ctx.fillStyle = `rgb(${color[0]}, ${color[1]}, ${color[2]})`; + ctx.fillRect(0, 0, 10, 10); + _assertPixelApprox(canvas, 5, 5, outputColor[0],outputColor[1],outputColor[2],255, 2); + } + t.done(); +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.componentTransfer.table.tentative.html b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.componentTransfer.table.tentative.html new file mode 100644 index 0000000000..47048b68a1 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.componentTransfer.table.tentative.html @@ -0,0 +1,67 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.filter.canvasFilterObject.componentTransfer.table.tentative</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.filter.canvasFilterObject.componentTransfer.table.tentative</h1> +<p class="desc">Test pixels on CanvasFilter() componentTransfer with table type</p> + + +<script> +var t = async_test("Test pixels on CanvasFilter() componentTransfer with table type"); +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'); + + // From https://www.w3.org/TR/SVG11/filters.html#feComponentTransferElement + function getTransformedValue(C, V) { + // Get the right interval + const n = V.length - 1; + const k = C == 1 ? n - 1 : Math.floor(C * n); + return V[k] + (C - k/n) * n * (V[k + 1] - V[k]); + } + + function getColor(inputColor, tableValues) { + const result = [0, 0, 0]; + for (const i in inputColor) { + const C = inputColor[i]/255; + const Cprime = getTransformedValue(C, tableValues[i]); + result[i] = Math.max(0, Math.min(1, Cprime)) * 255; + } + return result; + } + + tableValuesR = [0, 0, 1, 1]; + tableValuesG = [2, 0, 0.5, 3]; + tableValuesB = [1, -1, 5, 0]; + ctx.filter = new CanvasFilter({name: 'componentTransfer', + funcR: {type: 'table', tableValues: tableValuesR}, + funcG: {type: 'table', tableValues: tableValuesG}, + funcB: {type: 'table', tableValues: tableValuesB}, + }); + + const inputColors = [ + [255, 255, 255], + [0, 0, 0], + [127, 0, 34], + [252, 186, 3], + [50, 68, 87], + ]; + + for (const color of inputColors) { + let outputColor = getColor(color, [tableValuesR, tableValuesG, tableValuesB]); + ctx.fillStyle = `rgb(${color[0]}, ${color[1]}, ${color[2]})`; + ctx.fillRect(0, 0, 10, 10); + _assertPixelApprox(canvas, 5, 5, outputColor[0],outputColor[1],outputColor[2],255, 2); + } + t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.componentTransfer.table.tentative.worker.js b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.componentTransfer.table.tentative.worker.js new file mode 100644 index 0000000000..0799e73a58 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.componentTransfer.table.tentative.worker.js @@ -0,0 +1,62 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.filter.canvasFilterObject.componentTransfer.table.tentative +// Description:Test pixels on CanvasFilter() componentTransfer with table type +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("Test pixels on CanvasFilter() componentTransfer with table type"); +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'); + + // From https://www.w3.org/TR/SVG11/filters.html#feComponentTransferElement + function getTransformedValue(C, V) { + // Get the right interval + const n = V.length - 1; + const k = C == 1 ? n - 1 : Math.floor(C * n); + return V[k] + (C - k/n) * n * (V[k + 1] - V[k]); + } + + function getColor(inputColor, tableValues) { + const result = [0, 0, 0]; + for (const i in inputColor) { + const C = inputColor[i]/255; + const Cprime = getTransformedValue(C, tableValues[i]); + result[i] = Math.max(0, Math.min(1, Cprime)) * 255; + } + return result; + } + + tableValuesR = [0, 0, 1, 1]; + tableValuesG = [2, 0, 0.5, 3]; + tableValuesB = [1, -1, 5, 0]; + ctx.filter = new CanvasFilter({name: 'componentTransfer', + funcR: {type: 'table', tableValues: tableValuesR}, + funcG: {type: 'table', tableValues: tableValuesG}, + funcB: {type: 'table', tableValues: tableValuesB}, + }); + + const inputColors = [ + [255, 255, 255], + [0, 0, 0], + [127, 0, 34], + [252, 186, 3], + [50, 68, 87], + ]; + + for (const color of inputColors) { + let outputColor = getColor(color, [tableValuesR, tableValuesG, tableValuesB]); + ctx.fillStyle = `rgb(${color[0]}, ${color[1]}, ${color[2]})`; + ctx.fillRect(0, 0, 10, 10); + _assertPixelApprox(canvas, 5, 5, outputColor[0],outputColor[1],outputColor[2],255, 2); + } + t.done(); +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.convolveMatrix.exceptions.tentative.html b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.convolveMatrix.exceptions.tentative.html new file mode 100644 index 0000000000..301d11f888 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.convolveMatrix.exceptions.tentative.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.filter.canvasFilterObject.convolveMatrix.exceptions.tentative</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.filter.canvasFilterObject.convolveMatrix.exceptions.tentative</h1> +<p class="desc">Test exceptions on CanvasFilter() convolveMatrix</p> + + +<script> +var t = async_test("Test exceptions on CanvasFilter() convolveMatrix"); +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() { new CanvasFilter({name: 'convolveMatrix'}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'convolveMatrix', divisor: 2}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'convolveMatrix', kernelMatrix: null}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'convolveMatrix', kernelMatrix: 1}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'convolveMatrix', kernelMatrix: [[1, 0], [0]]}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'convolveMatrix', kernelMatrix: [[1, 'a'], [0]]}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'convolveMatrix', kernelMatrix: [[1, 0], 0]}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'convolveMatrix', kernelMatrix: [[1, 0], [0, Infinity]]}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'convolveMatrix', kernelMatrix: []}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'convolveMatrix', kernelMatrix: [1]}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'convolveMatrix', kernelMatrix: [1, 2, 3, 4]}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'convolveMatrix', kernelMatrix: [[], []]}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'convolveMatrix', kernelMatrix: [[1, 2], []]}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'convolveMatrix', kernelMatrix: [[], [1, 2]]}); }); + // This should not throw an error + ctx.filter = new CanvasFilter({name: 'convolveMatrix', kernelMatrix: [[]]}); + ctx.filter = new CanvasFilter({name: 'convolveMatrix', kernelMatrix: [[1]]}); + t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.convolveMatrix.exceptions.tentative.worker.js b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.convolveMatrix.exceptions.tentative.worker.js new file mode 100644 index 0000000000..b4ce4d76b2 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.convolveMatrix.exceptions.tentative.worker.js @@ -0,0 +1,38 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.filter.canvasFilterObject.convolveMatrix.exceptions.tentative +// Description:Test exceptions on CanvasFilter() convolveMatrix +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("Test exceptions on CanvasFilter() convolveMatrix"); +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() { new CanvasFilter({name: 'convolveMatrix'}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'convolveMatrix', divisor: 2}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'convolveMatrix', kernelMatrix: null}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'convolveMatrix', kernelMatrix: 1}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'convolveMatrix', kernelMatrix: [[1, 0], [0]]}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'convolveMatrix', kernelMatrix: [[1, 'a'], [0]]}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'convolveMatrix', kernelMatrix: [[1, 0], 0]}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'convolveMatrix', kernelMatrix: [[1, 0], [0, Infinity]]}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'convolveMatrix', kernelMatrix: []}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'convolveMatrix', kernelMatrix: [1]}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'convolveMatrix', kernelMatrix: [1, 2, 3, 4]}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'convolveMatrix', kernelMatrix: [[], []]}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'convolveMatrix', kernelMatrix: [[1, 2], []]}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'convolveMatrix', kernelMatrix: [[], [1, 2]]}); }); + // This should not throw an error + ctx.filter = new CanvasFilter({name: 'convolveMatrix', kernelMatrix: [[]]}); + ctx.filter = new CanvasFilter({name: 'convolveMatrix', kernelMatrix: [[1]]}); + t.done(); +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.dropShadow.exceptions.tentative.html b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.dropShadow.exceptions.tentative.html new file mode 100644 index 0000000000..3e55e97e54 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.dropShadow.exceptions.tentative.html @@ -0,0 +1,124 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.filter.canvasFilterObject.dropShadow.exceptions.tentative</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.filter.canvasFilterObject.dropShadow.exceptions.tentative</h1> +<p class="desc">Test exceptions on CanvasFilter() dropShadow object</p> + + +<script> +var t = async_test("Test exceptions on CanvasFilter() dropShadow object"); +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'); + + // dx + _assert(new CanvasFilter({name: 'dropShadow', dx: 10}), "new CanvasFilter({name: 'dropShadow', dx: 10})"); + _assert(new CanvasFilter({name: 'dropShadow', dx: -1}), "new CanvasFilter({name: 'dropShadow', dx: -1})"); + _assert(new CanvasFilter({name: 'dropShadow', dx: 0.5}), "new CanvasFilter({name: 'dropShadow', dx: 0.5})"); + _assert(new CanvasFilter({name: 'dropShadow', dx: null}), "new CanvasFilter({name: 'dropShadow', dx: null})"); + _assert(new CanvasFilter({name: 'dropShadow', dx: true}), "new CanvasFilter({name: 'dropShadow', dx: true})"); + _assert(new CanvasFilter({name: 'dropShadow', dx: false}), "new CanvasFilter({name: 'dropShadow', dx: false})"); + _assert(new CanvasFilter({name: 'dropShadow', dx: []}), "new CanvasFilter({name: 'dropShadow', dx: []})"); + _assert(new CanvasFilter({name: 'dropShadow', dx: [20]}), "new CanvasFilter({name: 'dropShadow', dx: [\""+(20)+"\"]})"); + _assert(new CanvasFilter({name: 'dropShadow', dx: '30'}), "new CanvasFilter({name: 'dropShadow', dx: '30'})"); + // dy + _assert(new CanvasFilter({name: 'dropShadow', dy: 10}), "new CanvasFilter({name: 'dropShadow', dy: 10})"); + _assert(new CanvasFilter({name: 'dropShadow', dy: -1}), "new CanvasFilter({name: 'dropShadow', dy: -1})"); + _assert(new CanvasFilter({name: 'dropShadow', dy: 0.5}), "new CanvasFilter({name: 'dropShadow', dy: 0.5})"); + _assert(new CanvasFilter({name: 'dropShadow', dy: null}), "new CanvasFilter({name: 'dropShadow', dy: null})"); + _assert(new CanvasFilter({name: 'dropShadow', dy: true}), "new CanvasFilter({name: 'dropShadow', dy: true})"); + _assert(new CanvasFilter({name: 'dropShadow', dy: false}), "new CanvasFilter({name: 'dropShadow', dy: false})"); + _assert(new CanvasFilter({name: 'dropShadow', dy: []}), "new CanvasFilter({name: 'dropShadow', dy: []})"); + _assert(new CanvasFilter({name: 'dropShadow', dy: [20]}), "new CanvasFilter({name: 'dropShadow', dy: [\""+(20)+"\"]})"); + _assert(new CanvasFilter({name: 'dropShadow', dy: '30'}), "new CanvasFilter({name: 'dropShadow', dy: '30'})"); + // floodOpacity + _assert(new CanvasFilter({name: 'dropShadow', floodOpacity: 10}), "new CanvasFilter({name: 'dropShadow', floodOpacity: 10})"); + _assert(new CanvasFilter({name: 'dropShadow', floodOpacity: -1}), "new CanvasFilter({name: 'dropShadow', floodOpacity: -1})"); + _assert(new CanvasFilter({name: 'dropShadow', floodOpacity: 0.5}), "new CanvasFilter({name: 'dropShadow', floodOpacity: 0.5})"); + _assert(new CanvasFilter({name: 'dropShadow', floodOpacity: null}), "new CanvasFilter({name: 'dropShadow', floodOpacity: null})"); + _assert(new CanvasFilter({name: 'dropShadow', floodOpacity: true}), "new CanvasFilter({name: 'dropShadow', floodOpacity: true})"); + _assert(new CanvasFilter({name: 'dropShadow', floodOpacity: false}), "new CanvasFilter({name: 'dropShadow', floodOpacity: false})"); + _assert(new CanvasFilter({name: 'dropShadow', floodOpacity: []}), "new CanvasFilter({name: 'dropShadow', floodOpacity: []})"); + _assert(new CanvasFilter({name: 'dropShadow', floodOpacity: [20]}), "new CanvasFilter({name: 'dropShadow', floodOpacity: [\""+(20)+"\"]})"); + _assert(new CanvasFilter({name: 'dropShadow', floodOpacity: '30'}), "new CanvasFilter({name: 'dropShadow', floodOpacity: '30'})"); + // stdDeviation + _assert(new CanvasFilter({name: 'dropShadow', stdDeviation: 10}), "new CanvasFilter({name: 'dropShadow', stdDeviation: 10})"); + _assert(new CanvasFilter({name: 'dropShadow', stdDeviation: -1}), "new CanvasFilter({name: 'dropShadow', stdDeviation: -1})"); + _assert(new CanvasFilter({name: 'dropShadow', stdDeviation: 0.5}), "new CanvasFilter({name: 'dropShadow', stdDeviation: 0.5})"); + _assert(new CanvasFilter({name: 'dropShadow', stdDeviation: null}), "new CanvasFilter({name: 'dropShadow', stdDeviation: null})"); + _assert(new CanvasFilter({name: 'dropShadow', stdDeviation: true}), "new CanvasFilter({name: 'dropShadow', stdDeviation: true})"); + _assert(new CanvasFilter({name: 'dropShadow', stdDeviation: false}), "new CanvasFilter({name: 'dropShadow', stdDeviation: false})"); + _assert(new CanvasFilter({name: 'dropShadow', stdDeviation: []}), "new CanvasFilter({name: 'dropShadow', stdDeviation: []})"); + _assert(new CanvasFilter({name: 'dropShadow', stdDeviation: [20]}), "new CanvasFilter({name: 'dropShadow', stdDeviation: [\""+(20)+"\"]})"); + _assert(new CanvasFilter({name: 'dropShadow', stdDeviation: '30'}), "new CanvasFilter({name: 'dropShadow', stdDeviation: '30'})"); + _assert(new CanvasFilter({name: 'dropShadow', stdDeviation: [10, -1]}), "new CanvasFilter({name: 'dropShadow', stdDeviation: [10, -1]})"); + _assert(new CanvasFilter({name: 'dropShadow', stdDeviation: [0.5, null]}), "new CanvasFilter({name: 'dropShadow', stdDeviation: [0.5, null]})"); + _assert(new CanvasFilter({name: 'dropShadow', stdDeviation: [true, false]}), "new CanvasFilter({name: 'dropShadow', stdDeviation: [true, false]})"); + _assert(new CanvasFilter({name: 'dropShadow', stdDeviation: [[], [20]]}), "new CanvasFilter({name: 'dropShadow', stdDeviation: [[], [\""+(20)+"\"]]})"); + _assert(new CanvasFilter({name: 'dropShadow', stdDeviation: ['30', ['40']]}), "new CanvasFilter({name: 'dropShadow', stdDeviation: ['30', ['40']]})"); + // floodColor + _assert(new CanvasFilter({name: 'dropShadow', floodColor: 'red'}), "new CanvasFilter({name: 'dropShadow', floodColor: 'red'})"); + _assert(new CanvasFilter({name: 'dropShadow', floodColor: 'canvas'}), "new CanvasFilter({name: 'dropShadow', floodColor: 'canvas'})"); + _assert(new CanvasFilter({name: 'dropShadow', floodColor: 'rgba(4, -3, 0.5, 1)'}), "new CanvasFilter({name: 'dropShadow', floodColor: 'rgba(4, -3, 0.5, 1)'})"); + _assert(new CanvasFilter({name: 'dropShadow', floodColor: '#aabbccdd'}), "new CanvasFilter({name: 'dropShadow', floodColor: '#aabbccdd'})"); + _assert(new CanvasFilter({name: 'dropShadow', floodColor: '#abcd'}), "new CanvasFilter({name: 'dropShadow', floodColor: '#abcd'})"); + + // dx + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', dx: NaN}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', dx: Infinity}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', dx: -Infinity}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', dx: undefined}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', dx: 'test'}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', dx: {}}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', dx: [1, 2]}); }); + // dy + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', dy: NaN}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', dy: Infinity}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', dy: -Infinity}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', dy: undefined}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', dy: 'test'}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', dy: {}}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', dy: [1, 2]}); }); + // floodOpacity + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', floodOpacity: NaN}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', floodOpacity: Infinity}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', floodOpacity: -Infinity}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', floodOpacity: undefined}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', floodOpacity: 'test'}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', floodOpacity: {}}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', floodOpacity: [1, 2]}); }); + // stdDeviation + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', stdDeviation: NaN}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', stdDeviation: Infinity}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', stdDeviation: -Infinity}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', stdDeviation: undefined}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', stdDeviation: 'test'}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', stdDeviation: {}}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', stdDeviation: [1, 2, 3]}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', stdDeviation: [1, NaN]}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', stdDeviation: [1, Infinity]}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', stdDeviation: [1, -Infinity]}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', stdDeviation: [1, undefined]}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', stdDeviation: [1, 'test']}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', stdDeviation: [1, {}]}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', stdDeviation: [1, [2, 3]]}); }); + // floodColor + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', floodColor: 'test'}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', floodColor: 'rgba(NaN, 3, 2, 1)'}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', floodColor: 10}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', floodColor: undefined}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', floodColor: null}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', floodColor: NaN}); }); + t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.dropShadow.exceptions.tentative.worker.js b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.dropShadow.exceptions.tentative.worker.js new file mode 100644 index 0000000000..bd18524f28 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.dropShadow.exceptions.tentative.worker.js @@ -0,0 +1,119 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.filter.canvasFilterObject.dropShadow.exceptions.tentative +// Description:Test exceptions on CanvasFilter() dropShadow object +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("Test exceptions on CanvasFilter() dropShadow object"); +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'); + + // dx + _assert(new CanvasFilter({name: 'dropShadow', dx: 10}), "new CanvasFilter({name: 'dropShadow', dx: 10})"); + _assert(new CanvasFilter({name: 'dropShadow', dx: -1}), "new CanvasFilter({name: 'dropShadow', dx: -1})"); + _assert(new CanvasFilter({name: 'dropShadow', dx: 0.5}), "new CanvasFilter({name: 'dropShadow', dx: 0.5})"); + _assert(new CanvasFilter({name: 'dropShadow', dx: null}), "new CanvasFilter({name: 'dropShadow', dx: null})"); + _assert(new CanvasFilter({name: 'dropShadow', dx: true}), "new CanvasFilter({name: 'dropShadow', dx: true})"); + _assert(new CanvasFilter({name: 'dropShadow', dx: false}), "new CanvasFilter({name: 'dropShadow', dx: false})"); + _assert(new CanvasFilter({name: 'dropShadow', dx: []}), "new CanvasFilter({name: 'dropShadow', dx: []})"); + _assert(new CanvasFilter({name: 'dropShadow', dx: [20]}), "new CanvasFilter({name: 'dropShadow', dx: [\""+(20)+"\"]})"); + _assert(new CanvasFilter({name: 'dropShadow', dx: '30'}), "new CanvasFilter({name: 'dropShadow', dx: '30'})"); + // dy + _assert(new CanvasFilter({name: 'dropShadow', dy: 10}), "new CanvasFilter({name: 'dropShadow', dy: 10})"); + _assert(new CanvasFilter({name: 'dropShadow', dy: -1}), "new CanvasFilter({name: 'dropShadow', dy: -1})"); + _assert(new CanvasFilter({name: 'dropShadow', dy: 0.5}), "new CanvasFilter({name: 'dropShadow', dy: 0.5})"); + _assert(new CanvasFilter({name: 'dropShadow', dy: null}), "new CanvasFilter({name: 'dropShadow', dy: null})"); + _assert(new CanvasFilter({name: 'dropShadow', dy: true}), "new CanvasFilter({name: 'dropShadow', dy: true})"); + _assert(new CanvasFilter({name: 'dropShadow', dy: false}), "new CanvasFilter({name: 'dropShadow', dy: false})"); + _assert(new CanvasFilter({name: 'dropShadow', dy: []}), "new CanvasFilter({name: 'dropShadow', dy: []})"); + _assert(new CanvasFilter({name: 'dropShadow', dy: [20]}), "new CanvasFilter({name: 'dropShadow', dy: [\""+(20)+"\"]})"); + _assert(new CanvasFilter({name: 'dropShadow', dy: '30'}), "new CanvasFilter({name: 'dropShadow', dy: '30'})"); + // floodOpacity + _assert(new CanvasFilter({name: 'dropShadow', floodOpacity: 10}), "new CanvasFilter({name: 'dropShadow', floodOpacity: 10})"); + _assert(new CanvasFilter({name: 'dropShadow', floodOpacity: -1}), "new CanvasFilter({name: 'dropShadow', floodOpacity: -1})"); + _assert(new CanvasFilter({name: 'dropShadow', floodOpacity: 0.5}), "new CanvasFilter({name: 'dropShadow', floodOpacity: 0.5})"); + _assert(new CanvasFilter({name: 'dropShadow', floodOpacity: null}), "new CanvasFilter({name: 'dropShadow', floodOpacity: null})"); + _assert(new CanvasFilter({name: 'dropShadow', floodOpacity: true}), "new CanvasFilter({name: 'dropShadow', floodOpacity: true})"); + _assert(new CanvasFilter({name: 'dropShadow', floodOpacity: false}), "new CanvasFilter({name: 'dropShadow', floodOpacity: false})"); + _assert(new CanvasFilter({name: 'dropShadow', floodOpacity: []}), "new CanvasFilter({name: 'dropShadow', floodOpacity: []})"); + _assert(new CanvasFilter({name: 'dropShadow', floodOpacity: [20]}), "new CanvasFilter({name: 'dropShadow', floodOpacity: [\""+(20)+"\"]})"); + _assert(new CanvasFilter({name: 'dropShadow', floodOpacity: '30'}), "new CanvasFilter({name: 'dropShadow', floodOpacity: '30'})"); + // stdDeviation + _assert(new CanvasFilter({name: 'dropShadow', stdDeviation: 10}), "new CanvasFilter({name: 'dropShadow', stdDeviation: 10})"); + _assert(new CanvasFilter({name: 'dropShadow', stdDeviation: -1}), "new CanvasFilter({name: 'dropShadow', stdDeviation: -1})"); + _assert(new CanvasFilter({name: 'dropShadow', stdDeviation: 0.5}), "new CanvasFilter({name: 'dropShadow', stdDeviation: 0.5})"); + _assert(new CanvasFilter({name: 'dropShadow', stdDeviation: null}), "new CanvasFilter({name: 'dropShadow', stdDeviation: null})"); + _assert(new CanvasFilter({name: 'dropShadow', stdDeviation: true}), "new CanvasFilter({name: 'dropShadow', stdDeviation: true})"); + _assert(new CanvasFilter({name: 'dropShadow', stdDeviation: false}), "new CanvasFilter({name: 'dropShadow', stdDeviation: false})"); + _assert(new CanvasFilter({name: 'dropShadow', stdDeviation: []}), "new CanvasFilter({name: 'dropShadow', stdDeviation: []})"); + _assert(new CanvasFilter({name: 'dropShadow', stdDeviation: [20]}), "new CanvasFilter({name: 'dropShadow', stdDeviation: [\""+(20)+"\"]})"); + _assert(new CanvasFilter({name: 'dropShadow', stdDeviation: '30'}), "new CanvasFilter({name: 'dropShadow', stdDeviation: '30'})"); + _assert(new CanvasFilter({name: 'dropShadow', stdDeviation: [10, -1]}), "new CanvasFilter({name: 'dropShadow', stdDeviation: [10, -1]})"); + _assert(new CanvasFilter({name: 'dropShadow', stdDeviation: [0.5, null]}), "new CanvasFilter({name: 'dropShadow', stdDeviation: [0.5, null]})"); + _assert(new CanvasFilter({name: 'dropShadow', stdDeviation: [true, false]}), "new CanvasFilter({name: 'dropShadow', stdDeviation: [true, false]})"); + _assert(new CanvasFilter({name: 'dropShadow', stdDeviation: [[], [20]]}), "new CanvasFilter({name: 'dropShadow', stdDeviation: [[], [\""+(20)+"\"]]})"); + _assert(new CanvasFilter({name: 'dropShadow', stdDeviation: ['30', ['40']]}), "new CanvasFilter({name: 'dropShadow', stdDeviation: ['30', ['40']]})"); + // floodColor + _assert(new CanvasFilter({name: 'dropShadow', floodColor: 'red'}), "new CanvasFilter({name: 'dropShadow', floodColor: 'red'})"); + _assert(new CanvasFilter({name: 'dropShadow', floodColor: 'canvas'}), "new CanvasFilter({name: 'dropShadow', floodColor: 'canvas'})"); + _assert(new CanvasFilter({name: 'dropShadow', floodColor: 'rgba(4, -3, 0.5, 1)'}), "new CanvasFilter({name: 'dropShadow', floodColor: 'rgba(4, -3, 0.5, 1)'})"); + _assert(new CanvasFilter({name: 'dropShadow', floodColor: '#aabbccdd'}), "new CanvasFilter({name: 'dropShadow', floodColor: '#aabbccdd'})"); + _assert(new CanvasFilter({name: 'dropShadow', floodColor: '#abcd'}), "new CanvasFilter({name: 'dropShadow', floodColor: '#abcd'})"); + + // dx + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', dx: NaN}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', dx: Infinity}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', dx: -Infinity}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', dx: undefined}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', dx: 'test'}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', dx: {}}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', dx: [1, 2]}); }); + // dy + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', dy: NaN}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', dy: Infinity}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', dy: -Infinity}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', dy: undefined}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', dy: 'test'}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', dy: {}}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', dy: [1, 2]}); }); + // floodOpacity + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', floodOpacity: NaN}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', floodOpacity: Infinity}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', floodOpacity: -Infinity}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', floodOpacity: undefined}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', floodOpacity: 'test'}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', floodOpacity: {}}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', floodOpacity: [1, 2]}); }); + // stdDeviation + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', stdDeviation: NaN}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', stdDeviation: Infinity}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', stdDeviation: -Infinity}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', stdDeviation: undefined}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', stdDeviation: 'test'}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', stdDeviation: {}}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', stdDeviation: [1, 2, 3]}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', stdDeviation: [1, NaN]}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', stdDeviation: [1, Infinity]}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', stdDeviation: [1, -Infinity]}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', stdDeviation: [1, undefined]}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', stdDeviation: [1, 'test']}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', stdDeviation: [1, {}]}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', stdDeviation: [1, [2, 3]]}); }); + // floodColor + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', floodColor: 'test'}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', floodColor: 'rgba(NaN, 3, 2, 1)'}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', floodColor: 10}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', floodColor: undefined}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', floodColor: null}); }); + assert_throws_js(TypeError, function() { new CanvasFilter({name: 'dropShadow', floodColor: NaN}); }); + t.done(); +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.dropShadow.tentative-expected.html b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.dropShadow.tentative-expected.html new file mode 100644 index 0000000000..86c5710132 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.dropShadow.tentative-expected.html @@ -0,0 +1,57 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: 2d.filter.canvasFilterObject.dropShadow.tentative</title> +<h1>2d.filter.canvasFilterObject.dropShadow.tentative</h1> +<p class="desc">Test CanvasFilter() dropShadow object.</p> + +<svg xmlns="http://www.w3.org/2000/svg" + width=520 height=420 + color-interpolation-filters="sRGB"> + <rect x=0 y=0 width=100% height=50 fill="teal" /> + <rect x=0 y=100 width=100% height=50 fill="teal" /> + <rect x=0 y=200 width=100% height=50 fill="teal" /> + <rect x=0 y=300 width=100% height=50 fill="teal" /> + + <rect x=10 y=10 width=80 height=80 fill="crimson" + filter="drop-shadow(2px 2px 2px black)"/> + <rect x=110 y=10 width=80 height=80 fill="crimson" + filter="drop-shadow(9px 12px 5px rgba(128, 0, 128, 0.7))"/> + + <rect x=10 y=110 width=80 height=80 fill="crimson" + filter="drop-shadow(9px 12px 3px purple)"/> + <rect x=110 y=110 width=80 height=80 fill="crimson" + filter="drop-shadow(9px 12px 3px LinkText)"/> + <rect x=210 y=110 width=80 height=80 fill="crimson" + filter="drop-shadow(9px 12px 3px rgba(20, 50, 130, 1))"/> + <rect x=310 y=110 width=80 height=80 fill="crimson" + filter="drop-shadow(9px 12px 3px rgba(20, 50, 130, 0.7))"/> + <rect x=410 y=110 width=80 height=80 fill="crimson" + filter="drop-shadow(9px 12px 3px rgba(20, 50, 130, 0.49))"/> + + <rect x=10 y=210 width=80 height=80 fill="crimson" + filter="drop-shadow(9px 12px 0px purple)"/> + <rect x=110 y=210 width=80 height=80 fill="crimson" + filter="drop-shadow(9px 12px 5px purple)"/> + <rect x=210 y=210 width=80 height=80 fill="crimson" + filter="drop-shadow(9px 12px 0px purple)"/> + <filter id="separable-filter" + x="-100%" y="-100%" width="300%" height="300%"> + <feDropShadow dx=9 dy=12 stdDeviation="3 5" flood-color="purple"/> + </filter> + <rect x=310 y=210 width=80 height=80 fill="crimson" + filter="url(#separable-filter)"/> + <rect x=410 y=210 width=80 height=80 fill="crimson" + filter="drop-shadow(9px 12px 0px purple)"/> + + <rect x=10 y=310 width=80 height=80 fill="crimson" + filter="drop-shadow(-5px 0px 0px purple)"/> + <filter id="separable-filter-degenerate" + x="-100%" y="-100%" width="300%" height="300%"> + <feDropShadow dx=0 dy=5 stdDeviation="0 3" + flood-color="rgba(128, 0, 128, 0.8)"/> + </filter> + <rect x=110 y=310 width=80 height=80 fill="crimson" + filter="url(#separable-filter-degenerate)"/> + <rect x=210 y=310 width=80 height=80 fill="crimson" + filter="drop-shadow(1px 10px 0px rgba(128, 0, 128, 0.4))"/> +</svg> diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.dropShadow.tentative.html b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.dropShadow.tentative.html new file mode 100644 index 0000000000..81eb1eae45 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.dropShadow.tentative.html @@ -0,0 +1,110 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<link rel="match" href="2d.filter.canvasFilterObject.dropShadow.tentative-expected.html"> +<title>Canvas test: 2d.filter.canvasFilterObject.dropShadow.tentative</title> +<h1>2d.filter.canvasFilterObject.dropShadow.tentative</h1> +<p class="desc">Test CanvasFilter() dropShadow object.</p> +<canvas id="canvas" width="520" height="420"> + <p class="fallback">FAIL (fallback content)</p> +</canvas> +<script> + const canvas = new OffscreenCanvas(520, 420); + const ctx = canvas.getContext('2d'); + + ctx.fillStyle = 'teal'; + ctx.fillRect(0, 0, 520, 50); + ctx.fillRect(0, 100, 520, 50); + ctx.fillRect(0, 200, 520, 50); + ctx.fillRect(0, 300, 520, 50); + + ctx.fillStyle = 'crimson'; + + // Parameter defaults. + ctx.filter = new CanvasFilter({name: 'dropShadow'}); + ctx.fillRect(10, 10, 80, 80); + + // All parameters specified. + ctx.filter = new CanvasFilter( + {name: 'dropShadow', dx: 9, dy: 12, stdDeviation: 5, + floodColor: 'purple', floodOpacity: 0.7}); + ctx.fillRect(110, 10, 80, 80); + + // Named color. + ctx.filter = new CanvasFilter( + {name: 'dropShadow', dx: 9, dy: 12, stdDeviation: 3, + floodColor: 'purple'}); + ctx.fillRect(10, 110, 80, 80); + + // System color. + ctx.filter = new CanvasFilter( + {name: 'dropShadow', dx: 9, dy: 12, stdDeviation: 3, + floodColor: 'LinkText'}); + ctx.fillRect(110, 110, 80, 80); + + // Numerical color. + ctx.filter = new CanvasFilter( + {name: 'dropShadow', dx: 9, dy: 12, stdDeviation: 3, + floodColor: 'rgba(20, 50, 130, 1)'}); + ctx.fillRect(210, 110, 80, 80); + + // Transparent floodColor. + ctx.filter = new CanvasFilter( + {name: 'dropShadow', dx: 9, dy: 12, stdDeviation: 3, + floodColor: 'rgba(20, 50, 130, 0.7)'}); + ctx.fillRect(310, 110, 80, 80); + + // Transparent floodColor and floodOpacity. + ctx.filter = new CanvasFilter( + {name: 'dropShadow', dx: 9, dy: 12, stdDeviation: 3, + floodColor: 'rgba(20, 50, 130, 0.7)', floodOpacity: 0.7}); + ctx.fillRect(410, 110, 80, 80); + + // No blur. + ctx.filter = new CanvasFilter( + {name: 'dropShadow', dx: 9, dy: 12, stdDeviation: 0, + floodColor: 'purple'}); + ctx.fillRect(10, 210, 80, 80); + + // Single float blur. + ctx.filter = new CanvasFilter( + {name: 'dropShadow', dx: 9, dy: 12, stdDeviation: 5, + floodColor: 'purple'}); + ctx.fillRect(110, 210, 80, 80); + + // Single negative float blur. + ctx.filter = new CanvasFilter( + {name: 'dropShadow', dx: 9, dy: 12, stdDeviation: -5, + floodColor: 'purple'}); + ctx.fillRect(210, 210, 80, 80); + + // Two floats (X&Y) blur. + ctx.filter = new CanvasFilter( + {name: 'dropShadow', dx: 9, dy: 12, stdDeviation: [3, 5], + floodColor: 'purple'}); + ctx.fillRect(310, 210, 80, 80); + + // Two negative floats (X&Y) blur. + ctx.filter = new CanvasFilter( + {name: 'dropShadow', dx: 9, dy: 12, stdDeviation: [-3, -5], + floodColor: 'purple'}); + ctx.fillRect(410, 210, 80, 80); + + // Degenerate parameter values. + ctx.filter = new CanvasFilter( + {name: 'dropShadow', dx: [-5], dy: [], stdDeviation: null, + floodColor: 'purple', floodOpacity: [2]}); + ctx.fillRect(10, 310, 80, 80); + + ctx.filter = new CanvasFilter( + {name: 'dropShadow', dx: null, dy: '5', stdDeviation: [[-5], ['3']], + floodColor: 'purple', floodOpacity: '0.8'}); + ctx.fillRect(110, 310, 80, 80); + + ctx.filter = new CanvasFilter( + {name: 'dropShadow', dx: true, dy: ['10'], stdDeviation: false, + floodColor: 'purple', floodOpacity: ['0.4']}); + ctx.fillRect(210, 310, 80, 80); + + const outputCanvas = document.getElementById("canvas"); + outputCanvas.getContext('2d').drawImage(canvas, 0, 0); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.dropShadow.tentative.w.html b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.dropShadow.tentative.w.html new file mode 100644 index 0000000000..fe9087244a --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.dropShadow.tentative.w.html @@ -0,0 +1,124 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<html class="reftest-wait"> +<link rel="match" href="2d.filter.canvasFilterObject.dropShadow.tentative-expected.html"> +<title>Canvas test: 2d.filter.canvasFilterObject.dropShadow.tentative</title> +<h1>2d.filter.canvasFilterObject.dropShadow.tentative</h1> +<p class="desc">Test CanvasFilter() dropShadow object.</p> +<canvas id="canvas" width="520" height="420"> + <p class="fallback">FAIL (fallback content)</p> +</canvas> +<script id='myWorker' type='text/worker'> + self.onmessage = function(e) { + const canvas = new OffscreenCanvas(520, 420); + const ctx = canvas.getContext('2d'); + + ctx.fillStyle = 'teal'; + ctx.fillRect(0, 0, 520, 50); + ctx.fillRect(0, 100, 520, 50); + ctx.fillRect(0, 200, 520, 50); + ctx.fillRect(0, 300, 520, 50); + + ctx.fillStyle = 'crimson'; + + // Parameter defaults. + ctx.filter = new CanvasFilter({name: 'dropShadow'}); + ctx.fillRect(10, 10, 80, 80); + + // All parameters specified. + ctx.filter = new CanvasFilter( + {name: 'dropShadow', dx: 9, dy: 12, stdDeviation: 5, + floodColor: 'purple', floodOpacity: 0.7}); + ctx.fillRect(110, 10, 80, 80); + + // Named color. + ctx.filter = new CanvasFilter( + {name: 'dropShadow', dx: 9, dy: 12, stdDeviation: 3, + floodColor: 'purple'}); + ctx.fillRect(10, 110, 80, 80); + + // System color. + ctx.filter = new CanvasFilter( + {name: 'dropShadow', dx: 9, dy: 12, stdDeviation: 3, + floodColor: 'LinkText'}); + ctx.fillRect(110, 110, 80, 80); + + // Numerical color. + ctx.filter = new CanvasFilter( + {name: 'dropShadow', dx: 9, dy: 12, stdDeviation: 3, + floodColor: 'rgba(20, 50, 130, 1)'}); + ctx.fillRect(210, 110, 80, 80); + + // Transparent floodColor. + ctx.filter = new CanvasFilter( + {name: 'dropShadow', dx: 9, dy: 12, stdDeviation: 3, + floodColor: 'rgba(20, 50, 130, 0.7)'}); + ctx.fillRect(310, 110, 80, 80); + + // Transparent floodColor and floodOpacity. + ctx.filter = new CanvasFilter( + {name: 'dropShadow', dx: 9, dy: 12, stdDeviation: 3, + floodColor: 'rgba(20, 50, 130, 0.7)', floodOpacity: 0.7}); + ctx.fillRect(410, 110, 80, 80); + + // No blur. + ctx.filter = new CanvasFilter( + {name: 'dropShadow', dx: 9, dy: 12, stdDeviation: 0, + floodColor: 'purple'}); + ctx.fillRect(10, 210, 80, 80); + + // Single float blur. + ctx.filter = new CanvasFilter( + {name: 'dropShadow', dx: 9, dy: 12, stdDeviation: 5, + floodColor: 'purple'}); + ctx.fillRect(110, 210, 80, 80); + + // Single negative float blur. + ctx.filter = new CanvasFilter( + {name: 'dropShadow', dx: 9, dy: 12, stdDeviation: -5, + floodColor: 'purple'}); + ctx.fillRect(210, 210, 80, 80); + + // Two floats (X&Y) blur. + ctx.filter = new CanvasFilter( + {name: 'dropShadow', dx: 9, dy: 12, stdDeviation: [3, 5], + floodColor: 'purple'}); + ctx.fillRect(310, 210, 80, 80); + + // Two negative floats (X&Y) blur. + ctx.filter = new CanvasFilter( + {name: 'dropShadow', dx: 9, dy: 12, stdDeviation: [-3, -5], + floodColor: 'purple'}); + ctx.fillRect(410, 210, 80, 80); + + // Degenerate parameter values. + ctx.filter = new CanvasFilter( + {name: 'dropShadow', dx: [-5], dy: [], stdDeviation: null, + floodColor: 'purple', floodOpacity: [2]}); + ctx.fillRect(10, 310, 80, 80); + + ctx.filter = new CanvasFilter( + {name: 'dropShadow', dx: null, dy: '5', stdDeviation: [[-5], ['3']], + floodColor: 'purple', floodOpacity: '0.8'}); + ctx.fillRect(110, 310, 80, 80); + + ctx.filter = new CanvasFilter( + {name: 'dropShadow', dx: true, dy: ['10'], stdDeviation: false, + floodColor: 'purple', floodOpacity: ['0.4']}); + ctx.fillRect(210, 310, 80, 80); + + const bitmap = canvas.transferToImageBitmap(); + self.postMessage(bitmap, bitmap); + }; +</script> +<script> + const blob = new Blob([document.getElementById('myWorker').textContent]); + const worker = new Worker(URL.createObjectURL(blob)); + worker.addEventListener('message', msg => { + const outputCtx = document.getElementById("canvas").getContext('2d'); + outputCtx.drawImage(msg.data, 0, 0); + document.documentElement.classList.remove("reftest-wait"); + }); + worker.postMessage(null); +</script> +</html> diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.isotropic-expected.html b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.isotropic-expected.html new file mode 100644 index 0000000000..f9571f208e --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.isotropic-expected.html @@ -0,0 +1,15 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: 2d.filter.canvasFilterObject.gaussianBlur.tentative.isotropic</title> +<h1>2d.filter.canvasFilterObject.gaussianBlur.tentative.isotropic</h1> +<p class="desc">Test CanvasFilter() with gaussianBlur.</p> + +<svg xmlns="http://www.w3.org/2000/svg" + width="100" height="100" + color-interpolation-filters="sRGB"> + <filter id="blur" x="-50%" y="-50%" width="200%" height="200%"> + <feGaussianBlur stdDeviation="4 4" /> + </filter> + <rect x="25" y="25" width="50" height="50" + fill="teal" filter="url(#blur)" /> +</svg> diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.isotropic.html b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.isotropic.html new file mode 100644 index 0000000000..4417a1917c --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.isotropic.html @@ -0,0 +1,23 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<link rel="match" href="2d.filter.canvasFilterObject.gaussianBlur.tentative.isotropic-expected.html"> +<title>Canvas test: 2d.filter.canvasFilterObject.gaussianBlur.tentative.isotropic</title> +<h1>2d.filter.canvasFilterObject.gaussianBlur.tentative.isotropic</h1> +<p class="desc">Test CanvasFilter() with gaussianBlur.</p> +<canvas id="canvas" width="100" height="100"> + <p class="fallback">FAIL (fallback content)</p> +</canvas> +<script> + const canvas = new OffscreenCanvas(100, 100); + const ctx = canvas.getContext('2d'); + + ctx.fillStyle = 'teal'; + ctx.filter = new CanvasFilter({ + name: 'gaussianBlur', + stdDeviation: [4, 4], + }); + ctx.fillRect(25, 25, 50, 50); + + const outputCanvas = document.getElementById("canvas"); + outputCanvas.getContext('2d').drawImage(canvas, 0, 0); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.isotropic.w.html b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.isotropic.w.html new file mode 100644 index 0000000000..d2024ad205 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.isotropic.w.html @@ -0,0 +1,37 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<html class="reftest-wait"> +<link rel="match" href="2d.filter.canvasFilterObject.gaussianBlur.tentative.isotropic-expected.html"> +<title>Canvas test: 2d.filter.canvasFilterObject.gaussianBlur.tentative.isotropic</title> +<h1>2d.filter.canvasFilterObject.gaussianBlur.tentative.isotropic</h1> +<p class="desc">Test CanvasFilter() with gaussianBlur.</p> +<canvas id="canvas" width="100" height="100"> + <p class="fallback">FAIL (fallback content)</p> +</canvas> +<script id='myWorker' type='text/worker'> + self.onmessage = function(e) { + const canvas = new OffscreenCanvas(100, 100); + const ctx = canvas.getContext('2d'); + + ctx.fillStyle = 'teal'; + ctx.filter = new CanvasFilter({ + name: 'gaussianBlur', + stdDeviation: [4, 4], + }); + ctx.fillRect(25, 25, 50, 50); + + const bitmap = canvas.transferToImageBitmap(); + self.postMessage(bitmap, bitmap); + }; +</script> +<script> + const blob = new Blob([document.getElementById('myWorker').textContent]); + const worker = new Worker(URL.createObjectURL(blob)); + worker.addEventListener('message', msg => { + const outputCtx = document.getElementById("canvas").getContext('2d'); + outputCtx.drawImage(msg.data, 0, 0); + document.documentElement.classList.remove("reftest-wait"); + }); + worker.postMessage(null); +</script> +</html> diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.mostly-x-expected.html b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.mostly-x-expected.html new file mode 100644 index 0000000000..e76613271f --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.mostly-x-expected.html @@ -0,0 +1,15 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: 2d.filter.canvasFilterObject.gaussianBlur.tentative.mostly-x</title> +<h1>2d.filter.canvasFilterObject.gaussianBlur.tentative.mostly-x</h1> +<p class="desc">Test CanvasFilter() with gaussianBlur.</p> + +<svg xmlns="http://www.w3.org/2000/svg" + width="100" height="100" + color-interpolation-filters="sRGB"> + <filter id="blur" x="-50%" y="-50%" width="200%" height="200%"> + <feGaussianBlur stdDeviation="4 1" /> + </filter> + <rect x="25" y="25" width="50" height="50" + fill="teal" filter="url(#blur)" /> +</svg> diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.mostly-x.html b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.mostly-x.html new file mode 100644 index 0000000000..2ea26359fe --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.mostly-x.html @@ -0,0 +1,23 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<link rel="match" href="2d.filter.canvasFilterObject.gaussianBlur.tentative.mostly-x-expected.html"> +<title>Canvas test: 2d.filter.canvasFilterObject.gaussianBlur.tentative.mostly-x</title> +<h1>2d.filter.canvasFilterObject.gaussianBlur.tentative.mostly-x</h1> +<p class="desc">Test CanvasFilter() with gaussianBlur.</p> +<canvas id="canvas" width="100" height="100"> + <p class="fallback">FAIL (fallback content)</p> +</canvas> +<script> + const canvas = new OffscreenCanvas(100, 100); + const ctx = canvas.getContext('2d'); + + ctx.fillStyle = 'teal'; + ctx.filter = new CanvasFilter({ + name: 'gaussianBlur', + stdDeviation: [4, 1], + }); + ctx.fillRect(25, 25, 50, 50); + + const outputCanvas = document.getElementById("canvas"); + outputCanvas.getContext('2d').drawImage(canvas, 0, 0); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.mostly-x.w.html b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.mostly-x.w.html new file mode 100644 index 0000000000..fa49ea4682 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.mostly-x.w.html @@ -0,0 +1,37 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<html class="reftest-wait"> +<link rel="match" href="2d.filter.canvasFilterObject.gaussianBlur.tentative.mostly-x-expected.html"> +<title>Canvas test: 2d.filter.canvasFilterObject.gaussianBlur.tentative.mostly-x</title> +<h1>2d.filter.canvasFilterObject.gaussianBlur.tentative.mostly-x</h1> +<p class="desc">Test CanvasFilter() with gaussianBlur.</p> +<canvas id="canvas" width="100" height="100"> + <p class="fallback">FAIL (fallback content)</p> +</canvas> +<script id='myWorker' type='text/worker'> + self.onmessage = function(e) { + const canvas = new OffscreenCanvas(100, 100); + const ctx = canvas.getContext('2d'); + + ctx.fillStyle = 'teal'; + ctx.filter = new CanvasFilter({ + name: 'gaussianBlur', + stdDeviation: [4, 1], + }); + ctx.fillRect(25, 25, 50, 50); + + const bitmap = canvas.transferToImageBitmap(); + self.postMessage(bitmap, bitmap); + }; +</script> +<script> + const blob = new Blob([document.getElementById('myWorker').textContent]); + const worker = new Worker(URL.createObjectURL(blob)); + worker.addEventListener('message', msg => { + const outputCtx = document.getElementById("canvas").getContext('2d'); + outputCtx.drawImage(msg.data, 0, 0); + document.documentElement.classList.remove("reftest-wait"); + }); + worker.postMessage(null); +</script> +</html> diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.mostly-y-expected.html b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.mostly-y-expected.html new file mode 100644 index 0000000000..0f214fca9f --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.mostly-y-expected.html @@ -0,0 +1,15 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: 2d.filter.canvasFilterObject.gaussianBlur.tentative.mostly-y</title> +<h1>2d.filter.canvasFilterObject.gaussianBlur.tentative.mostly-y</h1> +<p class="desc">Test CanvasFilter() with gaussianBlur.</p> + +<svg xmlns="http://www.w3.org/2000/svg" + width="100" height="100" + color-interpolation-filters="sRGB"> + <filter id="blur" x="-50%" y="-50%" width="200%" height="200%"> + <feGaussianBlur stdDeviation="1 4" /> + </filter> + <rect x="25" y="25" width="50" height="50" + fill="teal" filter="url(#blur)" /> +</svg> diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.mostly-y.html b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.mostly-y.html new file mode 100644 index 0000000000..a9783ccb6a --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.mostly-y.html @@ -0,0 +1,23 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<link rel="match" href="2d.filter.canvasFilterObject.gaussianBlur.tentative.mostly-y-expected.html"> +<title>Canvas test: 2d.filter.canvasFilterObject.gaussianBlur.tentative.mostly-y</title> +<h1>2d.filter.canvasFilterObject.gaussianBlur.tentative.mostly-y</h1> +<p class="desc">Test CanvasFilter() with gaussianBlur.</p> +<canvas id="canvas" width="100" height="100"> + <p class="fallback">FAIL (fallback content)</p> +</canvas> +<script> + const canvas = new OffscreenCanvas(100, 100); + const ctx = canvas.getContext('2d'); + + ctx.fillStyle = 'teal'; + ctx.filter = new CanvasFilter({ + name: 'gaussianBlur', + stdDeviation: [1, 4], + }); + ctx.fillRect(25, 25, 50, 50); + + const outputCanvas = document.getElementById("canvas"); + outputCanvas.getContext('2d').drawImage(canvas, 0, 0); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.mostly-y.w.html b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.mostly-y.w.html new file mode 100644 index 0000000000..ab83f50ea0 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.mostly-y.w.html @@ -0,0 +1,37 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<html class="reftest-wait"> +<link rel="match" href="2d.filter.canvasFilterObject.gaussianBlur.tentative.mostly-y-expected.html"> +<title>Canvas test: 2d.filter.canvasFilterObject.gaussianBlur.tentative.mostly-y</title> +<h1>2d.filter.canvasFilterObject.gaussianBlur.tentative.mostly-y</h1> +<p class="desc">Test CanvasFilter() with gaussianBlur.</p> +<canvas id="canvas" width="100" height="100"> + <p class="fallback">FAIL (fallback content)</p> +</canvas> +<script id='myWorker' type='text/worker'> + self.onmessage = function(e) { + const canvas = new OffscreenCanvas(100, 100); + const ctx = canvas.getContext('2d'); + + ctx.fillStyle = 'teal'; + ctx.filter = new CanvasFilter({ + name: 'gaussianBlur', + stdDeviation: [1, 4], + }); + ctx.fillRect(25, 25, 50, 50); + + const bitmap = canvas.transferToImageBitmap(); + self.postMessage(bitmap, bitmap); + }; +</script> +<script> + const blob = new Blob([document.getElementById('myWorker').textContent]); + const worker = new Worker(URL.createObjectURL(blob)); + worker.addEventListener('message', msg => { + const outputCtx = document.getElementById("canvas").getContext('2d'); + outputCtx.drawImage(msg.data, 0, 0); + document.documentElement.classList.remove("reftest-wait"); + }); + worker.postMessage(null); +</script> +</html> diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.x-only-expected.html b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.x-only-expected.html new file mode 100644 index 0000000000..285a641726 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.x-only-expected.html @@ -0,0 +1,15 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: 2d.filter.canvasFilterObject.gaussianBlur.tentative.x-only</title> +<h1>2d.filter.canvasFilterObject.gaussianBlur.tentative.x-only</h1> +<p class="desc">Test CanvasFilter() with gaussianBlur.</p> + +<svg xmlns="http://www.w3.org/2000/svg" + width="100" height="100" + color-interpolation-filters="sRGB"> + <filter id="blur" x="-50%" y="-50%" width="200%" height="200%"> + <feGaussianBlur stdDeviation="4 0" /> + </filter> + <rect x="25" y="25" width="50" height="50" + fill="teal" filter="url(#blur)" /> +</svg> diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.x-only.html b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.x-only.html new file mode 100644 index 0000000000..3028c2a700 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.x-only.html @@ -0,0 +1,23 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<link rel="match" href="2d.filter.canvasFilterObject.gaussianBlur.tentative.x-only-expected.html"> +<title>Canvas test: 2d.filter.canvasFilterObject.gaussianBlur.tentative.x-only</title> +<h1>2d.filter.canvasFilterObject.gaussianBlur.tentative.x-only</h1> +<p class="desc">Test CanvasFilter() with gaussianBlur.</p> +<canvas id="canvas" width="100" height="100"> + <p class="fallback">FAIL (fallback content)</p> +</canvas> +<script> + const canvas = new OffscreenCanvas(100, 100); + const ctx = canvas.getContext('2d'); + + ctx.fillStyle = 'teal'; + ctx.filter = new CanvasFilter({ + name: 'gaussianBlur', + stdDeviation: [4, 0], + }); + ctx.fillRect(25, 25, 50, 50); + + const outputCanvas = document.getElementById("canvas"); + outputCanvas.getContext('2d').drawImage(canvas, 0, 0); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.x-only.w.html b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.x-only.w.html new file mode 100644 index 0000000000..e8482cf3ed --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.x-only.w.html @@ -0,0 +1,37 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<html class="reftest-wait"> +<link rel="match" href="2d.filter.canvasFilterObject.gaussianBlur.tentative.x-only-expected.html"> +<title>Canvas test: 2d.filter.canvasFilterObject.gaussianBlur.tentative.x-only</title> +<h1>2d.filter.canvasFilterObject.gaussianBlur.tentative.x-only</h1> +<p class="desc">Test CanvasFilter() with gaussianBlur.</p> +<canvas id="canvas" width="100" height="100"> + <p class="fallback">FAIL (fallback content)</p> +</canvas> +<script id='myWorker' type='text/worker'> + self.onmessage = function(e) { + const canvas = new OffscreenCanvas(100, 100); + const ctx = canvas.getContext('2d'); + + ctx.fillStyle = 'teal'; + ctx.filter = new CanvasFilter({ + name: 'gaussianBlur', + stdDeviation: [4, 0], + }); + ctx.fillRect(25, 25, 50, 50); + + const bitmap = canvas.transferToImageBitmap(); + self.postMessage(bitmap, bitmap); + }; +</script> +<script> + const blob = new Blob([document.getElementById('myWorker').textContent]); + const worker = new Worker(URL.createObjectURL(blob)); + worker.addEventListener('message', msg => { + const outputCtx = document.getElementById("canvas").getContext('2d'); + outputCtx.drawImage(msg.data, 0, 0); + document.documentElement.classList.remove("reftest-wait"); + }); + worker.postMessage(null); +</script> +</html> diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.y-only-expected.html b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.y-only-expected.html new file mode 100644 index 0000000000..d59945b5da --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.y-only-expected.html @@ -0,0 +1,15 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>Canvas test: 2d.filter.canvasFilterObject.gaussianBlur.tentative.y-only</title> +<h1>2d.filter.canvasFilterObject.gaussianBlur.tentative.y-only</h1> +<p class="desc">Test CanvasFilter() with gaussianBlur.</p> + +<svg xmlns="http://www.w3.org/2000/svg" + width="100" height="100" + color-interpolation-filters="sRGB"> + <filter id="blur" x="-50%" y="-50%" width="200%" height="200%"> + <feGaussianBlur stdDeviation="0 4" /> + </filter> + <rect x="25" y="25" width="50" height="50" + fill="teal" filter="url(#blur)" /> +</svg> diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.y-only.html b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.y-only.html new file mode 100644 index 0000000000..fca324716b --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.y-only.html @@ -0,0 +1,23 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<link rel="match" href="2d.filter.canvasFilterObject.gaussianBlur.tentative.y-only-expected.html"> +<title>Canvas test: 2d.filter.canvasFilterObject.gaussianBlur.tentative.y-only</title> +<h1>2d.filter.canvasFilterObject.gaussianBlur.tentative.y-only</h1> +<p class="desc">Test CanvasFilter() with gaussianBlur.</p> +<canvas id="canvas" width="100" height="100"> + <p class="fallback">FAIL (fallback content)</p> +</canvas> +<script> + const canvas = new OffscreenCanvas(100, 100); + const ctx = canvas.getContext('2d'); + + ctx.fillStyle = 'teal'; + ctx.filter = new CanvasFilter({ + name: 'gaussianBlur', + stdDeviation: [0, 4], + }); + ctx.fillRect(25, 25, 50, 50); + + const outputCanvas = document.getElementById("canvas"); + outputCanvas.getContext('2d').drawImage(canvas, 0, 0); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.y-only.w.html b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.y-only.w.html new file mode 100644 index 0000000000..50cfb3083a --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.y-only.w.html @@ -0,0 +1,37 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<html class="reftest-wait"> +<link rel="match" href="2d.filter.canvasFilterObject.gaussianBlur.tentative.y-only-expected.html"> +<title>Canvas test: 2d.filter.canvasFilterObject.gaussianBlur.tentative.y-only</title> +<h1>2d.filter.canvasFilterObject.gaussianBlur.tentative.y-only</h1> +<p class="desc">Test CanvasFilter() with gaussianBlur.</p> +<canvas id="canvas" width="100" height="100"> + <p class="fallback">FAIL (fallback content)</p> +</canvas> +<script id='myWorker' type='text/worker'> + self.onmessage = function(e) { + const canvas = new OffscreenCanvas(100, 100); + const ctx = canvas.getContext('2d'); + + ctx.fillStyle = 'teal'; + ctx.filter = new CanvasFilter({ + name: 'gaussianBlur', + stdDeviation: [0, 4], + }); + ctx.fillRect(25, 25, 50, 50); + + const bitmap = canvas.transferToImageBitmap(); + self.postMessage(bitmap, bitmap); + }; +</script> +<script> + const blob = new Blob([document.getElementById('myWorker').textContent]); + const worker = new Worker(URL.createObjectURL(blob)); + worker.addEventListener('message', msg => { + const outputCtx = document.getElementById("canvas").getContext('2d'); + outputCtx.drawImage(msg.data, 0, 0); + document.documentElement.classList.remove("reftest-wait"); + }); + worker.postMessage(null); +</script> +</html> diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.tentative.html b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.tentative.html new file mode 100644 index 0000000000..fb99ef7d1f --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.tentative.html @@ -0,0 +1,49 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.filter.canvasFilterObject.tentative</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.filter.canvasFilterObject.tentative</h1> +<p class="desc">Test CanvasFilter() object</p> + + +<script> +var t = async_test("Test CanvasFilter() object"); +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(ctx.filter == 'none', "ctx.filter == 'none'"); + ctx.filter = 'blur(5px)'; + _assert(ctx.filter == 'blur(5px)', "ctx.filter == 'blur(5px)'"); + ctx.filter = new CanvasFilter({name: 'gaussianBlur', stdDeviation: 5}); + _assert(ctx.filter.toString() == '[object CanvasFilter]', "ctx.filter.toString() == '[object CanvasFilter]'"); + ctx.filter = new CanvasFilter({name: 'gaussianBlur', stdDeviation: [1, 2]}); + _assert(ctx.filter.toString() == '[object CanvasFilter]', "ctx.filter.toString() == '[object CanvasFilter]'"); + ctx.filter = new CanvasFilter([ + {name: 'gaussianBlur', stdDeviation: 5}, + {name: 'gaussianBlur', stdDeviation: 10} + ]); + _assert(ctx.filter.toString() == '[object CanvasFilter]', "ctx.filter.toString() == '[object CanvasFilter]'"); + var canvas2 = new OffscreenCanvas(100, 50); + var ctx2 = canvas2.getContext('2d'); + ctx2.filter = ctx.filter; + _assert(ctx.filter.toString() == '[object CanvasFilter]', "ctx.filter.toString() == '[object CanvasFilter]'"); + ctx.filter = 'blur(5px)'; + _assert(ctx.filter == 'blur(5px)', "ctx.filter == 'blur(5px)'"); + ctx.filter = 'none'; + _assert(ctx.filter == 'none', "ctx.filter == 'none'"); + ctx.filter = new CanvasFilter({name: 'gaussianBlur', stdDeviation: 5}); + ctx.filter = 'this string is not a filter and should do nothing'; + _assert(ctx.filter.toString() == '[object CanvasFilter]', "ctx.filter.toString() == '[object CanvasFilter]'"); + t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.tentative.worker.js b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.tentative.worker.js new file mode 100644 index 0000000000..db95e0b006 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.tentative.worker.js @@ -0,0 +1,44 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.filter.canvasFilterObject.tentative +// Description:Test CanvasFilter() object +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("Test CanvasFilter() object"); +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(ctx.filter == 'none', "ctx.filter == 'none'"); + ctx.filter = 'blur(5px)'; + _assert(ctx.filter == 'blur(5px)', "ctx.filter == 'blur(5px)'"); + ctx.filter = new CanvasFilter({name: 'gaussianBlur', stdDeviation: 5}); + _assert(ctx.filter.toString() == '[object CanvasFilter]', "ctx.filter.toString() == '[object CanvasFilter]'"); + ctx.filter = new CanvasFilter({name: 'gaussianBlur', stdDeviation: [1, 2]}); + _assert(ctx.filter.toString() == '[object CanvasFilter]', "ctx.filter.toString() == '[object CanvasFilter]'"); + ctx.filter = new CanvasFilter([ + {name: 'gaussianBlur', stdDeviation: 5}, + {name: 'gaussianBlur', stdDeviation: 10} + ]); + _assert(ctx.filter.toString() == '[object CanvasFilter]', "ctx.filter.toString() == '[object CanvasFilter]'"); + var canvas2 = new OffscreenCanvas(100, 50); + var ctx2 = canvas2.getContext('2d'); + ctx2.filter = ctx.filter; + _assert(ctx.filter.toString() == '[object CanvasFilter]', "ctx.filter.toString() == '[object CanvasFilter]'"); + ctx.filter = 'blur(5px)'; + _assert(ctx.filter == 'blur(5px)', "ctx.filter == 'blur(5px)'"); + ctx.filter = 'none'; + _assert(ctx.filter == 'none', "ctx.filter == 'none'"); + ctx.filter = new CanvasFilter({name: 'gaussianBlur', stdDeviation: 5}); + ctx.filter = 'this string is not a filter and should do nothing'; + _assert(ctx.filter.toString() == '[object CanvasFilter]', "ctx.filter.toString() == '[object CanvasFilter]'"); + t.done(); +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.turbulence.inputTypes.tentative.html b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.turbulence.inputTypes.tentative.html new file mode 100644 index 0000000000..040c62a96b --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.turbulence.inputTypes.tentative.html @@ -0,0 +1,130 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.filter.canvasFilterObject.turbulence.inputTypes.tentative</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.filter.canvasFilterObject.turbulence.inputTypes.tentative</h1> +<p class="desc">Test exceptions on CanvasFilter() turbulence object</p> + + +<script> +var t = async_test("Test exceptions on CanvasFilter() turbulence object"); +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'); + + const errorTestCases = [ + {baseFrequency: {}}, + {baseFrequency: -1}, + {baseFrequency: [0, -1]}, + {baseFrequency: NaN}, + {baseFrequency: Infinity}, + {baseFrequency: undefined}, + {baseFrequency: -Infinity}, + {baseFrequency: 'test'}, + + {numOctaves: {}}, + {numOctaves: -1}, + {numOctaves: NaN}, + {numOctaves: Infinity}, + {numOctaves: undefined}, + {numOctaves: -Infinity}, + {numOctaves: [1, 1]}, + {numOctaves: 'test'}, + + {seed: {}}, + {seed: NaN}, + {seed: Infinity}, + {seed: undefined}, + {seed: -Infinity}, + {seed: [1, 1]}, + {seed: 'test'}, + + {stitchTiles: {}}, + {stitchTiles: NaN}, + {stitchTiles: Infinity}, + {stitchTiles: undefined}, + {stitchTiles: -Infinity}, + {stitchTiles: [1, 1]}, + {stitchTiles: 'test'}, + {stitchTiles: null}, + {stitchTiles: []}, + {stitchTiles: [10]}, + {stitchTiles: 30}, + {stitchTiles: false}, + {stitchTiles: true}, + {stitchTiles: '10'}, + {stitchTiles: -1}, + + {type: {}}, + {type: NaN}, + {type: Infinity}, + {type: undefined}, + {type: -Infinity}, + {type: [1, 1]}, + {type: 'test'}, + {type: null}, + {type: []}, + {type: [10]}, + {type: 30}, + {type: false}, + {type: true}, + {type: '10'}, + {type: -1}, + ] + + // null and [] = 0 when parsed as number + const workingTestCases = [ + {baseFrequency: null}, + {baseFrequency: []}, + {baseFrequency: [10]}, + {baseFrequency: [10, 3]}, + {baseFrequency: 30}, + {baseFrequency: false}, + {baseFrequency: true}, + {baseFrequency: '10'}, + + {numOctaves: null}, + {numOctaves: []}, + {numOctaves: [10]}, + {numOctaves: 30}, + {numOctaves: false}, + {numOctaves: true}, + {numOctaves: '10'}, + + {seed: null}, + {seed: []}, + {seed: [10]}, + {seed: 30}, + {seed: false}, + {seed: true}, + {seed: '10'}, + {seed: -1}, + + {stitchTiles: 'stitch'}, + {stitchTiles: 'noStitch'}, + + {type: 'fractalNoise'}, + {type: 'turbulence'}, + ] + + for (testCase of errorTestCases) { + const filterOptions = {...{name: 'turbulence'}, ...testCase}; + assert_throws_js(TypeError, function() { new CanvasFilter(filterOptions); }); + } + + for (testCase of workingTestCases) { + const filterOptions = {...{name: 'turbulence'}, ...testCase}; + _assert(new CanvasFilter(filterOptions) != null, "new CanvasFilter(filterOptions) != null"); + } + t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.turbulence.inputTypes.tentative.worker.js b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.turbulence.inputTypes.tentative.worker.js new file mode 100644 index 0000000000..1a950a9207 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.turbulence.inputTypes.tentative.worker.js @@ -0,0 +1,125 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.filter.canvasFilterObject.turbulence.inputTypes.tentative +// Description:Test exceptions on CanvasFilter() turbulence object +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("Test exceptions on CanvasFilter() turbulence object"); +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'); + + const errorTestCases = [ + {baseFrequency: {}}, + {baseFrequency: -1}, + {baseFrequency: [0, -1]}, + {baseFrequency: NaN}, + {baseFrequency: Infinity}, + {baseFrequency: undefined}, + {baseFrequency: -Infinity}, + {baseFrequency: 'test'}, + + {numOctaves: {}}, + {numOctaves: -1}, + {numOctaves: NaN}, + {numOctaves: Infinity}, + {numOctaves: undefined}, + {numOctaves: -Infinity}, + {numOctaves: [1, 1]}, + {numOctaves: 'test'}, + + {seed: {}}, + {seed: NaN}, + {seed: Infinity}, + {seed: undefined}, + {seed: -Infinity}, + {seed: [1, 1]}, + {seed: 'test'}, + + {stitchTiles: {}}, + {stitchTiles: NaN}, + {stitchTiles: Infinity}, + {stitchTiles: undefined}, + {stitchTiles: -Infinity}, + {stitchTiles: [1, 1]}, + {stitchTiles: 'test'}, + {stitchTiles: null}, + {stitchTiles: []}, + {stitchTiles: [10]}, + {stitchTiles: 30}, + {stitchTiles: false}, + {stitchTiles: true}, + {stitchTiles: '10'}, + {stitchTiles: -1}, + + {type: {}}, + {type: NaN}, + {type: Infinity}, + {type: undefined}, + {type: -Infinity}, + {type: [1, 1]}, + {type: 'test'}, + {type: null}, + {type: []}, + {type: [10]}, + {type: 30}, + {type: false}, + {type: true}, + {type: '10'}, + {type: -1}, + ] + + // null and [] = 0 when parsed as number + const workingTestCases = [ + {baseFrequency: null}, + {baseFrequency: []}, + {baseFrequency: [10]}, + {baseFrequency: [10, 3]}, + {baseFrequency: 30}, + {baseFrequency: false}, + {baseFrequency: true}, + {baseFrequency: '10'}, + + {numOctaves: null}, + {numOctaves: []}, + {numOctaves: [10]}, + {numOctaves: 30}, + {numOctaves: false}, + {numOctaves: true}, + {numOctaves: '10'}, + + {seed: null}, + {seed: []}, + {seed: [10]}, + {seed: 30}, + {seed: false}, + {seed: true}, + {seed: '10'}, + {seed: -1}, + + {stitchTiles: 'stitch'}, + {stitchTiles: 'noStitch'}, + + {type: 'fractalNoise'}, + {type: 'turbulence'}, + ] + + for (testCase of errorTestCases) { + const filterOptions = {...{name: 'turbulence'}, ...testCase}; + assert_throws_js(TypeError, function() { new CanvasFilter(filterOptions); }); + } + + for (testCase of workingTestCases) { + const filterOptions = {...{name: 'turbulence'}, ...testCase}; + _assert(new CanvasFilter(filterOptions) != null, "new CanvasFilter(filterOptions) != null"); + } + t.done(); +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.value.html b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.value.html new file mode 100644 index 0000000000..5594174cf6 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.value.html @@ -0,0 +1,56 @@ +<!DOCTYPE html> +<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> +<title>OffscreenCanvas test: 2d.filter.value</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> + +<h1>2d.filter.value</h1> +<p class="desc">test if ctx.filter works correctly</p> + + +<script> +var t = async_test("test if ctx.filter works correctly"); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + + var canvas = new OffscreenCanvas(100, 50); + var ctx = canvas.getContext('2d'); + + _assert(ctx.filter == 'none', "ctx.filter == 'none'"); + ctx.filter = 'blur(5px)'; + _assert(ctx.filter == 'blur(5px)', "ctx.filter == 'blur(5px)'"); + ctx.save(); + ctx.filter = 'none'; + _assert(ctx.filter == 'none', "ctx.filter == 'none'"); + ctx.restore(); + _assert(ctx.filter == 'blur(5px)', "ctx.filter == 'blur(5px)'"); + + ctx.filter = 'blur(10)'; + _assert(ctx.filter == 'blur(5px)', "ctx.filter == 'blur(5px)'"); + ctx.filter = 'blur 10px'; + _assert(ctx.filter == 'blur(5px)', "ctx.filter == 'blur(5px)'"); + + ctx.filter = 'inherit'; + _assert(ctx.filter == 'blur(5px)', "ctx.filter == 'blur(5px)'"); + ctx.filter = 'initial'; + _assert(ctx.filter == 'blur(5px)', "ctx.filter == 'blur(5px)'"); + ctx.filter = 'unset'; + _assert(ctx.filter == 'blur(5px)', "ctx.filter == 'blur(5px)'"); + + ctx.filter = ''; + _assert(ctx.filter == 'blur(5px)', "ctx.filter == 'blur(5px)'"); + ctx.filter = null; + _assert(ctx.filter == 'blur(5px)', "ctx.filter == 'blur(5px)'"); + ctx.filter = undefined; + _assert(ctx.filter == 'blur(5px)', "ctx.filter == 'blur(5px)'"); + + ctx.filter = 'blur( 5px)'; + assert_equals(ctx.filter, 'blur( 5px)'); + t.done(); + +}); +</script> diff --git a/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.value.worker.js b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.value.worker.js new file mode 100644 index 0000000000..2308315b63 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.value.worker.js @@ -0,0 +1,51 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.filter.value +// Description:test if ctx.filter works correctly +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("test if ctx.filter works correctly"); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + + var canvas = new OffscreenCanvas(100, 50); + var ctx = canvas.getContext('2d'); + + _assert(ctx.filter == 'none', "ctx.filter == 'none'"); + ctx.filter = 'blur(5px)'; + _assert(ctx.filter == 'blur(5px)', "ctx.filter == 'blur(5px)'"); + ctx.save(); + ctx.filter = 'none'; + _assert(ctx.filter == 'none', "ctx.filter == 'none'"); + ctx.restore(); + _assert(ctx.filter == 'blur(5px)', "ctx.filter == 'blur(5px)'"); + + ctx.filter = 'blur(10)'; + _assert(ctx.filter == 'blur(5px)', "ctx.filter == 'blur(5px)'"); + ctx.filter = 'blur 10px'; + _assert(ctx.filter == 'blur(5px)', "ctx.filter == 'blur(5px)'"); + + ctx.filter = 'inherit'; + _assert(ctx.filter == 'blur(5px)', "ctx.filter == 'blur(5px)'"); + ctx.filter = 'initial'; + _assert(ctx.filter == 'blur(5px)', "ctx.filter == 'blur(5px)'"); + ctx.filter = 'unset'; + _assert(ctx.filter == 'blur(5px)', "ctx.filter == 'blur(5px)'"); + + ctx.filter = ''; + _assert(ctx.filter == 'blur(5px)', "ctx.filter == 'blur(5px)'"); + ctx.filter = null; + _assert(ctx.filter == 'blur(5px)', "ctx.filter == 'blur(5px)'"); + ctx.filter = undefined; + _assert(ctx.filter == 'blur(5px)', "ctx.filter == 'blur(5px)'"); + + ctx.filter = 'blur( 5px)'; + assert_equals(ctx.filter, 'blur( 5px)'); + t.done(); +}); +done(); |