OLD | NEW |
1 description("Test the behavior of CanvasRenderingContext2D.drawImage() when call
ed with different numbers of arguments."); | 1 description("Test the behavior of CanvasRenderingContext2D.drawImage() when call
ed with different numbers of arguments."); |
2 | 2 |
3 var ctx = document.createElement('canvas').getContext('2d'); | 3 var ctx = document.createElement('canvas').getContext('2d'); |
4 | 4 |
5 function ExpectedNotEnoughArgumentsMessage(num) { | |
6 return "\"TypeError: Failed to execute 'drawImage' on 'CanvasRenderingContex
t2D': 3 arguments required, but only " + num + " present.\""; | |
7 } | |
8 | |
9 var TypeError = "TypeError: Failed to execute 'drawImage' on 'CanvasRenderingCon
text2D': No function was found that matched the signature provided."; | |
10 | |
11 var imageElement = document.createElement("img"); | 5 var imageElement = document.createElement("img"); |
12 shouldThrow("ctx.drawImage()", ExpectedNotEnoughArgumentsMessage(0)); | 6 shouldThrow("ctx.drawImage()"); |
13 shouldThrow("ctx.drawImage(imageElement)", ExpectedNotEnoughArgumentsMessage(1))
; | 7 shouldThrow("ctx.drawImage(imageElement)"); |
14 shouldThrow("ctx.drawImage(imageElement, 0)", ExpectedNotEnoughArgumentsMessage(
2)); | 8 shouldThrow("ctx.drawImage(imageElement, 0)"); |
15 shouldBe("ctx.drawImage(imageElement, 0, 0)", "undefined"); | 9 shouldBe("ctx.drawImage(imageElement, 0, 0)", "undefined"); |
16 shouldThrow("ctx.drawImage(imageElement, 0, 0, 0)", "TypeError"); | 10 shouldThrow("ctx.drawImage(imageElement, 0, 0, 0)"); |
17 shouldBe("ctx.drawImage(imageElement, 0, 0, 0, 0)", "undefined"); | 11 shouldBe("ctx.drawImage(imageElement, 0, 0, 0, 0)", "undefined"); |
18 shouldThrow("ctx.drawImage(imageElement, 0, 0, 0, 0, 0)", "TypeError"); | 12 shouldThrow("ctx.drawImage(imageElement, 0, 0, 0, 0, 0)"); |
19 shouldThrow("ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0)", "TypeError"); | 13 shouldThrow("ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0)"); |
20 shouldThrow("ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0, 0)", "TypeError"); | 14 shouldThrow("ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0, 0)"); |
21 shouldBe("ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0, 0, 0)", "undefined"); | 15 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
"); | 16 shouldThrow("ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0, 0, 0, 0)"); |
23 shouldThrow("ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)", "TypeEr
ror"); | 17 shouldThrow("ctx.drawImage(imageElement, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)"); |
24 | 18 |
25 var canvasElement = document.createElement("canvas"); | 19 var canvasElement = document.createElement("canvas"); |
26 shouldThrow("ctx.drawImage(canvasElement)", ExpectedNotEnoughArgumentsMessage(1)
); | 20 shouldThrow("ctx.drawImage(canvasElement)"); |
27 shouldThrow("ctx.drawImage(canvasElement, 0)", ExpectedNotEnoughArgumentsMessage
(2)); | 21 shouldThrow("ctx.drawImage(canvasElement, 0)"); |
28 shouldBe("ctx.drawImage(canvasElement, 0, 0)", "undefined"); | 22 shouldBe("ctx.drawImage(canvasElement, 0, 0)", "undefined"); |
29 shouldThrow("ctx.drawImage(canvasElement, 0, 0, 0)", "TypeError"); | 23 shouldThrow("ctx.drawImage(canvasElement, 0, 0, 0)"); |
30 shouldBe("ctx.drawImage(canvasElement, 0, 0, 0, 0)", "undefined"); | 24 shouldBe("ctx.drawImage(canvasElement, 0, 0, 0, 0)", "undefined"); |
31 shouldThrow("ctx.drawImage(canvasElement, 0, 0, 0, 0, 0)", "TypeError"); | 25 shouldThrow("ctx.drawImage(canvasElement, 0, 0, 0, 0, 0)"); |
32 shouldThrow("ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0)", "TypeError"); | 26 shouldThrow("ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0)"); |
33 shouldThrow("ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0, 0)", "TypeError"); | 27 shouldThrow("ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0, 0)"); |
34 shouldBe("ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0, 0, 0)", "undefined"); | 28 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)", "TypeErro
r"); | 29 shouldThrow("ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0, 0, 0, 0)"); |
36 shouldThrow("ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)", "TypeE
rror"); | 30 shouldThrow("ctx.drawImage(canvasElement, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)"); |
OLD | NEW |