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 var InvalidStateError = "InvalidStateError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The source width is 0.";
11 var TypeMismatchError = "TypeMismatchError: The type of an object was incompatible with the expected type of the parameter associated to the object.";
13 // Create an image with invalid data.
14 var invalidImage = new Image();
15 invalidImage.src = 'resources/repaint.js';
16 invalidImage.onerror = draw;
18 var ctx = document.createElement("canvas").getContext('2d');
20 // null images should throw TypeError
21 shouldThrow("ctx.drawImage(null, 0, 0)");
22 shouldThrow("ctx.drawImage(null, 0, 0, 20, 20)");
23 shouldThrow("ctx.drawImage(null, 0, 0, 20, 20, 0, 0, 20, 20)");
25 // broken images should not throw
26 shouldBe("ctx.drawImage(invalidImage, 0, 0)", "undefined");
27 shouldBe("ctx.drawImage(invalidImage, 0, 0, 20, 20)", "undefined");
28 shouldBe("ctx.drawImage(invalidImage, 0, 0, 20, 20, 0, 0, 20, 20)", "undefined");
29 shouldBe("ctx.drawImage(invalidImage, 0, 0, 0, 20)", "undefined");
30 shouldBe("ctx.drawImage(invalidImage, 0, 0, 0, 20, 0, 0, 20, 20)", "undefined");