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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-strokeRect-gradient-shadow.html

Issue 2690183006: Use testharness.js instead of js-test.js in LayoutTests/fast/canvas tests. (Closed)
Patch Set: Addressing comments Created 3 years, 9 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-strokeRect-gradient-shadow.js"></script> 4 <script>
5 // Ensure correct behavior of canvas with strokeRect using a gradient strokeStyl e and a shadow.
6
7 var canvas = document.createElement('canvas');
8 document.body.appendChild(canvas);
9 canvas.setAttribute('width', '600');
10 canvas.setAttribute('height', '1100');
11 var ctx = canvas.getContext('2d');
12
13 var gradient = ctx.createLinearGradient(0, 0, 300, 0);
14 gradient.addColorStop(0, 'rgba(0, 0, 255, 0.5)');
15 gradient.addColorStop(1, 'rgba(0, 0, 255, 0.5)');
16
17 ctx.save();
18 ctx.strokeStyle = gradient;
19 ctx.shadowColor = 'rgba(255, 0, 0, 0.5)';
20 ctx.shadowOffsetX = 250;
21 ctx.lineWidth = 25;
22
23 var side = 200;
24
25 // Alpha shadow.
26 ctx.shadowBlur = 0;
27 ctx.strokeRect(50, 50, side, side);
28
29 // Blurry shadow.
30 ctx.shadowBlur = 10;
31 ctx.strokeRect(50, 300, side, side);
32
33 ctx.rotate(Math.PI / 2);
34
35 // Rotated alpha shadow.
36 ctx.shadowBlur = 0;
37 ctx.strokeRect(550, -250, side, side);
38
39 // Rotated blurry shadow.
40 ctx.shadowBlur = 10;
41 ctx.strokeRect(800, -250, side, side);
42
43 ctx.restore();
44
45 var imageData, data;
46 ctx.fillStyle = 'black';
47
48 function testPixelAlphaShadow(x, y, color)
49 {
50 if (color.length == 4) {
51 assert_array_equals(ctx.getImageData(x, y, 1, 1).data, color);
52 } else { // we expect to have [r, g, b, a, alphaApprox]
53 var data = ctx.getImageData(x, y, 1, 1).data;
54 assert_array_equals(data.slice(0,3), color.slice(0,3));
55 assert_approx_equals(data[3], color[3], color[4]);
56 }
57 // Plot test point.
58 ctx.fillRect(x, y, 3, 3);
59 }
60
61 var alphaTolerance = 15;
62 var testScenarios = [
63 ['Verify alpha shadow 1' , 400, 150, [0, 0, 0, 0]],
64 ['Verify alpha shadow 2' , 400, 75, [0, 0, 0, 0]],
65 ['Verify alpha shadow 3' , 400, 225, [0, 0, 0, 0]],
66 ['Verify alpha shadow 4' , 325, 150, [0, 0, 0, 0]],
67 ['Verify alpha shadow 5' , 475, 150, [0, 0, 0, 0]],
68 ['Verify alpha shadow 6' , 400, 50, [255, 0, 0, 64, alphaTolerance]],
69 ['Verify alpha shadow 7' , 500, 150, [255, 0, 0, 64, alphaTolerance]],
70 ['Verify alpha shadow 8' , 400, 250, [255, 0, 0, 64, alphaTolerance]],
71 ['Verify alpha shadow 9' , 300, 150, [255, 0, 0, 64, alphaTolerance]],
72 ['Verify alpha shadow 10' , 400, 25, [0, 0, 0, 0]],
73 ['Verify alpha shadow 11' , 525, 150, [0, 0, 0, 0]],
74 ['Verify alpha shadow 12' , 400, 275, [0, 0, 0, 0]],
75 ['Verify alpha shadow 13' , 275, 150, [0, 0, 0, 0]],
76
77 ['Verify blurry shadow 1' , 400, 400, [0, 0, 0, 0]],
78 ['Verify blurry shadow 2' , 400, 325, [0, 0, 0, 0]],
79 ['Verify blurry shadow 3' , 475, 400, [0, 0, 0, 0]],
80 ['Verify blurry shadow 4' , 400, 475, [0, 0, 0, 0]],
81 ['Verify blurry shadow 5' , 325, 400, [0, 0, 0, 0]],
82 ['Verify blurry shadow 6' , 400, 300, [255, 0, 0, 64, alphaTolerance]],
83 ['Verify blurry shadow 7' , 400, 500, [255, 0, 0, 64, alphaTolerance]],
84 ['Verify blurry shadow 8' , 300, 400, [255, 0, 0, 64, alphaTolerance]],
85 ['Verify blurry shadow 9' , 500, 400, [255, 0, 0, 64, alphaTolerance]],
86 ['Verify blurry shadow 10' , 525, 400, [0, 0, 0, 0]],
87 ['Verify blurry shadow 11' , 275, 400, [0, 0, 0, 0]],
88
89 ['Verify rotated alpha shadow 1' , 400, 650, [0, 0, 0, 0]],
90 ['Verify rotated alpha shadow 2' , 400, 575, [0, 0, 0, 0]],
91 ['Verify rotated alpha shadow 3' , 400, 725, [0, 0, 0, 0]],
92 ['Verify rotated alpha shadow 4' , 325, 650, [0, 0, 0, 0]],
93 ['Verify rotated alpha shadow 5' , 475, 650, [0, 0, 0, 0]],
94 ['Verify rotated alpha shadow 6' , 400, 550, [255, 0, 0, 64, alphaTolerance] ],
95 ['Verify rotated alpha shadow 7' , 500, 650, [255, 0, 0, 64, alphaTolerance] ],
96 ['Verify rotated alpha shadow 8' , 400, 750, [255, 0, 0, 64, alphaTolerance] ],
97 ['Verify rotated alpha shadow 9' , 300, 650, [255, 0, 0, 64, alphaTolerance] ],
98 ['Verify rotated alpha shadow 10' , 400, 525, [0, 0, 0, 0]],
99 ['Verify rotated alpha shadow 11' , 525, 650, [0, 0, 0, 0]],
100 ['Verify rotated alpha shadow 12' , 400, 775, [0, 0, 0, 0]],
101 ['Verify rotated alpha shadow 13' , 275, 650, [0, 0, 0, 0]],
102
103 ['Verify rotated blurry shadow 1' , 400, 900, [0, 0, 0, 0]],
104 ['Verify rotated blurry shadow 2' , 400, 825, [0, 0, 0, 0]],
105 ['Verify rotated blurry shadow 3' , 475, 900, [0, 0, 0, 0]],
106 ['Verify rotated blurry shadow 4' , 400, 975, [0, 0, 0, 0]],
107 ['Verify rotated blurry shadow 5' , 325, 900, [0, 0, 0, 0]],
108 ['Verify rotated blurry shadow 6' , 400, 800, [255, 0, 0, 64, alphaTolerance ]],
109 ['Verify rotated blurry shadow 7' , 400, 1000, [255, 0, 0, 64, alphaToleranc e]],
110 ['Verify rotated blurry shadow 8' , 300, 900, [255, 0, 0, 64, alphaTolerance ]],
111 ['Verify rotated blurry shadow 9' , 500, 900, [255, 0, 0, 64, alphaTolerance ]],
112 ['Verify rotated blurry shadow 10' , 525, 900, [0, 0, 0, 0]],
113 ['Verify rotated blurry shadow 11' , 275, 900, [0, 0, 0, 0]],
114 ['Verify rotated blurry shadow 12' , 400, 1025, [0, 0, 0, 0]],
115 ];
116
117 generate_tests(testPixelAlphaShadow, testScenarios);
118
119 </script>
8 </body> 120 </body>
9 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698