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

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: Corrections 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 test(function(t) {
6 var tmpimg = document.createElement('canvas');
7 tmpimg.width = 200;
8 tmpimg.height = 200;
9 ctx = tmpimg.getContext('2d');
10
11 // Create the image for blending test with images.
12 var img = document.createElement('canvas');
13 img.width = 100;
14 img.height = 100;
15 var imgCtx = img.getContext('2d');
16
17 function pixelDataAtPoint()
18 {
19 return ctx.getImageData(50, 50, 1, 1).data;
20 }
21
22 function checkResult(expectedColors, sigma) {
23 for (var i = 0; i < 4; i++)
24 assert_approx_equals(pixelDataAtPoint()[i], expectedColors[i], sigma );
25 }
26
27 // Execute test.
28 function prepareTestScenario() {
Justin Novosad 2017/02/08 18:23:33 Nit: unnecessary nested function
zakerinasab 2017/02/08 19:57:49 Done.
29 ctx.fillStyle = 'rgb(255,0,0)';
30 ctx.fillRect(0, 0, 100, 100);
31 ctx.fillStyle = 'rgb(0,255,0)';
32 ctx.beginPath();
33 ctx.rect(0, 0, 100, 100);
34 ctx.rect(25, 25, 50, 50);
35 ctx.clip();
36 ctx.beginPath();
37 ctx.fillRect(0, 0, 100, 100);
38 checkResult([0, 255, 0, 255], 5);
39
40 ctx.fillStyle = 'rgb(255,0,0)';
41 ctx.fillRect(0, 0, 100, 100);
42 ctx.fillStyle = 'rgb(0,255,0)';
43 ctx.beginPath();
44 ctx.rect(0, 0, 100, 100);
45 ctx.rect(25, 25, 50, 50);
46 ctx.clip('nonzero');
47 ctx.beginPath();
48 ctx.fillRect(0, 0, 100, 100);
49 checkResult([0, 255, 0, 255], 5);
50
51 ctx.fillStyle = 'rgb(255,0,0)';
52 ctx.fillRect(0, 0, 100, 100);
53 ctx.fillStyle = 'rgb(0,255,0)';
54 ctx.beginPath();
55 ctx.rect(0, 0, 100, 100);
56 ctx.rect(25, 25, 50, 50);
57 ctx.clip('evenodd');
58 ctx.beginPath();
59 ctx.fillRect(0, 0, 100, 100);
60 checkResult([255, 0, 0, 255], 5);
61 }
62
63 // Run test and allow variation of results.
64 prepareTestScenario();
65 }, "Series of tests to ensure correct results of the winding rule.");
66 </script>
8 </body> 67 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698