Commit f3c31fc7 authored by Juanmi Huertas's avatar Juanmi Huertas Committed by Commit Bot

Enforcing range in parameters of putImageData, getImageData and createImageData

These functions receive parameters of type long, and those were not being checked
in case they were receiving infinity or other not-long values.
Added EnforceRange in the idl to ensure those functions are receiving valid longs.
Removing the expected on the WPT tests to stop ignoring these failures.
Changing a fast test that was testing the original throw behavior.

Bug: 934841, 934839, 934837
Change-Id: Iaa95d3c5ed9ac545472ff72e9ef4b535d22cbedf
Reviewed-on: https://chromium-review.googlesource.com/c/1494798
Commit-Queue: Juanmi Huertas <juanmihd@chromium.org>
Reviewed-by: default avatarFernando Serboncini <fserb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#636626}
parent 5d646fe8
......@@ -125,10 +125,10 @@ interface CanvasRenderingContext2D {
// pixel manipulation
[RaisesException] ImageData createImageData(ImageData imagedata);
[RaisesException] ImageData createImageData(long sw, long sh);
[RaisesException] ImageData getImageData(long sx, long sy, long sw, long sh);
[RaisesException] void putImageData(ImageData imagedata, long dx, long dy);
[RaisesException] void putImageData(ImageData imagedata, long dx, long dy, long dirtyX, long dirtyY, long dirtyWidth, long dirtyHeight);
[RaisesException] ImageData createImageData([EnforceRange] long sw, [EnforceRange] long sh);
[RaisesException] ImageData getImageData([EnforceRange] long sx, [EnforceRange] long sy, [EnforceRange] long sw, [EnforceRange] long sh);
[RaisesException] void putImageData(ImageData imagedata, [EnforceRange] long dx, [EnforceRange] long dy);
[RaisesException] void putImageData(ImageData imagedata, [EnforceRange] long dx, [EnforceRange] long dy, [EnforceRange] long dirtyX, [EnforceRange] long dirtyY, [EnforceRange] long dirtyWidth, [EnforceRange] long dirtyHeight);
// https://github.com/WICG/canvas-color-space/blob/master/CanvasColorSpaceProposal.md
[RuntimeEnabled=CanvasColorManagement, RaisesException] ImageData createImageData(unsigned long sw, unsigned long sh, ImageDataColorSettings imageDataColorSettings);
......
This is a testharness.js-based test.
FAIL createImageData() throws TypeError if arguments are not finite assert_throws: function "function() { ctx.createImageData(Infinity, 10); }" threw object "IndexSizeError: Failed to execute 'createImageData' on 'CanvasRenderingContext2D': The source width is 0." ("IndexSizeError") expected object "TypeError" ("TypeError")
Harness: the test ran to completion.
This is a testharness.js-based test.
FAIL getImageData() throws TypeError if arguments are not finite assert_throws: function "function() { ctx.getImageData(Infinity, 10, 10, 10); }" did not throw
Harness: the test ran to completion.
This is a testharness.js-based test.
FAIL putImageData() throws TypeError if arguments are not finite assert_throws: function "function() { ctx.putImageData(imgdata, Infinity, 10); }" did not throw
Harness: the test ran to completion.
......@@ -6,25 +6,25 @@ test(function(t) {
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
assert_throws("INDEX_SIZE_ERR", function() {
assert_throws(new TypeError(), function() {
ctx.createImageData(Infinity, Infinity);
});
assert_throws("INDEX_SIZE_ERR", function() {
assert_throws(new TypeError(), function() {
ctx.createImageData(Infinity, 10);
});
assert_throws("INDEX_SIZE_ERR", function() {
assert_throws(new TypeError(), function() {
ctx.createImageData(-Infinity, 10);
});
assert_throws("INDEX_SIZE_ERR", function() {
assert_throws(new TypeError(), function() {
ctx.createImageData(10, Infinity);
});
assert_throws("INDEX_SIZE_ERR", function() {
assert_throws(new TypeError(), function() {
ctx.createImageData(10, -Infinity);
});
assert_throws("INDEX_SIZE_ERR", function() {
assert_throws(new TypeError(), function() {
ctx.createImageData(NaN, 10);
});
assert_throws("INDEX_SIZE_ERR", function() {
assert_throws(new TypeError(), function() {
ctx.createImageData(10, NaN);
});
}, 'Test the argument bounds of canvas createImageData.');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment