Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / canvas / script-tests / canvas-gradient-without-path.js
1 description("Series of tests to ensure that no gradient is drawn without path");
2 var ctx = document.createElement('canvas').getContext('2d');
3
4 ctx.fillStyle = 'green';
5 ctx.fillRect(0, 0, 100, 100);
6
7 var gradient = ctx.createLinearGradient(0, 0, 0, 100);
8 gradient.addColorStop(1, 'red');
9 ctx.fillStyle = gradient;
10
11 ctx.fill();
12
13 var imageData = ctx.getImageData(1, 1, 98, 98);
14 var imgdata = imageData.data;
15 shouldBe("imgdata[4]", "0");
16 shouldBe("imgdata[5]", "128");
17 shouldBe("imgdata[6]", "0");
18
19 ctx.strokeStyle = 'green';
20 ctx.lineWidth = 100;
21 ctx.strokeRect(50, 0, 100, 100);
22
23 ctx.strokeStyle = gradient;
24
25 ctx.stroke();
26
27 imageData = ctx.getImageData(1, 1, 98, 98);
28 imgdata = imageData.data;
29 shouldBe("imgdata[4]", "0");
30 shouldBe("imgdata[5]", "128");
31 shouldBe("imgdata[6]", "0");