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

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

Issue 289283002: Add some layout tests about behavior on undefined and null. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 6 years, 7 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
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 // Create an image with invalid data. 10 // Create an image with invalid data.
11 var invalidImage = new Image(); 11 var invalidImage = new Image();
12 invalidImage.src = 'resources/shadow-offset.js'; 12 invalidImage.src = 'resources/shadow-offset.js';
13 invalidImage.onerror = draw; 13 invalidImage.onerror = draw;
14 14
15 var ctx = document.createElement("canvas").getContext('2d'); 15 var ctx = document.createElement("canvas").getContext('2d');
16 function draw() { 16 function draw() {
17 // null images should throw TypeError 17 // null and undefined images should throw TypeError
18 shouldThrow("ctx.drawImage(null, 0, 0)"); 18 shouldThrow("ctx.drawImage(null, 0, 0)");
19 shouldThrow("ctx.drawImage(null, 0, 0, 20, 20)"); 19 shouldThrow("ctx.drawImage(null, 0, 0, 20, 20)");
20 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)");
21 shouldThrow("ctx.drawImage(undefined, 0, 0)");
22 shouldThrow("ctx.drawImage(undefined, 0, 0, 20, 20)");
23 shouldThrow("ctx.drawImage(undefined, 0, 0, 20, 20, 0, 0, 20, 20)");
21 24
22 // broken images should not throw 25 // broken images should not throw
23 shouldThrow("ctx.drawImage(invalidImage, 0, 0)"); 26 shouldThrow("ctx.drawImage(invalidImage, 0, 0)");
24 shouldThrow("ctx.drawImage(invalidImage, 0, 0, 20, 20)"); 27 shouldThrow("ctx.drawImage(invalidImage, 0, 0, 20, 20)");
25 shouldThrow("ctx.drawImage(invalidImage, 0, 0, 20, 20, 0, 0, 20, 20)"); 28 shouldThrow("ctx.drawImage(invalidImage, 0, 0, 20, 20, 0, 0, 20, 20)");
26 shouldThrow("ctx.drawImage(invalidImage, 0, 0, 0, 20)"); 29 shouldThrow("ctx.drawImage(invalidImage, 0, 0, 0, 20)");
27 shouldThrow("ctx.drawImage(invalidImage, 0, 0, 0, 20, 0, 0, 20, 20)"); 30 shouldThrow("ctx.drawImage(invalidImage, 0, 0, 0, 20, 0, 0, 20, 20)");
28 31
29 finishJSTest(); 32 finishJSTest();
30 } 33 }
31 </script> 34 </script>
32 </body> 35 </body>
33 </html> 36 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698