From fee11623a87d803799f1ec469edcbbefa7d72383 Mon Sep 17 00:00:00 2001 From: Aaron Krajeski Date: Mon, 13 Dec 2021 12:28:30 -0800 Subject: [PATCH] Test outside of IDL conversions for CanvasFilter From the discussion here (https://github.com/whatwg/html/pull/6763) we need to explicitly test all possible types of inputs for filter attributes. Bug: 1201359 Change-Id: I5ef5905298a17310e4eb54c3c01ab8d6b7973737 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3320960 Reviewed-by: Yi Xu Reviewed-by: Domenic Denicola Commit-Queue: Aaron Krajeski Cr-Commit-Position: refs/heads/main@{#951163} --- ...er.canvasFilterObject.blur.exceptions.html | 5 +- ...as-filter-boolean-conversion-expected.html | 30 ++++++++++ .../canvas-filter-boolean-conversion.html | 58 +++++++++++++++++++ ...anvas-filter-long-conversion-expected.html | 26 +++++++++ .../canvas-filter-long-conversion.html | 35 +++++++++++ .../canvas-filter-sequence-conversion.html | 55 ++++++++++++++++++ ...er.canvasFilterObject.blur.exceptions.html | 5 +- ...nvasFilterObject.blur.exceptions.worker.js | 5 +- html/canvas/tools/yaml/element/filters.yaml | 5 +- html/canvas/tools/yaml/offscreen/filters.yaml | 5 +- 10 files changed, 224 insertions(+), 5 deletions(-) create mode 100644 html/canvas/element/manual/filters/idl-conversions/canvas-filter-boolean-conversion-expected.html create mode 100644 html/canvas/element/manual/filters/idl-conversions/canvas-filter-boolean-conversion.html create mode 100644 html/canvas/element/manual/filters/idl-conversions/canvas-filter-long-conversion-expected.html create mode 100644 html/canvas/element/manual/filters/idl-conversions/canvas-filter-long-conversion.html create mode 100644 html/canvas/element/manual/filters/idl-conversions/canvas-filter-sequence-conversion.html diff --git a/html/canvas/element/filters/2d.filter.canvasFilterObject.blur.exceptions.html b/html/canvas/element/filters/2d.filter.canvasFilterObject.blur.exceptions.html index 22dac93dcf8ff1..e0c939328b1dcd 100644 --- a/html/canvas/element/filters/2d.filter.canvasFilterObject.blur.exceptions.html +++ b/html/canvas/element/filters/2d.filter.canvasFilterObject.blur.exceptions.html @@ -20,8 +20,11 @@

2d.filter.canvasFilterObject.blur.exceptions

_addTest(function(canvas, ctx) { assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter({filter: "gaussianBlur"}); }); -assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter({filter: "gaussianBlur", stdDevation: null}); }); +assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter({filter: "gaussianBlur", stdDeviation: undefined}); }); assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter({filter: "gaussianBlur", stdDeviation: "foo"}); }); +assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter({filter: "gaussianBlur", stdDeviation: [1,2]}); }); +assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter({filter: "gaussianBlur", stdDeviation: NaN}); }); +assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter({filter: "gaussianBlur", stdDeviation: {}}); }); }); diff --git a/html/canvas/element/manual/filters/idl-conversions/canvas-filter-boolean-conversion-expected.html b/html/canvas/element/manual/filters/idl-conversions/canvas-filter-boolean-conversion-expected.html new file mode 100644 index 00000000000000..f79cdd1eeb75dd --- /dev/null +++ b/html/canvas/element/manual/filters/idl-conversions/canvas-filter-boolean-conversion-expected.html @@ -0,0 +1,30 @@ + + + + diff --git a/html/canvas/element/manual/filters/idl-conversions/canvas-filter-boolean-conversion.html b/html/canvas/element/manual/filters/idl-conversions/canvas-filter-boolean-conversion.html new file mode 100644 index 00000000000000..16c40e4162feeb --- /dev/null +++ b/html/canvas/element/manual/filters/idl-conversions/canvas-filter-boolean-conversion.html @@ -0,0 +1,58 @@ + + + + + + + diff --git a/html/canvas/element/manual/filters/idl-conversions/canvas-filter-long-conversion-expected.html b/html/canvas/element/manual/filters/idl-conversions/canvas-filter-long-conversion-expected.html new file mode 100644 index 00000000000000..8b4262ed0418d7 --- /dev/null +++ b/html/canvas/element/manual/filters/idl-conversions/canvas-filter-long-conversion-expected.html @@ -0,0 +1,26 @@ + + + + diff --git a/html/canvas/element/manual/filters/idl-conversions/canvas-filter-long-conversion.html b/html/canvas/element/manual/filters/idl-conversions/canvas-filter-long-conversion.html new file mode 100644 index 00000000000000..c742633224c13e --- /dev/null +++ b/html/canvas/element/manual/filters/idl-conversions/canvas-filter-long-conversion.html @@ -0,0 +1,35 @@ + + + + + + + diff --git a/html/canvas/element/manual/filters/idl-conversions/canvas-filter-sequence-conversion.html b/html/canvas/element/manual/filters/idl-conversions/canvas-filter-sequence-conversion.html new file mode 100644 index 00000000000000..7774f3aa4fa5d7 --- /dev/null +++ b/html/canvas/element/manual/filters/idl-conversions/canvas-filter-sequence-conversion.html @@ -0,0 +1,55 @@ + +Canvas test: canvas-filter-sequence-conversion + + + + + + +

