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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/fast/canvas/canvas-path-context-stroke.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-path-context-stroke.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-path-context-stroke.html
index 5f84cb205ad1ff740d8ce30823dae31197a488e9..9025097c2b4a84325437d0ff2677a1c2b6bba847 100644
--- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-path-context-stroke.html
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-path-context-stroke.html
@@ -1,9 +1,49 @@
-<!doctype html>
-<html>
-<head>
-<script src="../../resources/js-test.js"></script>
-</head>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
<body>
<canvas id="canvas" width="200" height="200"></canvas>
-<script src="script-tests/canvas-path-context-stroke.js"></script>
+<script>
+
+var ctx = document.getElementById('canvas').getContext('2d');
+
+function checkResult(expectedColors, sigma) {
+ data = ctx.getImageData(75, 75, 1, 1).data;
+ for (var i = 0; i < 4; i++)
+ assert_approx_equals(data[i], expectedColors[i], sigma);
+}
+
+function drawRectangleOn(contextOrPath) {
+ contextOrPath.rect(25, 25, 50, 50);
+}
+
+function testStrokeWith(path) {
+ ctx.fillStyle = 'rgb(255,0,0)';
+ ctx.beginPath();
+ ctx.fillRect(0, 0, 100, 100);
+ ctx.strokeStyle = 'rgb(0,255,0)';
+ ctx.lineWidth = 5;
+ if (path) {
+ ctx.stroke(path);
+ } else {
+ ctx.beginPath();
+ drawRectangleOn(ctx);
+ ctx.stroke();
+ }
+ checkResult([0, 255, 0, 255], 5);
+}
+
+test(function(t) {
+ var path = new Path2D();
+ drawRectangleOn(path);
+
+ testStrokeWith();
+ testStrokeWith(path);
+
+ // Test exception cases.
+ assert_throws(null, function() {ctx.stroke(null);});
+ assert_throws(null, function() {ctx.stroke(undefined);});
+ assert_throws(null, function() {ctx.stroke([]);});
+ assert_throws(null, function() {ctx.stroke({});});
+}, "Series of tests to ensure stroke() works with optional path parameter.");
+</script>
</body>

Powered by Google App Engine
This is Rietveld 408576698