summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.colorMatrix.tentative.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.colorMatrix.tentative.html')
-rw-r--r--testing/web-platform/tests/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.colorMatrix.tentative.html69
1 files changed, 69 insertions, 0 deletions
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>