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"); |
+for (i = 0; i < imageData.data.length; ++i) { |
+ imageData.data[i] = 231; |
+} |
+ |
+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); |
+shouldBe("imageDataFromData.width", "100"); |
+shouldBe("imageDataFromData.height", "50"); |
+shouldBe("imageDataFromData.data[34]", "imageData.data[34]"); |