Chromium Code Reviews| Index: LayoutTests/fast/canvas/script-tests/canvas-ImageData.js |
| diff --git a/LayoutTests/fast/canvas/script-tests/canvas-ImageData.js b/LayoutTests/fast/canvas/script-tests/canvas-ImageData.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..501dd16d98f99143d8929863c3cafa66098b3076 |
| --- /dev/null |
| +++ b/LayoutTests/fast/canvas/script-tests/canvas-ImageData.js |
| @@ -0,0 +1,38 @@ |
| +description("Test ImageData constructor"); |
| + |
| +shouldBeDefined("ImageData"); |
| +shouldBe("ImageData.length", "2"); |
| + |
| +imageData = new ImageData(100, 50); |
| + |
| +shouldBeNonNull("imageData"); |
| +shouldBeNonNull("imageData.data"); |
| +shouldBe("imageData.data[11]", "0"); |
|
Justin Novosad
2014/03/24 14:21:09
Why 11? Should check at least one of each RGBA com
sof
2014/03/24 14:57:21
Good idea; switched to peeking&poking over RGBA va
|
| +for (i = 0; i < imageData.data.length; ++i) { |
| + imageData.data[i] = 231; |
|
Justin Novosad
2014/03/24 14:21:09
Why set everything to 231? You only check element
|
| +} |
| + |
| +shouldBe("imageData.width", "100"); |
| +shouldBe("imageData.height", "50"); |
| +shouldBe("imageData.data[32]", "231"); |
| + |
| +shouldThrow("new ImageData(10)"); |
| +shouldThrow("new ImageData(0, 10)"); |
| +shouldThrow("new ImageData(10, 0)"); |
| +shouldThrow("new ImageData('width', 'height')"); |
| +shouldThrow("new ImageData(1 << 31, 1 << 31)"); |
| + |
| +shouldThrow("new ImageData(new Uint8ClampedArray(0))"); |
| +shouldThrow("new ImageData(new Uint8Array(100), 25)"); |
| +shouldThrow("new ImageData(new Uint8ClampedArray(27), 2)"); |
| +shouldThrow("new ImageData(new Uint8ClampedArray(104), 14)"); |
| +shouldThrow("new ImageData(imageData.data, 0)"); |
| +shouldThrow("new ImageData(imageData.data, 13)"); |
| +shouldThrow("new ImageData(imageData.data, 1 << 31)"); |
| +shouldThrow("new ImageData(imageData.data, 'biggish')"); |
| +shouldThrow("new ImageData(imageData.data, 1 << 24, 1 << 31)"); |
| + |
| +imageDataFromData = new ImageData(imageData.data, 100); |
|
Justin Novosad
2014/03/24 14:00:11
Would be good to exercise a successful call to thi
sof
2014/03/24 14:57:21
Done.
|
| +shouldBe("imageDataFromData.width", "100"); |
| +shouldBe("imageDataFromData.height", "50"); |
| +shouldBe("imageDataFromData.data[34]", "imageData.data[34]"); |