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

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-strokeRect.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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/fast/canvas/canvas-strokeRect.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-strokeRect.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-strokeRect.html
index 1a5580b08cd4806d233fe3b19b81a5761c3dcf80..077c7a30e040e8d0006adbf363952977fe67ea66 100644
--- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-strokeRect.html
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-strokeRect.html
@@ -1,9 +1,61 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html>
-<head>
-<script src="../../resources/js-test.js"></script>
-</head>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
<body>
-<script src="script-tests/canvas-strokeRect.js"></script>
+<script>
+test(function(t) {
+ var ctx = document.createElement('canvas').getContext('2d');
+
+ // stroke rect with solid green
+ ctx.beginPath();
+ ctx.strokeStyle = 'green';
+ ctx.lineWidth = 100;
+ ctx.strokeRect(50, 0, 100, 100);
+ assert_array_equals(ctx.getImageData(2, 1, 1, 1).data.slice(0,3), [0, 128, 0]);
Justin Novosad 2017/02/21 22:03:13 I see 5 individual tests here. Could you break thi
zakerinasab 2017/02/22 15:42:43 Done.
+
+ ctx.clearRect(0, 0, 100, 100);
+
+ // stroke rect with a pattern
+ var canvas2 = document.createElement('canvas');
+ canvas2.width = 100;
+ canvas2.height = 100;
+ var ctx2 = canvas2.getContext('2d');
+ ctx2.fillStyle = 'green';
+ ctx2.fillRect(0, 0, 100, 100);
+ var pattern = ctx.createPattern(canvas2, 'repeat');
+ ctx.strokeStyle = 'pattern';
+ ctx.lineWidth = 100;
+ ctx.strokeRect(50, 0, 100, 100);
+ assert_array_equals(ctx.getImageData(2, 1, 1, 1).data.slice(0,3), [0, 128, 0]);
+
+ ctx.clearRect(0, 0, 100, 100);
+
+ // stroke rect with gradient
+ var gradient = ctx.createLinearGradient(0, 0, 0, 100);
+ gradient.addColorStop(0, "green");
+ gradient.addColorStop(1, "green");
+ ctx.strokeStyle = 'gradient';
+ ctx.lineWidth = 100;
+ ctx.strokeRect(50, 0, 100, 100);
+ assert_array_equals(ctx.getImageData(2, 1, 1, 1).data.slice(0,3), [0, 128, 0]);
+
+ ctx.clearRect(0, 0, 100, 100);
+
+ // stroke rect with height = width = 0 and lineWidth = 2.
+ ctx.strokeStyle = 'red';
+ ctx.lineWidth = 2;
+ ctx.strokeRect(0, 0, 0, 0);
+ assert_array_equals(ctx.getImageData(0, 0, 1, 1).data.slice(0,3), [0, 0, 0]);
+
+ // stroke rect with height = width = 0, lineWidth = 2, and shadow.
+ ctx.shadowOffsetX = 5;
+ ctx.shadowOffsetY = 5;
+ ctx.shadowColor = 'blue';
+ ctx.strokeStyle = 'red';
+ ctx.lineWidth = 2;
+ ctx.strokeRect(0, 0, 0, 0);
+ assert_array_equals(ctx.getImageData(0, 0, 1, 1).data.slice(0,3), [0, 0, 0]);
+
+}, "Series of tests to ensure correct behaviour of canvas.strokeRect()");
+
+</script>
</body>
-</html>

Powered by Google App Engine
This is Rietveld 408576698