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

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

Issue 24203002: Improve generated "Not enough arguments." TypeError exceptions. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: NeedsRebaseline Created 7 years, 3 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-overloads-drawImage.js
diff --git a/LayoutTests/fast/canvas/script-tests/canvas-overloads-drawImage.js b/LayoutTests/fast/canvas/script-tests/canvas-overloads-drawImage.js
index e57acae799d4ae1a4058b46c3c0dbc022c446b8b..3d9580da3f2f23ce2563c103c483520105aed992 100644
--- a/LayoutTests/fast/canvas/script-tests/canvas-overloads-drawImage.js
+++ b/LayoutTests/fast/canvas/script-tests/canvas-overloads-drawImage.js
@@ -2,13 +2,16 @@ description("Test the behavior of CanvasRenderingContext2D.drawImage() when call
var ctx = document.createElement('canvas').getContext('2d');
+function ExpectedNotEnoughArgumentsMessage(num) {
+ return "\"TypeError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': 3 arguments required, but only " + num + " present.\"";
+}
+
var TypeError = "TypeError: Type error";
-var TypeErrorNotEnoughArguments = "TypeError: Not enough arguments";
var imageElement = document.createElement("img");
-shouldThrow("ctx.drawImage()", "TypeErrorNotEnoughArguments");
-shouldThrow("ctx.drawImage(imageElement)", "TypeErrorNotEnoughArguments");
-shouldThrow("ctx.drawImage(imageElement, 0)", "TypeErrorNotEnoughArguments");
+shouldThrow("ctx.drawImage()", ExpectedNotEnoughArgumentsMessage(0));
+shouldThrow("ctx.drawImage(imageElement)", ExpectedNotEnoughArgumentsMessage(1));
+shouldThrow("ctx.drawImage(imageElement, 0)", ExpectedNotEnoughArgumentsMessage(2));
shouldBe("ctx.drawImage(imageElement, 0, 0)", "undefined");
shouldThrow("ctx.drawImage(imageElement, 0, 0, 0)", "TypeError");
shouldBe("ctx.drawImage(imageElement, 0, 0, 0, 0)", "undefined");
@@ -20,8 +23,8 @@ shouldThrow("ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0, 0, 0, 0)", "TypeError
shouldThrow("ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)", "TypeError");
var canvasElement = document.createElement("canvas");
-shouldThrow("ctx.drawImage(canvasElement)", "TypeErrorNotEnoughArguments");
-shouldThrow("ctx.drawImage(canvasElement, 0)", "TypeErrorNotEnoughArguments");
+shouldThrow("ctx.drawImage(canvasElement)", ExpectedNotEnoughArgumentsMessage(1));
+shouldThrow("ctx.drawImage(canvasElement, 0)", ExpectedNotEnoughArgumentsMessage(2));
shouldBe("ctx.drawImage(canvasElement, 0, 0)", "undefined");
shouldThrow("ctx.drawImage(canvasElement, 0, 0, 0)", "TypeError");
shouldBe("ctx.drawImage(canvasElement, 0, 0, 0, 0)", "undefined");

Powered by Google App Engine
This is Rietveld 408576698