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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-clip-rule.html

Issue 2675763005: Use testharness.js instead of js-test.js in LayoutTests/fast/canvas tests. (Closed)
Patch Set: Addressing comments 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> 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-clip-rule.js"></script> 4 <script>
5 var tmpimg = document.createElement('canvas');
6 tmpimg.width = 200;
7 tmpimg.height = 200;
8 ctx = tmpimg.getContext('2d');
9
10 // Create the image for blending test with images.
11 var img = document.createElement('canvas');
12 img.width = 100;
13 img.height = 100;
14 var imgCtx = img.getContext('2d');
15
16 function checkResult(expectedColors, sigma) {
17 var data = ctx.getImageData(50, 50, 1, 1).data;
18 for (var i = 0; i < 4; i++)
19 assert_approx_equals(data[i], expectedColors[i], sigma);
20 }
21
22 test(function(t) {
23 ctx.fillStyle = 'rgb(255,0,0)';
24 ctx.fillRect(0, 0, 100, 100);
25 ctx.fillStyle = 'rgb(0,255,0)';
26 ctx.beginPath();
27 ctx.rect(0, 0, 100, 100);
28 ctx.rect(25, 25, 50, 50);
29 ctx.clip();
30 ctx.beginPath();
31 ctx.fillRect(0, 0, 100, 100);
32 checkResult([0, 255, 0, 255], 5);
33
34 ctx.fillStyle = 'rgb(255,0,0)';
35 ctx.fillRect(0, 0, 100, 100);
36 ctx.fillStyle = 'rgb(0,255,0)';
37 ctx.beginPath();
38 ctx.rect(0, 0, 100, 100);
39 ctx.rect(25, 25, 50, 50);
40 ctx.clip('nonzero');
41 ctx.beginPath();
42 ctx.fillRect(0, 0, 100, 100);
43 checkResult([0, 255, 0, 255], 5);
44
45 ctx.fillStyle = 'rgb(255,0,0)';
46 ctx.fillRect(0, 0, 100, 100);
47 ctx.fillStyle = 'rgb(0,255,0)';
48 ctx.beginPath();
49 ctx.rect(0, 0, 100, 100);
50 ctx.rect(25, 25, 50, 50);
51 ctx.clip('evenodd');
52 ctx.beginPath();
53 ctx.fillRect(0, 0, 100, 100);
54 checkResult([255, 0, 0, 255], 5);
55 }, "Series of tests to ensure correct results of the winding rule.");
56 </script>
8 </body> 57 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698