description("Test addPath() method.");
-var ctx = document.createElement('canvas').getContext('2d');
+var canvas = document.createElement('canvas');
+var ctx = canvas.getContext('2d');
debug("Test addPath() with transform as identity matrix.")
+ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.beginPath();
var p1 = new Path2D();
p1.rect(0,0,100,100);
var m = ctx.currentTransform;
p1.addPath(p2, m);
ctx.fillStyle = 'yellow';
-ctx.currentPath = p1;
-ctx.fill();
+ctx.fill(p1);
var imageData = ctx.getImageData(0, 100, 100, 100);
var imgdata = imageData.data;
shouldBe("imgdata[4]", "255");
debug("");
debug("Test addPath() with transform as translate(100, -100).")
+ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.beginPath();
var p3 = new Path2D();
p3.rect(0,0,100,100);
m.e = 100; m.f = -100;
p3.addPath(p4, m);
ctx.fillStyle = 'yellow';
-ctx.currentPath = p3;
-ctx.fill();
+ctx.fill(p3);
imageData = ctx.getImageData(100, 0, 100, 100);
imgdata = imageData.data;
shouldBe("imgdata[4]", "255");
debug("");
debug("Test addPath() with non-invertible transform.")
+ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.beginPath();
var p5 = new Path2D();
p5.rect(0,0,100,100);
m.e = 0; m.f = 0;
p5.addPath(p6, m);
ctx.fillStyle = 'yellow';
-ctx.currentPath = p5;
-ctx.fill();
+ctx.fill(p5);
imageData = ctx.getImageData(100, 100, 100, 100);
imgdata = imageData.data;
shouldNotBe("imgdata[4]", "255");
debug("");
debug("Test addPath() with transform as null or invalid type.")
+ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.beginPath();
var p7 = new Path2D();
p7.rect(0,0,100,100);
var p8 = new Path2D();
p8.rect(100,100,100,100);
p7.addPath(p8, null);
-p7.addPath(p8, []);
-p7.addPath(p8, {});
+shouldThrow("p7.addPath(p8, [])");
+shouldThrow("p7.addPath(p8, {})");
ctx.fillStyle = 'red';
-ctx.currentPath = p7;
-ctx.fill();
+ctx.fill(p7);
imageData = ctx.getImageData(100, 100, 100, 100);
imgdata = imageData.data;
shouldBe("imgdata[4]", "255");
shouldBe("imgdata[7]", "255");
debug("");
+debug("Test addPath() with transform omitted.")
+ctx.clearRect(0, 0, canvas.width, canvas.height);
+ctx.beginPath();
+var p9 = new Path2D();
+var p10 = new Path2D();
+p9.rect(0,0,10,10);
+p10.addPath(p9);
+ctx.fillStyle = 'red';
+ctx.fill(p10);
+imageData = ctx.getImageData(1, 1, 1, 1);
+imgdata = imageData.data;
+shouldBe("imgdata[0]", "255");
+shouldBe("imgdata[1]", "0");
+shouldBe("imgdata[2]", "0");
+shouldBe("imgdata[3]", "255");
+debug("");
+
debug("Test addPath() with path as null and invalid type");
var p9 = new Path2D();
p9.rect(0,0,100,100);