canvas-filter-sequence-conversion

+

Test converting types into sequences

+ + +

Actual output:

+

FAIL (fallback content)

+ +
    + diff --git a/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.blur.exceptions.html b/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.blur.exceptions.html index c047903e6e07ec..d3a03dc1572611 100644 --- a/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.blur.exceptions.html +++ b/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.blur.exceptions.html @@ -21,8 +21,11 @@

    2d.filter.canvasFilterObject.blur.exceptions

    var ctx = offscreenCanvas.getContext('2d'); assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter({filter: "gaussianBlur"}); }); -assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter({filter: "gaussianBlur", stdDevation: null}); }); +assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter({filter: "gaussianBlur", stdDeviation: undefined}); }); assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter({filter: "gaussianBlur", stdDeviation: "foo"}); }); +assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter({filter: "gaussianBlur", stdDeviation: [1,2]}); }); +assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter({filter: "gaussianBlur", stdDeviation: NaN}); }); +assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter({filter: "gaussianBlur", stdDeviation: {}}); }); t.done(); }); diff --git a/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.blur.exceptions.worker.js b/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.blur.exceptions.worker.js index 1f44c002ac721d..29f743dd2f9e9e 100644 --- a/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.blur.exceptions.worker.js +++ b/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.blur.exceptions.worker.js @@ -17,8 +17,11 @@ var offscreenCanvas = new OffscreenCanvas(100, 50); var ctx = offscreenCanvas.getContext('2d'); assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter({filter: "gaussianBlur"}); }); -assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter({filter: "gaussianBlur", stdDevation: null}); }); +assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter({filter: "gaussianBlur", stdDeviation: undefined}); }); assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter({filter: "gaussianBlur", stdDeviation: "foo"}); }); +assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter({filter: "gaussianBlur", stdDeviation: [1,2]}); }); +assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter({filter: "gaussianBlur", stdDeviation: NaN}); }); +assert_throws_js(TypeError, function() { ctx.filter = new CanvasFilter({filter: "gaussianBlur", stdDeviation: {}}); }); t.done(); }); diff --git a/html/canvas/tools/yaml/element/filters.yaml b/html/canvas/tools/yaml/element/filters.yaml index 420af371f5fe14..57cbebcf91c27d 100644 --- a/html/canvas/tools/yaml/element/filters.yaml +++ b/html/canvas/tools/yaml/element/filters.yaml @@ -61,8 +61,11 @@ desc: Test exceptions on CanvasFilter() blur.object code: | @assert throws TypeError ctx.filter = new CanvasFilter({filter: "gaussianBlur"}); - @assert throws TypeError ctx.filter = new CanvasFilter({filter: "gaussianBlur", stdDevation: null}); + @assert throws TypeError ctx.filter = new CanvasFilter({filter: "gaussianBlur", stdDeviation: undefined}); @assert throws TypeError ctx.filter = new CanvasFilter({filter: "gaussianBlur", stdDeviation: "foo"}); + @assert throws TypeError ctx.filter = new CanvasFilter({filter: "gaussianBlur", stdDeviation: [1,2]}); + @assert throws TypeError ctx.filter = new CanvasFilter({filter: "gaussianBlur", stdDeviation: NaN}); + @assert throws TypeError ctx.filter = new CanvasFilter({filter: "gaussianBlur", stdDeviation: {}}); - name: 2d.filter.canvasFilterObject.colorMatrix desc: Test the functionality of ColorMatrix filters in CanvasFilter objects diff --git a/html/canvas/tools/yaml/offscreen/filters.yaml b/html/canvas/tools/yaml/offscreen/filters.yaml index e715c95258cd13..f9cf1cb3a4116f 100644 --- a/html/canvas/tools/yaml/offscreen/filters.yaml +++ b/html/canvas/tools/yaml/offscreen/filters.yaml @@ -28,8 +28,11 @@ desc: Test exceptions on CanvasFilter() blur.object code: | @assert throws TypeError ctx.filter = new CanvasFilter({filter: "gaussianBlur"}); - @assert throws TypeError ctx.filter = new CanvasFilter({filter: "gaussianBlur", stdDevation: null}); + @assert throws TypeError ctx.filter = new CanvasFilter({filter: "gaussianBlur", stdDeviation: undefined}); @assert throws TypeError ctx.filter = new CanvasFilter({filter: "gaussianBlur", stdDeviation: "foo"}); + @assert throws TypeError ctx.filter = new CanvasFilter({filter: "gaussianBlur", stdDeviation: [1,2]}); + @assert throws TypeError ctx.filter = new CanvasFilter({filter: "gaussianBlur", stdDeviation: NaN}); + @assert throws TypeError ctx.filter = new CanvasFilter({filter: "gaussianBlur", stdDeviation: {}}); t.done(); - name: 2d.filter.canvasFilterObject.colorMatrix