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

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

Issue 181693006: Refactoring source image usage in CanvasRenderingContext2D (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: applied last corrections 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 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="../../resources/js-test.js"></script> 4 <script src="../../resources/js-test.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 Canvas::drawImage with a broken so urce image."); 8 description("This test checks behavior of Canvas::drawImage with a broken so urce image.");
9 9
10 var InvalidStateError = "InvalidStateError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The source width is 0.";
11 var TypeMismatchError = "TypeMismatchError: The type of an object was incomp atible with the expected type of the parameter associated to the object.";
12
13 // Create an image with invalid data. 10 // Create an image with invalid data.
14 var invalidImage = new Image(); 11 var invalidImage = new Image();
15 invalidImage.src = 'resources/repaint.js'; 12 invalidImage.src = 'resources/repaint.js';
16 invalidImage.onerror = draw; 13 invalidImage.onerror = draw;
17 14
18 var ctx = document.createElement("canvas").getContext('2d'); 15 var ctx = document.createElement("canvas").getContext('2d');
19 function draw() { 16 function draw() {
20 // null images should throw TypeError 17 // null images should throw TypeError
21 shouldThrow("ctx.drawImage(null, 0, 0)"); 18 shouldThrow("ctx.drawImage(null, 0, 0)");
22 shouldThrow("ctx.drawImage(null, 0, 0, 20, 20)"); 19 shouldThrow("ctx.drawImage(null, 0, 0, 20, 20)");
23 shouldThrow("ctx.drawImage(null, 0, 0, 20, 20, 0, 0, 20, 20)"); 20 shouldThrow("ctx.drawImage(null, 0, 0, 20, 20, 0, 0, 20, 20)");
24 21
25 // broken images should not throw 22 // broken images should not throw
26 shouldBe("ctx.drawImage(invalidImage, 0, 0)", "undefined"); 23 shouldThrow("ctx.drawImage(invalidImage, 0, 0)");
27 shouldBe("ctx.drawImage(invalidImage, 0, 0, 20, 20)", "undefined"); 24 shouldThrow("ctx.drawImage(invalidImage, 0, 0, 20, 20)");
28 shouldBe("ctx.drawImage(invalidImage, 0, 0, 20, 20, 0, 0, 20, 20)", "und efined"); 25 shouldThrow("ctx.drawImage(invalidImage, 0, 0, 20, 20, 0, 0, 20, 20)");
29 shouldBe("ctx.drawImage(invalidImage, 0, 0, 0, 20)", "undefined"); 26 shouldThrow("ctx.drawImage(invalidImage, 0, 0, 0, 20)");
30 shouldBe("ctx.drawImage(invalidImage, 0, 0, 0, 20, 0, 0, 20, 20)", "unde fined"); 27 shouldThrow("ctx.drawImage(invalidImage, 0, 0, 0, 20, 0, 0, 20, 20)");
31 28
32 finishJSTest(); 29 finishJSTest();
33 } 30 }
34 </script> 31 </script>
35 </body> 32 </body>
36 </html> 33 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698