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-path-context-stroke.html

Issue 2689243002: 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> 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 <canvas id="canvas" width="200" height="200"></canvas> 4 <canvas id="canvas" width="200" height="200"></canvas>
8 <script src="script-tests/canvas-path-context-stroke.js"></script> 5 <script>
6
7 var ctx = document.getElementById('canvas').getContext('2d');
8
9 function checkResult(expectedColors, sigma) {
10 data = ctx.getImageData(75, 75, 1, 1).data;
11 for (var i = 0; i < 4; i++)
12 assert_approx_equals(data[i], expectedColors[i], sigma);
13 }
14
15 function drawRectangleOn(contextOrPath) {
16 contextOrPath.rect(25, 25, 50, 50);
17 }
18
19 function testStrokeWith(path) {
20 ctx.fillStyle = 'rgb(255,0,0)';
21 ctx.beginPath();
22 ctx.fillRect(0, 0, 100, 100);
23 ctx.strokeStyle = 'rgb(0,255,0)';
24 ctx.lineWidth = 5;
25 if (path) {
26 ctx.stroke(path);
27 } else {
28 ctx.beginPath();
29 drawRectangleOn(ctx);
30 ctx.stroke();
31 }
32 checkResult([0, 255, 0, 255], 5);
33 }
34
35 test(function(t) {
36 var path = new Path2D();
37 drawRectangleOn(path);
38
39 testStrokeWith();
40 testStrokeWith(path);
41
42 // Test exception cases.
43 assert_throws(null, function() {ctx.stroke(null);});
44 assert_throws(null, function() {ctx.stroke(undefined);});
45 assert_throws(null, function() {ctx.stroke([]);});
46 assert_throws(null, function() {ctx.stroke({});});
47 }, "Series of tests to ensure stroke() works with optional path parameter.");
48 </script>
9 </body> 49 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698