1 <!DOCTYPE HTML PUBLIC
"-//IETF//DTD HTML//EN">
4 <script src=
"../../resources/js-test.js"></script>
7 window
.jsTestIsAsync
= true;
8 description("This test checks behavior of Canvas::drawImage with a broken source image.");
10 // Create an image with invalid data.
11 var invalidImage
= new Image();
12 invalidImage
.src
= 'resources/shadow-offset.js';
13 invalidImage
.onerror
= draw
;
15 var ctx
= document
.createElement("canvas").getContext('2d');
17 // null and undefined images should throw TypeError
18 shouldThrow("ctx.drawImage(null, 0, 0)");
19 shouldThrow("ctx.drawImage(null, 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)");
25 // broken images should not throw
26 shouldThrow("ctx.drawImage(invalidImage, 0, 0)");
27 shouldThrow("ctx.drawImage(invalidImage, 0, 0, 20, 20)");
28 shouldThrow("ctx.drawImage(invalidImage, 0, 0, 20, 20, 0, 0, 20, 20)");
29 shouldThrow("ctx.drawImage(invalidImage, 0, 0, 0, 20)");
30 shouldThrow("ctx.drawImage(invalidImage, 0, 0, 0, 20, 0, 0, 20, 20)");