blob: 6c0ccf998eb6991b5dd19bd6e93919da02541503 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<script>
description("Test the behavior of CanvasRenderingContext2D.drawImage() when called with different numbers of arguments.");
var ctx = document.createElement('canvas').getContext('2d');
var TypeError = "TypeError: Type error";
var TypeErrorNotEnoughArguments = "TypeError: Not enough arguments";
var imageElement = document.createElement("img");
shouldThrow("ctx.drawImage()", "TypeErrorNotEnoughArguments");
shouldThrow("ctx.drawImage(imageElement)", "TypeErrorNotEnoughArguments");
shouldThrow("ctx.drawImage(imageElement, 0)", "TypeErrorNotEnoughArguments");
shouldBe("ctx.drawImage(imageElement, 0, 0)", "undefined");
shouldThrow("ctx.drawImage(imageElement, 0, 0, 0)", "TypeError");
shouldBe("ctx.drawImage(imageElement, 0, 0, 0, 0)", "undefined");
shouldThrow("ctx.drawImage(imageElement, 0, 0, 0, 0, 0)", "TypeError");
shouldThrow("ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0)", "TypeError");
shouldThrow("ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0, 0)", "TypeError");
shouldBe("ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0, 0, 0)", "undefined");
shouldBe("ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0, 0, 0, 0)", "undefined");
shouldBe("ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)", "undefined");
var canvasElement = document.createElement("canvas");
shouldThrow("ctx.drawImage(canvasElement)", "TypeErrorNotEnoughArguments");
shouldThrow("ctx.drawImage(canvasElement, 0)", "TypeErrorNotEnoughArguments");
shouldBe("ctx.drawImage(canvasElement, 0, 0)", "undefined");
shouldThrow("ctx.drawImage(canvasElement, 0, 0, 0)", "TypeError");
shouldBe("ctx.drawImage(canvasElement, 0, 0, 0, 0)", "undefined");
shouldThrow("ctx.drawImage(canvasElement, 0, 0, 0, 0, 0)", "TypeError");
shouldThrow("ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0)", "TypeError");
shouldThrow("ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0, 0)", "TypeError");
shouldThrowErrorName("ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0, 0, 0)", "IndexSizeError");
shouldThrowErrorName("ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0, 0, 0, 0)", "IndexSizeError");
shouldThrowErrorName("ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)", "IndexSizeError");
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>