1 description("Series of tests to ensure correct behaviour of calling canvas methods with illegal arguments (Infintiy and NaN)");
6 ctx
= document
.createElement('canvas').getContext('2d');
9 ctx
.fillStyle
= 'green';
10 ctx
.fillRect(0, 0, 100, 100);
12 var imageData
= ctx
.getImageData(50, 50, 1, 1);
13 var imgdata
= imageData
.data
;
14 shouldBe("imgdata[0]", "0");
15 shouldBe("imgdata[1]", "128");
16 shouldBe("imgdata[2]", "0");
18 ctx
= document
.createElement('canvas').getContext('2d');
21 ctx
.fillStyle
= 'green';
22 ctx
.fillRect(0, 0, 100, 100);
24 var imageData
= ctx
.getImageData(50, 50, 1, 1);
25 var imgdata
= imageData
.data
;
26 shouldBe("imgdata[0]", "0");
27 shouldBe("imgdata[1]", "128");
28 shouldBe("imgdata[2]", "0");
30 ctx
= document
.createElement('canvas').getContext('2d');
32 ctx
.scale(Infinity
, 1);
33 ctx
.fillStyle
= 'green';
34 ctx
.fillRect(0, 0, 100, 100);
36 var imageData
= ctx
.getImageData(50, 50, 1, 1);
37 var imgdata
= imageData
.data
;
38 shouldBe("imgdata[0]", "0");
39 shouldBe("imgdata[1]", "128");
40 shouldBe("imgdata[2]", "0");
42 ctx
= document
.createElement('canvas').getContext('2d');
44 ctx
.scale(1, Infinity
);
45 ctx
.fillStyle
= 'green';
46 ctx
.fillRect(0, 0, 100, 100);
48 var imageData
= ctx
.getImageData(50, 50, 1, 1);
49 var imgdata
= imageData
.data
;
50 shouldBe("imgdata[0]", "0");
51 shouldBe("imgdata[1]", "128");
52 shouldBe("imgdata[2]", "0");
56 debug("Test translate.");
57 ctx
= document
.createElement('canvas').getContext('2d');
59 ctx
.translate(NaN
, 1);
60 ctx
.fillStyle
= 'green';
61 ctx
.fillRect(0, 0, 100, 100);
63 var imageData
= ctx
.getImageData(50, 50, 1, 1);
64 var imgdata
= imageData
.data
;
65 shouldBe("imgdata[0]", "0");
66 shouldBe("imgdata[1]", "128");
67 shouldBe("imgdata[2]", "0");
69 ctx
= document
.createElement('canvas').getContext('2d');
71 ctx
.translate(1, NaN
);
72 ctx
.fillStyle
= 'green';
73 ctx
.fillRect(0, 0, 100, 100);
75 var imageData
= ctx
.getImageData(50, 50, 1, 1);
76 var imgdata
= imageData
.data
;
77 shouldBe("imgdata[0]", "0");
78 shouldBe("imgdata[1]", "128");
79 shouldBe("imgdata[2]", "0");
81 ctx
= document
.createElement('canvas').getContext('2d');
83 ctx
.translate(Infinity
, 1);
84 ctx
.fillStyle
= 'green';
85 ctx
.fillRect(0, 0, 100, 100);
87 var imageData
= ctx
.getImageData(50, 50, 1, 1);
88 var imgdata
= imageData
.data
;
89 shouldBe("imgdata[0]", "0");
90 shouldBe("imgdata[1]", "128");
91 shouldBe("imgdata[2]", "0");
93 ctx
= document
.createElement('canvas').getContext('2d');
95 ctx
.translate(1, Infinity
);
96 ctx
.fillStyle
= 'green';
97 ctx
.fillRect(0, 0, 100, 100);
99 var imageData
= ctx
.getImageData(50, 50, 1, 1);
100 var imgdata
= imageData
.data
;
101 shouldBe("imgdata[0]", "0");
102 shouldBe("imgdata[1]", "128");
103 shouldBe("imgdata[2]", "0");
106 debug("Test rotate.");
107 ctx
= document
.createElement('canvas').getContext('2d');
110 ctx
.fillStyle
= 'green';
111 ctx
.fillRect(0, 0, 100, 100);
113 var imageData
= ctx
.getImageData(50, 50, 1, 1);
114 var imgdata
= imageData
.data
;
115 shouldBe("imgdata[0]", "0");
116 shouldBe("imgdata[1]", "128");
117 shouldBe("imgdata[2]", "0");
119 ctx
= document
.createElement('canvas').getContext('2d');
121 ctx
.rotate(Infinity
);
122 ctx
.fillStyle
= 'green';
123 ctx
.fillRect(0, 0, 100, 100);
125 var imageData
= ctx
.getImageData(50, 50, 1, 1);
126 var imgdata
= imageData
.data
;
127 shouldBe("imgdata[0]", "0");
128 shouldBe("imgdata[1]", "128");
129 shouldBe("imgdata[2]", "0");