Chromium Code Reviews| Index: LayoutTests/fast/canvas/script-tests/canvas-path-addpath.js |
| diff --git a/LayoutTests/fast/canvas/script-tests/canvas-path-addpath.js b/LayoutTests/fast/canvas/script-tests/canvas-path-addpath.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..54ce9d4f9a29154a2865a694cbbb11177664505b |
| --- /dev/null |
| +++ b/LayoutTests/fast/canvas/script-tests/canvas-path-addpath.js |
| @@ -0,0 +1,52 @@ |
| +description("Test addPath() method."); |
| +var ctx = document.createElement('canvas').getContext('2d'); |
| + |
| +debug("Test addPath() with transform as identity matrix.") |
| +ctx.beginPath(); |
| +var p1 = new Path(); |
| +p1.rect(0,0,100,100); |
| +var p2 = new Path(); |
| +p2.rect(0,100,100,100); |
| +var svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg"); |
| +var m = svgElement.createSVGMatrix(); |
|
Justin Novosad
2014/02/18 16:09:29
simpler way to create an SVGMatrix:
var m = ctx.c
pals
2014/02/19 11:47:22
Done.
|
| +p1.addPath(p2, m); |
| +ctx.fillStyle = 'yellow'; |
| +ctx.currentPath = p1; |
| +ctx.fill(); |
| +var imageData = ctx.getImageData(0, 100, 100, 100); |
| +var imgdata = imageData.data; |
| +shouldBe("imgdata[4]", "255"); |
| +shouldBe("imgdata[5]", "255"); |
| +shouldBe("imgdata[6]", "0"); |
| +shouldBe("imgdata[7]", "255"); |
| +debug(""); |
| + |
| +debug("Test addPath() with transform as translate(100, -100).") |
|
Justin Novosad
2014/02/18 16:09:29
Please add an additional test case where the trans
pals
2014/02/19 11:47:22
Done.
|
| +ctx.beginPath(); |
| +var p1 = new Path(); |
|
Justin Novosad
2014/02/18 16:09:29
re-declaration of existing variable.
pals
2014/02/19 11:47:22
Done.
|
| +p1.rect(0,0,100,100); |
| +var p2 = new Path(); |
| +p2.rect(0,100,100,100); |
| +var svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg"); |
|
Justin Novosad
2014/02/18 16:09:29
No need to re-create this
pals
2014/02/19 11:47:22
Done.
|
| +var m = svgElement.createSVGMatrix(); |
| +m.a = 1; m.b = 0; |
| +m.c = 0; m.d = 1; |
| +m.e = 100; m.f = -100; |
| +p1.addPath(p2, m); |
| +ctx.fillStyle = 'yellow'; |
| +ctx.currentPath = p1; |
| +ctx.fill(); |
| +var imageData = ctx.getImageData(100, 0, 100, 100); |
| +var imgdata = imageData.data; |
| +shouldBe("imgdata[4]", "255"); |
| +shouldBe("imgdata[5]", "255"); |
| +shouldBe("imgdata[6]", "0"); |
| +shouldBe("imgdata[7]", "255"); |
| +debug(""); |
| + |
| +debug("Test addPath() with transform as null.") |
| +var p1 = new Path(); |
| +p1.rect(0,0,100,100); |
| +var p2 = new Path(); |
| +shouldThrow("p1.addPath(p2, null)"); |
|
Justin Novosad
2014/02/18 16:09:29
According to the spec, the transform is a nullable
pals
2014/02/19 11:47:22
The addPath idl changes generates following code
|
| +debug(""); |