Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / canvas / script-tests / canvas-overloads-drawImage.js
1 description("Test the behavior of CanvasRenderingContext2D.drawImage() when called with different numbers of arguments.");
2
3 var ctx = document.createElement('canvas').getContext('2d');
4
5 function ExpectedNotEnoughArgumentsMessage(num) {
6     return "\"TypeError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': 3 arguments required, but only " + num + " present.\"";
7 }
8
9 var TypeError = "TypeError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': No function was found that matched the signature provided.";
10
11 var imageElement = document.createElement("img");
12 shouldThrow("ctx.drawImage()", ExpectedNotEnoughArgumentsMessage(0));
13 shouldThrow("ctx.drawImage(imageElement)", ExpectedNotEnoughArgumentsMessage(1));
14 shouldThrow("ctx.drawImage(imageElement, 0)", ExpectedNotEnoughArgumentsMessage(2));
15 shouldBe("ctx.drawImage(imageElement, 0, 0)", "undefined");
16 shouldThrow("ctx.drawImage(imageElement, 0, 0, 0)", "TypeError");
17 shouldBe("ctx.drawImage(imageElement, 0, 0, 0, 0)", "undefined");
18 shouldThrow("ctx.drawImage(imageElement, 0, 0, 0, 0, 0)", "TypeError");
19 shouldThrow("ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0)", "TypeError");
20 shouldThrow("ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0, 0)", "TypeError");
21 shouldBe("ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0, 0, 0)", "undefined");
22 shouldThrow("ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0, 0, 0, 0)", "TypeError");
23 shouldThrow("ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)", "TypeError");
24
25 var canvasElement = document.createElement("canvas");
26 shouldThrow("ctx.drawImage(canvasElement)", ExpectedNotEnoughArgumentsMessage(1));
27 shouldThrow("ctx.drawImage(canvasElement, 0)", ExpectedNotEnoughArgumentsMessage(2));
28 shouldBe("ctx.drawImage(canvasElement, 0, 0)", "undefined");
29 shouldThrow("ctx.drawImage(canvasElement, 0, 0, 0)", "TypeError");
30 shouldBe("ctx.drawImage(canvasElement, 0, 0, 0, 0)", "undefined");
31 shouldThrow("ctx.drawImage(canvasElement, 0, 0, 0, 0, 0)", "TypeError");
32 shouldThrow("ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0)", "TypeError");
33 shouldThrow("ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0, 0)", "TypeError");
34 shouldBe("ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0, 0, 0)", "undefined");
35 shouldThrow("ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0, 0, 0, 0)", "TypeError");
36 shouldThrow("ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)", "TypeError");