1 description("Series of tests to ensure correct behaviour on negative source/destination of a HTMLCanvasElement");
2 var canvas2 = document.createElement('canvas');
5 var ctx2 = canvas2.getContext('2d');
6 ctx2.fillStyle = '#f00';
7 ctx2.fillRect(0, 0, 100, 50);
8 ctx2.fillStyle = '#0f0';
9 ctx2.fillRect(0, 50, 100, 50);
11 var canvas = document.getElementById('canvas').getContext('2d');
12 canvas.drawImage(canvas2, 100, 50, -50, 50, 0, 0, 50, 50);
13 canvas.drawImage(canvas2, 100, 100, -50, -50, 0, 100, 50, -50);
14 canvas.drawImage(canvas2, 0, 100, 100, -50, 100, 100, -50, -50);
15 canvas.drawImage(canvas2, 0, 50, 100, 50, 100, 0, -50, 50);
17 var imageData = canvas.getImageData(0, 0, 100, 100);
18 var imgdata = imageData.data;
19 shouldBe("imgdata[4]", "0");
20 shouldBe("imgdata[5]", "255");
21 shouldBe("imgdata[6]", "0");
23 // test width or height -1
24 canvas.fillStyle = '#000';
25 canvas.fillRect(0, 0, 1, 2);
26 canvas.drawImage(canvas2, 0, 0, 1, 1, 1, 1, -1, -1);
27 var imageData = canvas.getImageData(0, 0, 1, 2);
28 var imgdata = imageData.data;
29 shouldBe("imgdata[0]", "255");
30 shouldBe("imgdata[1]", "0");
31 shouldBe("imgdata[2]", "0");
32 shouldBe("imgdata[4]", "0");
33 shouldBe("imgdata[5]", "0");
34 shouldBe("imgdata[6]", "0");