Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Unified Diff: LayoutTests/fast/canvas/script-tests/canvas-ImageData.js

Issue 196343032: Implement ImageData constructors. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Generate code that custom wrap()s constructor instances Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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]");

Powered by Google App Engine
This is Rietveld 408576698