Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: LayoutTests/fast/canvas/script-tests/canvas-path-constructors.js

Issue 226953004: Remove get/set currentPath in canvas (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 description("Test different constructors of Path."); 1 description("Test different constructors of Path.");
2 var ctx = document.createElement('canvas').getContext('2d'); 2 var ctx = document.createElement('canvas').getContext('2d');
3 3
4 debug("Test constructor Path().") 4 debug("Test constructor Path().")
5 ctx.beginPath(); 5 ctx.beginPath();
6 var p1 = new Path2D(); 6 var p1 = new Path2D();
7 p1.rect(0,0,100,100); 7 p1.rect(0,0,100,100);
8 ctx.fillStyle = 'yellow'; 8 ctx.fillStyle = 'yellow';
9 ctx.currentPath = p1; 9 ctx.fill(p1);
10 ctx.fill();
11 var imageData = ctx.getImageData(0, 0, 100, 100); 10 var imageData = ctx.getImageData(0, 0, 100, 100);
12 var imgdata = imageData.data; 11 var imgdata = imageData.data;
13 shouldBe("imgdata[4]", "255"); 12 shouldBe("imgdata[4]", "255");
14 shouldBe("imgdata[5]", "255"); 13 shouldBe("imgdata[5]", "255");
15 shouldBe("imgdata[6]", "0"); 14 shouldBe("imgdata[6]", "0");
16 shouldBe("imgdata[7]", "255"); 15 shouldBe("imgdata[7]", "255");
17 debug(""); 16 debug("");
18 17
19 debug("Test constructor Path(DOMString) which takes a SVG data string.") 18 debug("Test constructor Path(DOMString) which takes a SVG data string.")
20 ctx.beginPath(); 19 ctx.beginPath();
21 var p2 = new Path2D("M100,0L200,0L200,100L100,100z"); 20 var p2 = new Path2D("M100,0L200,0L200,100L100,100z");
22 ctx.currentPath = p2;
23 ctx.fillStyle = 'blue'; 21 ctx.fillStyle = 'blue';
24 ctx.fill(); 22 ctx.fill(p2);
25 imageData = ctx.getImageData(100, 0, 100, 100); 23 imageData = ctx.getImageData(100, 0, 100, 100);
26 imgdata = imageData.data; 24 imgdata = imageData.data;
27 shouldBe("imgdata[4]", "0"); 25 shouldBe("imgdata[4]", "0");
28 shouldBe("imgdata[5]", "0"); 26 shouldBe("imgdata[5]", "0");
29 shouldBe("imgdata[6]", "255"); 27 shouldBe("imgdata[6]", "255");
30 shouldBe("imgdata[7]", "255"); 28 shouldBe("imgdata[7]", "255");
31 debug(""); 29 debug("");
32 30
33 debug("Test constructor Path(Path) which takes another Path object.") 31 debug("Test constructor Path(Path) which takes another Path object.")
34 ctx.beginPath(); 32 ctx.beginPath();
35 var p3 = new Path2D(p1); 33 var p3 = new Path2D(p1);
36 ctx.translate(200,0); 34 ctx.translate(200,0);
37 ctx.currentPath = p3;
38 ctx.fillStyle = 'green'; 35 ctx.fillStyle = 'green';
36 ctx.fill(p3);
39 ctx.translate(-200,0); 37 ctx.translate(-200,0);
40 ctx.fill();
41 imageData = ctx.getImageData(200, 0, 100, 100); 38 imageData = ctx.getImageData(200, 0, 100, 100);
42 imgdata = imageData.data; 39 imgdata = imageData.data;
43 shouldBe("imgdata[4]", "0"); 40 shouldBe("imgdata[4]", "0");
44 shouldBe("imgdata[5]", "128"); 41 shouldBe("imgdata[5]", "128");
45 shouldBe("imgdata[6]", "0"); 42 shouldBe("imgdata[6]", "0");
46 shouldBe("imgdata[7]", "255"); 43 shouldBe("imgdata[7]", "255");
47 debug(""); 44 debug("");
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698