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

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/OffScreenCanvas-invalid-args.html

Issue 1488763002: Start an empty interface OffScreenCanvas (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: better -1 handling and more invalid args test cases Created 5 years 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: 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..1a788dc171e2093ed0a94bcee1fa26080384507f
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/canvas/OffScreenCanvas-invalid-args.html
@@ -0,0 +1,68 @@
+<!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");
+
+var didThrow = false;
+try {
+ var canvas2 = new OffScreenCanvas(-1, -1);
+} catch(e) {
+ didThrow = true;
+ testPassed("OffScreenCanvas(-1, -1) throws an exception as expected: " + e);
+}
+if (!didThrow)
+ testFailed("OffScreenCanvas(-1, -1) should throw an exception but did not.");
+
+var canvas3 = new OffScreenCanvas(null, null);
+shouldBe("canvas3.width", "0");
+shouldBe("canvas3.height", "0");
+
+canvas3.width = setWidth;
+canvas3.height = setHeight;
+shouldBe("canvas3.width", "setWidth-1");
+shouldBe("canvas3.height", "setHeight-1");
+
+try {
+ canvas3.width = -1;
Justin Novosad 2015/12/04 04:37:41 Use the helper function "shouldThrow" instead of a
+} catch(e) {
+ didThrow = true;
+ testPassed("Setting width to -1 throws an exception as expected: " + e);
+}
+if (!didThrow)
+ testFailed("Setting width to -1 should throw an exception but did not.");
+
+try {
+ canvas3.width = obj;
+} catch(e) {
+ didThrow = true;
+ testPassed("Setting width to an object throws an exception as expected: " + e);
+}
+if (!didThrow)
+ testFailed("Setting width to an object should throw an exception but did not.");
+
+try {
+ var canvas4 = new OffScreenCanvas(obj, obj);
+} catch(e) {
+ didThrow = true;
+ testPassed("OffScreenCanvas(object, object) throws an exception as expected: " + e);
+}
+if (!didThrow)
+ testFailed("OffScreenCanvas(object, object) should throw an exception but did not");
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698