Skip to content

Commit

Permalink
Bug 1825099 [wpt PR 39255] - Reject kernelMatrix with 0 width in conv…
Browse files Browse the repository at this point in the history
…olveMatrix CanvasFilters., a=testonly

Automatic update from web-platform-tests
Reject kernelMatrix with 0 width in convolveMatrix CanvasFilters.

Only the height was checked (rejecting `[]` kernels) but kernels with
zero width like `[[], []]` were incorrectly accepted.

The current CanvasFilter specification is defined by reusing the
SVG specification for how the filters attributes work
(whatwg/html#6763). For the
"feConvolveMatrix" filter, the SVG specification says
(https://www.w3.org/TR/SVG11/filters.html#feConvolveMatrixElement):

"Attribute definitions:
- order = "<number-optional-number>"
  Indicates the number of cells in each dimension for ‘kernelMatrix’.
  The values provided must be <integer>s greater than zero. The first
  number, <orderX>, indicates the number of columns in the matrix.
  The second number, <orderY>, indicates the number of rows in the
  matrix. If <orderY> is not provided, it defaults to <orderX>."

Change-Id: I23baf05db73e679a52cd9d553d7c6308d91b56f9
Bug: 1428652
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4377066
Reviewed-by: Aaron Krajeski <aaronhk@chromium.org>
Commit-Queue: Jean-Philippe Gravel <jpgravel@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1124423}

--

wpt-commits: 8b9f4e275162d151dc2a0c847601542d75051cbf
wpt-pr: 39255
  • Loading branch information
graveljp authored and moz-wptsync-bot committed Apr 14, 2023
1 parent 8777cd2 commit 34476a9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,14 @@ <h1>2d.filter.canvasFilterObject.convolveMatrix.exceptions.tentative</h1>
assert_throws_js(TypeError, function() { new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [[1, 0], 0]}); });
assert_throws_js(TypeError, function() { new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [[1, 0], [0, Infinity]]}); });
assert_throws_js(TypeError, function() { new CanvasFilter({filter: "convolveMatrix", kernelMatrix: []}); });
assert_throws_js(TypeError, function() { new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [1]}); });
assert_throws_js(TypeError, function() { new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [1, 2, 3, 4]}); });
assert_throws_js(TypeError, function() { new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [[], []]}); });
assert_throws_js(TypeError, function() { new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [[1, 2], []]}); });
assert_throws_js(TypeError, function() { new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [[], [1, 2]]}); });
// This should not throw an error
ctx.filter = new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [[]]});
ctx.filter = new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [[1]]});


});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,14 @@ <h1>2d.filter.canvasFilterObject.convolveMatrix.exceptions.tentative</h1>
assert_throws_js(TypeError, function() { new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [[1, 0], 0]}); });
assert_throws_js(TypeError, function() { new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [[1, 0], [0, Infinity]]}); });
assert_throws_js(TypeError, function() { new CanvasFilter({filter: "convolveMatrix", kernelMatrix: []}); });
assert_throws_js(TypeError, function() { new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [1]}); });
assert_throws_js(TypeError, function() { new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [1, 2, 3, 4]}); });
assert_throws_js(TypeError, function() { new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [[], []]}); });
assert_throws_js(TypeError, function() { new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [[1, 2], []]}); });
assert_throws_js(TypeError, function() { new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [[], [1, 2]]}); });
// This should not throw an error
ctx.filter = new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [[]]});
ctx.filter = new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [[1]]});
})(canvas, ctx);
t.done();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@ assert_throws_js(TypeError, function() { new CanvasFilter({filter: "convolveMatr
assert_throws_js(TypeError, function() { new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [[1, 0], 0]}); });
assert_throws_js(TypeError, function() { new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [[1, 0], [0, Infinity]]}); });
assert_throws_js(TypeError, function() { new CanvasFilter({filter: "convolveMatrix", kernelMatrix: []}); });
assert_throws_js(TypeError, function() { new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [1]}); });
assert_throws_js(TypeError, function() { new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [1, 2, 3, 4]}); });
assert_throws_js(TypeError, function() { new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [[], []]}); });
assert_throws_js(TypeError, function() { new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [[1, 2], []]}); });
assert_throws_js(TypeError, function() { new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [[], [1, 2]]}); });
// This should not throw an error
ctx.filter = new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [[]]});
ctx.filter = new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [[1]]});
t.done();

});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,14 @@
@assert throws TypeError new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [[1, 0], 0]});
@assert throws TypeError new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [[1, 0], [0, Infinity]]});
@assert throws TypeError new CanvasFilter({filter: "convolveMatrix", kernelMatrix: []});
@assert throws TypeError new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [1]});
@assert throws TypeError new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [1, 2, 3, 4]});
@assert throws TypeError new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [[], []]});
@assert throws TypeError new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [[1, 2], []]});
@assert throws TypeError new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [[], [1, 2]]});
// This should not throw an error
ctx.filter = new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [[]]});
ctx.filter = new CanvasFilter({filter: "convolveMatrix", kernelMatrix: [[1]]});
- name: 2d.filter.canvasFilterObject.componentTransfer.linear.tentative
desc: Test pixels on CanvasFilter() componentTransfer with linear type
Expand Down

0 comments on commit 34476a9

Please sign in to comment.