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

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

Issue 2690183006: 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 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-strokePath-shadow.js"></script> 4 <script>
5 // Ensure correct behavior of canvas with path stroke shadow.
6
7 var canvas = document.createElement('canvas');
8 document.body.appendChild(canvas);
9 canvas.setAttribute('width', '700');
10 canvas.setAttribute('height', '700');
11 var ctx = canvas.getContext('2d');
12
13 ctx.beginPath();
14 ctx.moveTo(300, 300);
15 ctx.lineTo(300, 50);
16 ctx.bezierCurveTo(200, 40, 75, 150, 30, 30);
17 ctx.quadraticCurveTo(250, 75, 50, 300);
18 ctx.shadowOffsetX = 350;
19 ctx.shadowColor = 'rgba(255, 20, 0, 0.5)';
20 ctx.shadowBlur = 0;
21 ctx.strokeStyle = 'rgba(0, 0, 255, 1)';
22 ctx.lineWidth = 30;
23 ctx.closePath();
24 ctx.stroke();
25
26 ctx.beginPath();
27 ctx.moveTo(300,650);
28 ctx.lineTo(300,400);
29 ctx.bezierCurveTo(200, 390, 75, 500, 30, 380);
30 ctx.quadraticCurveTo(250, 425, 50, 650);
31 ctx.shadowOffsetX = 350;
32 ctx.shadowColor = 'rgba(255, 0, 0, 0.5)';
33 ctx.shadowBlur = 30;
34 ctx.strokeStyle = 'rgba(0, 0, 255, 1)';
35 ctx.lineWidth = 30;
36 ctx.closePath();
37 ctx.stroke();
38
39 var colorTolerance = 2;
40 function checkPixelWithTolerance(x, y, rgbNOTa) {
41 data = ctx.getImageData(x, y, 1, 1).data;
42 for (i = 0; i < 3; i++)
43 assert_approx_equals(data[i], rgbNOTa[i], colorTolerance);
44 if(rgbNOTa.length == 4)
45 assert_not_equals(data[3], rgbNOTa[3]);
46 }
47
48 var testScenarios = [
49 ['Verify solid shadow 1', 650, 300, [255, 20, 0]],
50 ['Verify solid shadow 2', 650, 50, [255, 20, 0]],
51 ['Verify solid shadow 3', 380, 30, [255, 20, 0]],
52 ['Verify solid shadow 4', 400, 40, [255, 20, 0]],
53
54 ['Verify blurry shadow 1', 640, 640, [255, 0, 0, 255]],
55 ['Verify blurry shadow 2', 650, 400, [255, 0, 0, 255]],
56 ['Verify blurry shadow 3', 380, 380, [255, 0, 0, 255]],
57 ['Verify blurry shadow 4', 350, 380, [255, 0, 0, 255]],
58
59 ];
60
61 generate_tests(checkPixelWithTolerance, testScenarios);
62
63 </script>
8 </body> 64 </body>
9 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698