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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-transforms-fillRect-shadow.html

Issue 2693043012: 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 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-transforms-fillRect-shadow.js"></script> 4 <script>
5 // Ensure correct behavior of canvas with fillRect+shadow after translation+rota tion+scaling. A blue and red checkered pattern should be displayed.
6
7 var canvas = document.createElement('canvas');
8 document.body.appendChild(canvas);
9 canvas.setAttribute('width', '600');
10 canvas.setAttribute('height', '600');
11 var ctx = canvas.getContext('2d');
12
13 ctx.fillStyle = 'rgba(0, 0, 255, 1.0)';
14 ctx.shadowOffsetX = 100;
15 ctx.shadowOffsetY = 100;
16
17 ctx.translate(-100, -100);
18 ctx.rotate(Math.PI/2);
19 ctx.scale(2, 2);
20
21 ctx.shadowColor = 'rgba(255, 0, 0, 1.0)';
22 ctx.fillRect(100, -150, 50, 50);
23
24 ctx.shadowColor = 'rgba(255, 0, 0, 0.5)';
25 ctx.fillRect(200, -150, 50, 50);
26
27 ctx.shadowBlur = 5;
28 ctx.shadowColor = 'rgba(255, 0, 0, 1.0)';
29 ctx.fillRect(100, -250, 50, 50);
30
31 ctx.shadowColor = 'rgba(255, 0, 0, 0.5)';
32 ctx.fillRect(200, -250, 50, 50);
33
34 function testPixelShadowBlur(x, y, color)
35 {
36 if (color.length == 4) {
37 assert_array_equals(ctx.getImageData(x, y, 1, 1).data, color);
38 } else { // we expect to have [r, g, b, a, alphaTolerance]
39 var data = ctx.getImageData(x, y, 1, 1).data;
40 assert_array_equals(data.slice(0,3), color.slice(0,3));
41 assert_approx_equals(data[3], color[3], color[4]);
42 }
43 }
44
45 var alphaTolerance = 20;
46 var testPixelShadowScenarios = [
47 ['Verify solid shadow 1', 201, 205, [255, 0, 0, 255]],
48 ['Verify solid shadow 2', 298, 298, [255, 0, 0, 255]],
49 ['Verify solid shadow 3', 201, 298, [255, 0, 0, 255]],
50
51 ['Verify solid alpha shadow 1', 201, 401, [255, 0, 0, 127, alphaTolerance]],
52 ['Verify solid alpha shadow 2', 298, 450, [255, 0, 0, 127, alphaTolerance]],
53 ['Verify solid alpha shadow 3', 205, 498, [255, 0, 0, 127, alphaTolerance]],
54
55 ['Verify blurry shadow 1', 399, 205, [255, 0, 0, 106, alphaTolerance]],
56 ['Verify blurry shadow 2', 500, 205, [255, 0, 0, 106, alphaTolerance]],
57 ['Verify blurry shadow 3', 499, 299, [255, 0, 0, 83, alphaTolerance]],
58
59 ['Verify blurry alpha shadow 1', 398, 405, [255, 0, 0, 36, alphaTolerance]],
60 ['Verify blurry alpha shadow 2', 405, 501, [255, 0, 0, 36, alphaTolerance]],
61 ['Verify blurry alpha shadow 3', 405, 501, [255, 0, 0, 36, alphaTolerance]],
62 ];
63
64 generate_tests(testPixelShadowBlur, testPixelShadowScenarios);
65
66 </script>
8 </body> 67 </body>
9 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698