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

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-lineWidth.html

Issue 2694703004: Use testharness.js instead of js-test.js in LayoutTests/fast/canvas tests. (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/canvas/canvas-lineWidth.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/fast/canvas/canvas-lineWidth.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-lineWidth.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-lineWidth.html
index b36f5027d6273b68d22eba3c6b78cadeab9d0f2a..264b18255bc5a3dea3685e9a7d8a4ddbff53f2fb 100644
--- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-lineWidth.html
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-lineWidth.html
@@ -1,10 +1,50 @@
-<!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>
<canvas id="canvas" width=600 height=300 style="border:5px solid black">
-<script src="canvas-lineWidth.js"></script>
+<script>
+// Compare sections of a <canvas> to assert they are identical, or nearly so.
+function compareRows(ctx, y0, y1, width, height, allowableDifference) {
+ var data0 = ctx.getImageData(0, y0, width, height).data;
+ var data1 = ctx.getImageData(0, y1, width, height).data;
+ for (var i = 0; i < data0.length; ++i)
+ assert_approx_equals(data0[i], data1[i], allowableDifference);
+}
+
+ctx = document.getElementById("canvas").getContext("2d");
+ctx.strokeStyle = 'blue';
+
+test(function(t) {
+
+ for (var j = 0; j < 3; ++j) {
+ ctx.beginPath();
+ for (var i = 0; i < 60; ++i) {
+ var x = i * 10;
+ var y = j * 100 + 30 + (i % 15);
+ if (i == 0) {
+ ctx.moveTo(x, y);
+ } else {
+ ctx.lineTo(x, y);
+ }
+ }
+ ctx.stroke();
+
+ if (j == 0) {
+ assert_equals(ctx.lineWidth, 1);
+ ctx.lineWidth = ctx.lineWidth;
+ assert_equals(ctx.lineWidth, 1);
+ } else {
+ assert_equals(ctx.lineWidth, 1);
+ ctx.lineWidth = 1;
+ assert_equals(ctx.lineWidth, 1);
+ }
+ }
+
+ // Make sure that all rows are nearly identical.
+ // (Tiny variations are OK.)
+ compareRows(ctx, 0, 100, 600, 100, 1);
+ compareRows(ctx, 0, 200, 600, 100, 1);
+
+}, 'Test that the default lineWidth is consistent.');
+</script>
</body>
-</html>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/canvas/canvas-lineWidth.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698