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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-scale-fillRect-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-fillRect-shadow.js"></script> 4 <script>
5 // Ensure correct behavior of canvas with fillRect+shadow after 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', '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.fillRect(50, 50, 50, 50);
20
21 ctx.shadowColor = 'rgba(255, 0, 0, 0.3)';
22 ctx.fillRect(50, 150, 50, 50);
23
24 ctx.shadowColor = 'rgba(255, 0, 0, 1.0)';
25 ctx.shadowBlur = 10;
26 ctx.fillRect(150, 50, 50, 50);
27
28 ctx.shadowColor = 'rgba(255, 0, 0, 0.3)';
29 ctx.fillRect(150, 150, 50, 50);
30
31 function testPixelShadow(x, y, color)
32 {
33 assert_array_equals(ctx.getImageData(x, y, 1, 1).data, color);
34 }
35
36 function testPixelShadowAlpha(x, y, color)
37 {
38 var data = ctx.getImageData(x, y, 1, 1).data;
39 assert_array_equals(data.slice(0,3), color.slice(0,3));
40 assert_approx_equals(data[3], color[3], 20);
41 }
42
43 var testPixelShadowScenarios = [
44 ['Verify solid shadow 1', 201, 205, [255, 0, 0, 255]],
45 ['Verify solid shadow 2', 298, 298, [255, 0, 0, 255]],
46 ['Verify solid shadow 3', 201, 298, [255, 0, 0, 255]],
47 ];
48
49 var testPixelShadowAlphaScenarios = [
50 ['Verify solid alpha shadow 1', 201, 405, [255, 0, 0, 76]],
51 ['Verify solid alpha shadow 2', 298, 405, [255, 0, 0, 76]],
52 ['Verify solid alpha shadow 3', 205, 498, [255, 0, 0, 76]],
53
54 ['Verify blurry shadow 1', 398, 205, [255, 0, 0, 83]],
55 ['Verify blurry shadow 2', 501, 205, [255, 0, 0, 83]],
56 ['Verify blurry shadow 3', 500, 300, [255, 0, 0, 53]],
57
58 ['Verify blurry alpha shadow 1', 398, 405, [255, 0, 0, 24]],
59 ['Verify blurry alpha shadow 2', 405, 501, [255, 0, 0, 24]],
60 ];
61
62 generate_tests(testPixelShadow, testPixelShadowScenarios);
63 generate_tests(testPixelShadowAlpha, testPixelShadowAlphaScenarios);
64
65 </script>
8 </body> 66 </body>
9 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698