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

Side by Side Diff: LayoutTests/fast/canvas/drawImage-with-valid-image.html

Issue 24203002: Improve generated "Not enough arguments." TypeError exceptions. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: FAIL. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../js/resources/js-test-pre.js"></script> 4 <script src="../js/resources/js-test-pre.js"></script>
5 </head> 5 </head>
6 <script> 6 <script>
7 window.jsTestIsAsync = true; 7 window.jsTestIsAsync = true;
8 description("This test checks behavior of valid arguments to Canvas::drawIma ge that use a valid source image."); 8 description("This test checks behavior of valid arguments to Canvas::drawIma ge that use a valid source image.");
9 9
10 var TypeError = "TypeError: Not enough arguments"; 10 function ExpectedNotEnoughArgumentsMessage(num) {
11 return "\"TypeError: Failed to execute 'drawImage' on 'CanvasRenderingCo ntext2D': 3 arguments required, but only " + num + " present.\"";
12 }
11 var IndexSizeError = "IndexSizeError: Index or size was negative, or greater than the allowed value."; 13 var IndexSizeError = "IndexSizeError: Index or size was negative, or greater than the allowed value.";
12 14
13 // Create image 15 // Create image
14 var myImage = new Image(); 16 var myImage = new Image();
15 var img_src = 'resources/apple.gif'; 17 var img_src = 'resources/apple.gif';
16 myImage.src = img_src; 18 myImage.src = img_src;
17 myImage.onload = draw; 19 myImage.onload = draw;
18 20
19 var bitmap; 21 var bitmap;
20 var ctx = document.createElement("canvas").getContext('2d'); 22 var ctx = document.createElement("canvas").getContext('2d');
21 function draw() { 23 function draw() {
22 // No arguments should get exception 24 // No arguments should get exception
23 shouldThrow("ctx.drawImage()", "TypeError"); 25 shouldThrow("ctx.drawImage()", ExpectedNotEnoughArgumentsMessage(0));
24 26
25 // image argument only should get exception 27 // image argument only should get exception
26 shouldThrow("ctx.drawImage(myImage)", "TypeError"); 28 shouldThrow("ctx.drawImage(myImage)", ExpectedNotEnoughArgumentsMessage( 1));
27 29
28 // image argument plus one number should get exception 30 // image argument plus one number should get exception
29 shouldThrow("ctx.drawImage(myImage, 0)", "TypeError"); 31 shouldThrow("ctx.drawImage(myImage, 0)", ExpectedNotEnoughArgumentsMessa ge(2));
30 32
31 // image argument plus 2 numbers 33 // image argument plus 2 numbers
32 shouldNotThrow("ctx.drawImage(myImage, 0, 0)"); 34 shouldNotThrow("ctx.drawImage(myImage, 0, 0)");
33 35
34 // image argument plus 4 numbers 36 // image argument plus 4 numbers
35 shouldNotThrow("ctx.drawImage(myImage, 0, 0, 20, 20)"); 37 shouldNotThrow("ctx.drawImage(myImage, 0, 0, 20, 20)");
36 38
37 // image argument plus 8 numbers 39 // image argument plus 8 numbers
38 shouldNotThrow("ctx.drawImage(myImage, 0, 0, 20, 20, 0, 0, 20, 20)"); 40 shouldNotThrow("ctx.drawImage(myImage, 0, 0, 20, 20, 0, 0, 20, 20)");
39 41
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 shouldNotThrow("ctx.drawImage(bitmap, 52, 74, -52, -64, 0, 0, 20, 20)"); 146 shouldNotThrow("ctx.drawImage(bitmap, 52, 74, -52, -64, 0, 0, 20, 20)");
145 147
146 // negative size of source, imageRect does not contain sourceRect on eve ry side 148 // negative size of source, imageRect does not contain sourceRect on eve ry side
147 shouldNotThrow("ctx.drawImage(bitmap, 62, 74, -72, -84, 0, 0, 20, 20)"); 149 shouldNotThrow("ctx.drawImage(bitmap, 62, 74, -72, -84, 0, 0, 20, 20)");
148 150
149 finishJSTest(); 151 finishJSTest();
150 } 152 }
151 </script> 153 </script>
152 <script src="../js/resources/js-test-post.js"></script> 154 <script src="../js/resources/js-test-post.js"></script>
153 </body> 155 </body>
154 </html> 156 </html>
marja 2013/09/18 10:24:08 What's this?
Mike West 2013/09/18 11:16:34 Idunno. Line ending change? Not something I intent
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698