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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-modify-emptyPath.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-modify-emptyPath.js"></script> 4 <script>
5
6 function getColor(x,y) {
7 return ctx.getImageData(x, y, 1, 1).data;
8 }
9
10 var canvas = document.createElement('canvas');
11 canvas.width = 300;
12 canvas.height = 300;
13 var ctx = canvas.getContext('2d');
14
15 // Test no drawing cases
16 ctx.fillStyle = 'green';
17 ctx.strokeStyle = 'red';
18 ctx.lineWidth = 50;
19
20
21 test(function(t) {
22 ctx.beginPath();
23 ctx.fillRect(0, 0, 100, 100);
24 ctx.lineTo(50, 50);
25 ctx.stroke();
26 assert_array_equals(getColor(40,40), [0,128,0,255]);
27 ctx.clearRect(0, 0, 300, 300);
28
29 // Test when create rectangle path using a rectangle with width = height = 0 .
30
31 ctx.strokeStyle = 'red';
32 ctx.lineWidth = 10;
33 ctx.beginPath();
34 ctx.rect(0, 0, 0, 0);
35 ctx.stroke();
36 assert_array_equals(getColor(1,1), [0,0,0,0]);
37 ctx.clearRect(0, 0, 300, 300);
38
39 // Test path modifications that result in drawing
40 ctx.fillStyle = 'red';
41 ctx.strokeStyle = 'green';
42
43
44 ctx.beginPath();
45 ctx.fillRect(0, 0, 100, 100);
46 ctx.lineTo(0, 50);
47 ctx.lineTo(100, 50);
48 ctx.stroke();
49 assert_array_equals(getColor(0,0), [255,0,0,255]);
50 assert_array_equals(getColor(50,50), [0,128,0,255]);
51 ctx.clearRect(0, 0, 300, 300);
52
53
54 ctx.beginPath();
55 ctx.fillRect(0, 0, 100, 100);
56 ctx.quadraticCurveTo(0, 50, 100, 50);
57 ctx.stroke();
58 assert_array_equals(getColor(10,10), [255,0,0,255]);
59 assert_array_equals(getColor(50,50), [0,128,0,255]);
60 ctx.clearRect(0, 0, 300, 300);
61
62
63 ctx.beginPath();
64 ctx.fillRect(0, 0, 100, 100);
65 ctx.quadraticCurveTo(0, 50, 100, 50);
66 ctx.lineTo(50, 100);
67 ctx.stroke();
68 assert_array_equals(getColor(10,10), [255,0,0,255]);
69 assert_array_equals(getColor(99,51), [0,128,0,255]);
70 assert_array_equals(getColor(50,50), [0,128,0,255]);
71 ctx.clearRect(0, 0, 300, 300);
72
73
74 ctx.beginPath();
75 ctx.fillRect(0, 0, 100, 100);
76 ctx.bezierCurveTo(0, 50, 50, 50, 100, 50);
77 ctx.stroke();
78 assert_array_equals(getColor(10,10), [255,0,0,255]);
79 assert_array_equals(getColor(50,50), [0,128,0,255]);
80 ctx.clearRect(0, 0, 300, 300);
81
82
83 ctx.beginPath();
84 ctx.fillRect(0, 0, 100, 100);
85 ctx.bezierCurveTo(0, 50, 50, 50, 100, 50);
86 ctx.stroke();
87 ctx.lineTo(50, 100);
88 ctx.stroke();
89 assert_array_equals(getColor(10,10), [255,0,0,255]);
90 assert_array_equals(getColor(99,51), [0,128,0,255]);
91 assert_array_equals(getColor(50,50), [0,128,0,255]);
92 ctx.clearRect(0, 0, 300, 300);
93
94 }, "This tests behaviour of path modification APIs on an empty path.");
95 </script>
8 </body> 96 </body>
9 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698