Index: third_party/WebKit/LayoutTests/fast/canvas/OffScreenCanvas-invalid-args.html |
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/OffScreenCanvas-invalid-args.html b/third_party/WebKit/LayoutTests/fast/canvas/OffScreenCanvas-invalid-args.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9ce02a7c079e2148c37aab238afe08978d22e900 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/fast/canvas/OffScreenCanvas-invalid-args.html |
@@ -0,0 +1,40 @@ |
+<!DOCTYPE html> |
+<script src="../../resources/js-test.js"></script> |
+<script> |
+description("Tests that the OffScreenCanvas can handle invalid arguments"); |
+ |
+// Since blink uses signed int internally, this case tests how the constructor |
+// responds to the arguments that are larger than INT_MAX which would cause |
+// overflow. The current implementation is expected to clamp. |
+var setWidth = Math.pow(2, 31); |
+var setHeight = Math.pow(2, 31); |
+var obj = {Name: "John Doe", Age: 30}; |
+ |
+var canvas1 = new OffScreenCanvas(setWidth, setHeight); |
+shouldBe("canvas1.width", "setWidth-1"); |
+shouldBe("canvas1.height", "setHeight-1"); |
+ |
+canvas1.width = null; |
+canvas1.height = null; |
+shouldBe("canvas1.width", "0"); |
+shouldBe("canvas1.height", "0"); |
+ |
+shouldThrow("new OffScreenCanvas(-1, -1)"); |
+ |
+var canvas2 = new OffScreenCanvas(null, null); |
+shouldBe("canvas2.width", "0"); |
+shouldBe("canvas2.height", "0"); |
+ |
+canvas2.width = setWidth; |
+canvas2.height = setHeight; |
+shouldBe("canvas2.width", "setWidth-1"); |
+shouldBe("canvas2.height", "setHeight-1"); |
+ |
+shouldThrow("canvas2.width = -1"); |
+shouldThrow("canvas2.height = -1"); |
+ |
+shouldThrow("canvas2.width = obj"); |
+shouldThrow("canvas2.height = obj"); |
+ |
+shouldThrow("new OffScreenCanvas(obj, obj)"); |
+</script> |