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..0d57c3750a89905ad17f7fb8c152a3bf35abd337 |
--- /dev/null |
+++ b/LayoutTests/fast/canvas/script-tests/canvas-path-addpath.js |
@@ -0,0 +1,70 @@ |
+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 m = ctx.currentTransform; |
+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).") |
+ctx.beginPath(); |
+var p3 = new Path(); |
+p3.rect(0,0,100,100); |
+var p4 = new Path(); |
+p4.rect(0,100,100,100); |
+m.a = 1; m.b = 0; |
+m.c = 0; m.d = 1; |
+m.e = 100; m.f = -100; |
+p3.addPath(p4, m); |
+ctx.fillStyle = 'yellow'; |
+ctx.currentPath = p3; |
+ctx.fill(); |
+var imageData = ctx.getImageData(100, 0, 100, 100); |
Justin Novosad
2014/02/19 16:38:28
no need for 'var' here. Same thing for following l
pals
2014/03/03 06:27:39
Done.
|
+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 non-invertible transform.") |
+ctx.beginPath(); |
+var p5 = new Path(); |
+p5.rect(0,0,100,100); |
+var p6 = new Path(); |
+p6.rect(100,100,100,100); |
+m.a = 0; m.b = 0; |
+m.c = 0; m.d = 0; |
+m.e = 0; m.f = 0; |
+p5.addPath(p6, m); |
+ctx.fillStyle = 'yellow'; |
+ctx.currentPath = p5; |
+ctx.fill(); |
+var imageData = ctx.getImageData(100, 100, 100, 100); |
Justin Novosad
2014/02/19 16:38:28
Same here.
pals
2014/03/03 06:27:39
Done.
|
+var imgdata = imageData.data; |
+shouldNotBe("imgdata[4]", "255"); |
+shouldNotBe("imgdata[5]", "255"); |
+shouldBe("imgdata[6]", "0"); |
+shouldNotBe("imgdata[7]", "255"); |
+debug(""); |
+ |
+debug("Test addPath() with transform as null.") |
+var p7 = new Path(); |
+p7.rect(0,0,100,100); |
+var p8 = new Path(); |
+shouldThrow("p7.addPath(p8, null)"); |
+debug(""); |