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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-path-addpath.html

Issue 2694703004: Use testharness.js instead of js-test.js in LayoutTests/fast/canvas tests. (Closed)
Patch Set: Created 3 years, 10 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 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> 1 <script src="../../resources/testharness.js"></script>
2 <html> 2 <script src="../../resources/testharnessreport.js"></script>
3 <head>
4 <script src="../../resources/js-test.js"></script>
5 </head>
6 <body> 3 <body>
7 <script src="script-tests/canvas-path-addpath.js"></script> 4 <script>
5 test(function(t) {
6 var canvas = document.createElement('canvas');
7 var ctx = canvas.getContext('2d');
8
9 ctx.clearRect(0, 0, canvas.width, canvas.height);
10 ctx.beginPath();
11 var p1 = new Path2D();
12 p1.rect(0,0,100,100);
13 var p2 = new Path2D();
14 p2.rect(0,100,100,100);
15 var m = ctx.currentTransform;
16 p1.addPath(p2, m);
17 ctx.fillStyle = 'yellow';
18 ctx.fill(p1);
19 assert_array_equals(ctx.getImageData(1, 100, 1, 1).data, [255, 255, 0, 255]) ;
20
21 ctx.clearRect(0, 0, canvas.width, canvas.height);
22 ctx.beginPath();
23 var p3 = new Path2D();
24 p3.rect(0,0,100,100);
25 var p4 = new Path2D();
26 p4.rect(0,100,100,100);
27 m.a = 1; m.b = 0;
28 m.c = 0; m.d = 1;
29 m.e = 100; m.f = -100;
30 p3.addPath(p4, m);
31 ctx.fillStyle = 'yellow';
32 ctx.fill(p3);
33 assert_array_equals(ctx.getImageData(101, 0, 1, 1).data, [255, 255, 0, 255]) ;
34
35 ctx.clearRect(0, 0, canvas.width, canvas.height);
36 ctx.beginPath();
37 var p5 = new Path2D();
38 p5.rect(0,0,100,100);
39 var p6 = new Path2D();
40 p6.rect(100,100,100,100);
41 m.a = 0; m.b = 0;
42 m.c = 0; m.d = 0;
43 m.e = 0; m.f = 0;
44 p5.addPath(p6, m);
45 ctx.fillStyle = 'yellow';
46 ctx.fill(p5);
47 assert_array_equals(ctx.getImageData(101, 100, 1, 1).data, [0, 0, 0, 0]);
48
49 ctx.clearRect(0, 0, canvas.width, canvas.height);
50 ctx.beginPath();
51 var p7 = new Path2D();
52 p7.rect(0,0,100,100);
53 var p8 = new Path2D();
54 p8.rect(100,100,100,100);
55 p7.addPath(p8, null);
56 assert_throws(null, function() {p7.addPath(p8, []);});
57 assert_throws(null, function() {p7.addPath(p8, {});});
58 ctx.fillStyle = 'red';
59 ctx.fill(p7);
60 assert_array_equals(ctx.getImageData(101, 100, 1, 1).data, [255, 0, 0, 255]) ;
61
62 ctx.clearRect(0, 0, canvas.width, canvas.height);
63 ctx.beginPath();
64 var p9 = new Path2D();
65 var p10 = new Path2D();
66 p9.rect(0,0,10,10);
67 p10.addPath(p9);
68 ctx.fillStyle = 'red';
69 ctx.fill(p10);
70 assert_array_equals(ctx.getImageData(1, 1, 1, 1).data, [255, 0, 0, 255]);
71
72 var p9 = new Path2D();
73 p9.rect(0,0,100,100);
74 assert_throws(null, function() {p7.addPath(null, m);});
75 assert_throws(null, function() {p7.addPath([], m);});
76 assert_throws(null, function() {p7.addPath({}, m);});
77
78 }, "Test addPath() method.");
79 </script>
8 </body> 80 </body>
9 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698