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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-scale-fillPath-shadow.html

Issue 2696023002: Use testharness.js instead of js-test.js in LayoutTests/fast/canvas tests. (Closed)
Patch Set: Rebaseline 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-scale-fillPath-shadow.js"></script> 4 <script>
5 // Ensure correct behavior of canvas with path fill + shadow after scaling. A bl ue and red checkered pattern should be displayed.
6
7 var canvas = document.createElement('canvas');
8 document.body.appendChild(canvas);
9 canvas.setAttribute('width', '1000');
10 canvas.setAttribute('height', '1000');
11 var ctx = canvas.getContext('2d');
12
13 ctx.scale(2, 2);
14 ctx.shadowOffsetX = 100;
15 ctx.shadowOffsetY = 100;
16 ctx.fillStyle = 'rgba(0, 0, 255, 1)';
17
18 ctx.shadowColor = 'rgba(255, 0, 0, 1.0)';
19 ctx.beginPath();
20 ctx.moveTo(50, 50);
21 ctx.lineTo(100, 50);
22 ctx.lineTo(100, 100);
23 ctx.lineTo(50, 100);
24 ctx.fill();
25
26 ctx.shadowColor = 'rgba(255, 0, 0, 0.3)';
27 ctx.beginPath();
28 ctx.moveTo(50, 150);
29 ctx.lineTo(100, 150);
30 ctx.lineTo(100, 200);
31 ctx.lineTo(50, 200);
32 ctx.fill();
33
34 ctx.shadowColor = 'rgba(255, 0, 0, 1.0)';
35 ctx.shadowBlur = 10;
36 ctx.beginPath();
37 ctx.moveTo(150, 50);
38 ctx.lineTo(200, 50);
39 ctx.lineTo(200, 100);
40 ctx.lineTo(150, 100);
41 ctx.fill();
42
43 ctx.shadowColor = 'rgba(255, 0, 0, 0.3)';
44 ctx.beginPath();
45 ctx.moveTo(150, 150);
46 ctx.lineTo(200, 150);
47 ctx.lineTo(200, 200);
48 ctx.lineTo(150, 200);
49 ctx.fill();
50
51 function testPixelShadow(x, y, color)
52 {
53 assert_array_equals(ctx.getImageData(x, y, 1, 1).data, color);
54 }
55
56 function testPixelShadowAlpha(x, y, color)
57 {
58 var data = ctx.getImageData(x, y, 1, 1).data;
59 assert_array_equals(data.slice(0,3), color.slice(0,3));
60 assert_approx_equals(data[3], color[3], 20);
61 }
62
63 var testPixelShadowScenarios = [
64 ['Verify solid shadow 1', 201, 205, [255, 0, 0, 255]],
65 ['Verify solid shadow 2', 298, 295, [255, 0, 0, 255]],
66 ['Verify solid shadow 3', 201, 298, [255, 0, 0, 255]],
67 ];
68
69 var testPixelShadowAlphaScenarios = [
70 ['Verify solid alpha shadow 1', 201, 405, [255, 0, 0, 76]],
71 ['Verify solid alpha shadow 2', 298, 405, [255, 0, 0, 76]],
72 ['Verify solid alpha shadow 3', 205, 498, [255, 0, 0, 76]],
73
74 ['Verify blurry shadow 1', 398, 205, [255, 0, 0, 83]],
75 ['Verify blurry shadow 2', 501, 205, [255, 0, 0, 83]],
76 ['Verify blurry shadow 3', 500, 300, [255, 0, 0, 53]],
77
78 ['Verify blurry alpha shadow 1', 398, 405, [255, 0, 0, 24]],
79 ['Verify blurry alpha shadow 2', 405, 501, [255, 0, 0, 24]],
80 ];
81
82 generate_tests(testPixelShadow, testPixelShadowScenarios);
83 generate_tests(testPixelShadowAlpha, testPixelShadowAlphaScenarios);
84
85 </script>
8 </body> 86 </body>
9 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698