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

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

Issue 2675763005: 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-currentTransform.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-currentTransform.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-currentTransform.html
index e9ed6b2d698d80496409a5ab612675d0c039fca3..c9716be74a899144a5567dca6e84caf7e41a10f2 100644
--- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-currentTransform.html
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-currentTransform.html
@@ -1,9 +1,323 @@
-<!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-currentTransform.js"></script>
+<script>
+test(function(t) {
+ var ctx = document.createElement('canvas').getContext('2d');
+
+ var matrix = ctx.currentTransform;
+ assert_equals(matrix.a, 1);
+ assert_equals(matrix.b, 0);
+ assert_equals(matrix.c, 0);
+ assert_equals(matrix.d, 1);
+ assert_equals(matrix.e, 0);
+ assert_equals(matrix.f, 0);
+
+ function setCurrentTransform(ctx, a, b, c, d, e, f)
+ {
+ matrix.a = a;
+ matrix.b = b;
+ matrix.c = c;
+ matrix.d = d;
+ matrix.e = e;
+ matrix.f = f;
+ ctx.currentTransform = matrix;
+ matrix.a = NaN;
+ matrix.b = NaN;
+ matrix.c = NaN;
+ matrix.d = NaN;
+ matrix.e = NaN;
+ matrix.f = NaN;
+ matrix = ctx.currentTransform;
+ assert_equals(matrix.a, a);
+ assert_equals(matrix.b, b);
+ assert_equals(matrix.c, c);
+ assert_equals(matrix.d, d);
+ assert_equals(matrix.e, e);
+ assert_equals(matrix.f, f);
+ }
+
+ matrix.a = 2;
+
+ assert_equals(ctx.currentTransform.a, 1);
+ assert_equals(ctx.currentTransform.b, 0);
+ assert_equals(ctx.currentTransform.c, 0);
+ assert_equals(ctx.currentTransform.d, 1);
+ assert_equals(ctx.currentTransform.e, 0);
+ assert_equals(ctx.currentTransform.f, 0);
+
+
+ ctx.beginPath();
+ ctx.scale(0.5, 0.5);
+ matrix = ctx.currentTransform;
+ assert_equals(matrix.a, 0.5);
+ assert_equals(matrix.b, 0);
+ assert_equals(matrix.c, 0);
+ assert_equals(matrix.d, 0.5);
+ assert_equals(matrix.e, 0);
+ assert_equals(matrix.f, 0);
+ setCurrentTransform(ctx, 1, 0, 0, 1, 0, 0);
+ ctx.fillStyle = 'green';
+ ctx.fillRect(0, 0, 100, 100);
+
+ var imageData = ctx.getImageData(1, 1, 98, 98);
+ var imgdata = imageData.data;
+ assert_equals(imgdata[4], 0);
+ assert_equals(imgdata[5], 128);
+ assert_equals(imgdata[6], 0);
+
+
+ ctx.beginPath();
+ ctx.rect(0,0,100,100);
+ ctx.save();
+ setCurrentTransform(ctx, 0.5, 0, 0, 0.5, 10, 10);
+ ctx.fillStyle = 'red';
+ ctx.fillRect(0, 0, 100, 100);
+ ctx.restore();
+ matrix = ctx.currentTransform;
+ assert_equals(matrix.a, 1);
+ assert_equals(matrix.b, 0);
+ assert_equals(matrix.c, 0);
+ assert_equals(matrix.d, 1);
+ assert_equals(matrix.e, 0);
+ assert_equals(matrix.f, 0);
+ ctx.fillStyle = 'green';
+ ctx.fillRect(0, 0, 100, 100);
+
+ imageData = ctx.getImageData(1, 1, 98, 98);
+ imgdata = imageData.data;
+ assert_equals(imgdata[4], 0);
+ assert_equals(imgdata[5], 128);
+ assert_equals(imgdata[6], 0);
+
+
+ ctx.beginPath();
+ ctx.fillStyle = 'green';
+ ctx.save();
+ setCurrentTransform(ctx, 0.5, 0, 0, 0.5, 0, 0);
+ ctx.fillStyle = 'red';
+ ctx.fillRect(0, 0, 100, 100);
+ ctx.restore();
+ matrix = ctx.currentTransform;
+ assert_equals(matrix.a, 1);
+ assert_equals(matrix.b, 0);
+ assert_equals(matrix.c, 0);
+ assert_equals(matrix.d, 1);
+ assert_equals(matrix.e, 0);
+ assert_equals(matrix.f, 0);
+ ctx.fillRect(0, 0, 100, 100);
+
+ imageData = ctx.getImageData(1, 1, 98, 98);
+ imgdata = imageData.data;
+ assert_equals(imgdata[4], 0);
+ assert_equals(imgdata[5], 128);
+ assert_equals(imgdata[6], 0);
+
+
+ ctx.beginPath();
+ ctx.fillStyle = 'green';
+ ctx.fillRect(0, 0, 100, 100);
+ setCurrentTransform(ctx, 0, 0, 0, 0, 0, 0);
+ ctx.fillStyle = 'red';
+ ctx.fillRect(0, 0, 100, 100);
+
+ imageData = ctx.getImageData(1, 1, 98, 98);
+ imgdata = imageData.data;
+ assert_equals(imgdata[4], 0);
+ assert_equals(imgdata[5], 128);
+ assert_equals(imgdata[6], 0);
+
+
+ ctx.beginPath();
+ ctx.resetTransform();
+ matrix = ctx.currentTransform;
+ assert_equals(matrix.a, 1);
+ assert_equals(matrix.b, 0);
+ assert_equals(matrix.c, 0);
+ assert_equals(matrix.d, 1);
+ assert_equals(matrix.e, 0);
+ assert_equals(matrix.f, 0);
+ ctx.save();
+ setCurrentTransform(ctx, 0, 0, 0, 0, 0, 0);
+ ctx.fillStyle = 'red';
+ ctx.fillRect(0, 0, 100, 100);
+ ctx.restore();
+ matrix = ctx.currentTransform;
+ assert_equals(matrix.a, 1);
+ assert_equals(matrix.b, 0);
+ assert_equals(matrix.c, 0);
+ assert_equals(matrix.d, 1);
+ assert_equals(matrix.e, 0);
+ assert_equals(matrix.f, 0);
+ ctx.fillStyle = 'blue';
+ ctx.fillRect(0, 0, 100, 100);
+
+ imageData = ctx.getImageData(1, 1, 98, 98);
+ imgdata = imageData.data;
+ assert_equals(imgdata[4], 0);
+ assert_equals(imgdata[5], 0);
+ assert_equals(imgdata[6], 255);
+
+ ctx.beginPath();
+ ctx.fillStyle = 'red';
+ ctx.fillRect(0, 0, 100, 100);
+ setCurrentTransform(ctx, 0, 0, 0, 0, 0, 0);
+ ctx.fillStyle = 'green';
+ ctx.fillRect(0, 0, 100, 100);
+ setCurrentTransform(ctx, 1, 0, 0, 1, 0, 0);
+ ctx.fillStyle = 'blue';
+ ctx.fillRect(0, 0, 100, 100);
+
+ imageData = ctx.getImageData(1, 1, 98, 98);
+ imgdata = imageData.data;
+ assert_equals(imgdata[4], 0);
+ assert_equals(imgdata[5], 0);
+ assert_equals(imgdata[6], 255);
+
+ setCurrentTransform(ctx, 1, 0, 0, 1, 1, 2);
+ ctx.scale(0, 0);
+ matrix = ctx.currentTransform;
+ assert_equals(matrix.a, 0);
+ assert_equals(matrix.b, 0);
+ assert_equals(matrix.c, 0);
+ assert_equals(matrix.d, 0);
+ assert_equals(matrix.e, 1);
+ assert_equals(matrix.f, 2);
+ setCurrentTransform(ctx, 1, 0, 0, 1, 0, 0);
+
+ // throws: TypeError: Failed to set the \'currentTransform\' property on \'CanvasRenderingContext2D\': The provided value is not of type \'SVGMatrix\'.
+ assert_throws(null, function() {ctx.currentTransform = ctx;});
+ // throws: TypeError: Failed to set the \'currentTransform\' property on \'CanvasRenderingContext2D\': The provided value is not of type \'SVGMatrix\'.
+ assert_throws(null, function() {ctx.currentTransform = undefined;});
+ // throws: TypeError: Failed to set the \'currentTransform\' property on \'CanvasRenderingContext2D\': The provided value is not of type \'SVGMatrix\'.
+ assert_throws(null, function() {ctx.currentTransform = null;});
+
+ ctx.fillStyle = 'red';
+ ctx.fillRect(0, 0, 100, 100);
+
+ function setCurrentTransformToNonfinite(ctx, a, b, c, d, e, f)
+ {
+ matrix.a = a;
+ matrix.b = b;
+ matrix.c = c;
+ matrix.d = d;
+ matrix.e = e;
+ matrix.f = f;
+ ctx.currentTransform = matrix;
+ matrix.a = NaN;
+ matrix.b = NaN;
+ matrix.c = NaN;
+ matrix.d = NaN;
+ matrix.e = NaN;
+ matrix.f = NaN;
+ matrix = ctx.currentTransform;
+ assert_equals(matrix.a, 1);
+ assert_equals(matrix.b, 0);
+ assert_equals(matrix.c, 0);
+ assert_equals(matrix.d, 1);
+ assert_equals(matrix.e, 100);
+ assert_equals(matrix.f, 10);
+ }
+
+ ctx.translate(100, 10);
+ matrix = ctx.currentTransform;
+ assert_equals(matrix.a, 1);
+ assert_equals(matrix.b, 0);
+ assert_equals(matrix.c, 0);
+ assert_equals(matrix.d, 1);
+ assert_equals(matrix.e, 100);
+ assert_equals(matrix.f, 10);
+ setCurrentTransformToNonfinite(ctx, Infinity, 0, 0, 0, 0, 0);
Justin Novosad 2017/02/08 18:23:33 this would be a really good place to use generate_
zakerinasab 2017/02/08 19:57:50 Done.
+ setCurrentTransformToNonfinite(ctx, -Infinity, 0, 0, 0, 0, 0);
+ setCurrentTransformToNonfinite(ctx, NaN, 0, 0, 0, 0, 0);
+ setCurrentTransformToNonfinite(ctx, 0, Infinity, 0, 0, 0, 0);
+ setCurrentTransformToNonfinite(ctx, 0, -Infinity, 0, 0, 0, 0);
+ setCurrentTransformToNonfinite(ctx, 0, NaN, 0, 0, 0, 0);
+ setCurrentTransformToNonfinite(ctx, 0, 0, Infinity, 0, 0, 0);
+ setCurrentTransformToNonfinite(ctx, 0, 0, -Infinity, 0, 0, 0);
+ setCurrentTransformToNonfinite(ctx, 0, 0, NaN, 0, 0, 0);
+ setCurrentTransformToNonfinite(ctx, 0, 0, 0, Infinity, 0, 0);
+ setCurrentTransformToNonfinite(ctx, 0, 0, 0, -Infinity, 0, 0);
+ setCurrentTransformToNonfinite(ctx, 0, 0, 0, NaN, 0, 0);
+ setCurrentTransformToNonfinite(ctx, 0, 0, 0, 0, Infinity, 0);
+ setCurrentTransformToNonfinite(ctx, 0, 0, 0, 0, -Infinity, 0);
+ setCurrentTransformToNonfinite(ctx, 0, 0, 0, 0, NaN, 0);
+ setCurrentTransformToNonfinite(ctx, 0, 0, 0, 0, 0, Infinity);
+ setCurrentTransformToNonfinite(ctx, 0, 0, 0, 0, 0, -Infinity);
+ setCurrentTransformToNonfinite(ctx, 0, 0, 0, 0, 0, NaN);
+ setCurrentTransformToNonfinite(ctx, Infinity, Infinity, 0, 0, 0, 0);
+ setCurrentTransformToNonfinite(ctx, Infinity, Infinity, Infinity, 0, 0, 0);
+ setCurrentTransformToNonfinite(ctx, Infinity, Infinity, Infinity, Infinity, 0, 0);
+ setCurrentTransformToNonfinite(ctx, Infinity, Infinity, Infinity, Infinity, Infinity, 0);
+ setCurrentTransformToNonfinite(ctx, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity);
+ setCurrentTransformToNonfinite(ctx, Infinity, Infinity, Infinity, Infinity, 0, Infinity);
+ setCurrentTransformToNonfinite(ctx, Infinity, Infinity, Infinity, 0, Infinity, 0);
+ setCurrentTransformToNonfinite(ctx, Infinity, Infinity, Infinity, 0, Infinity, Infinity);
+ setCurrentTransformToNonfinite(ctx, Infinity, Infinity, Infinity, 0, 0, Infinity);
+ setCurrentTransformToNonfinite(ctx, Infinity, Infinity, 0, Infinity, 0, 0);
+ setCurrentTransformToNonfinite(ctx, Infinity, Infinity, 0, Infinity, Infinity, 0);
+ setCurrentTransformToNonfinite(ctx, Infinity, Infinity, 0, Infinity, Infinity, Infinity);
+ setCurrentTransformToNonfinite(ctx, Infinity, Infinity, 0, Infinity, 0, Infinity);
+ setCurrentTransformToNonfinite(ctx, Infinity, Infinity, 0, 0, Infinity, 0);
+ setCurrentTransformToNonfinite(ctx, Infinity, Infinity, 0, 0, Infinity, Infinity);
+ setCurrentTransformToNonfinite(ctx, Infinity, Infinity, 0, 0, 0, Infinity);
+ setCurrentTransformToNonfinite(ctx, Infinity, 0, Infinity, 0, 0, 0);
+ setCurrentTransformToNonfinite(ctx, Infinity, 0, Infinity, Infinity, 0, 0);
+ setCurrentTransformToNonfinite(ctx, Infinity, 0, Infinity, Infinity, Infinity, 0);
+ setCurrentTransformToNonfinite(ctx, Infinity, 0, Infinity, Infinity, Infinity, Infinity);
+ setCurrentTransformToNonfinite(ctx, Infinity, 0, Infinity, Infinity, 0, Infinity);
+ setCurrentTransformToNonfinite(ctx, Infinity, 0, Infinity, 0, Infinity, 0);
+ setCurrentTransformToNonfinite(ctx, Infinity, 0, Infinity, 0, Infinity, Infinity);
+ setCurrentTransformToNonfinite(ctx, Infinity, 0, Infinity, 0, 0, Infinity);
+ setCurrentTransformToNonfinite(ctx, Infinity, 0, 0, Infinity, 0, 0);
+ setCurrentTransformToNonfinite(ctx, Infinity, 0, 0, Infinity, Infinity, 0);
+ setCurrentTransformToNonfinite(ctx, Infinity, 0, 0, Infinity, Infinity, Infinity);
+ setCurrentTransformToNonfinite(ctx, Infinity, 0, 0, Infinity, 0, Infinity);
+ setCurrentTransformToNonfinite(ctx, Infinity, 0, 0, 0, Infinity, 0);
+ setCurrentTransformToNonfinite(ctx, Infinity, 0, 0, 0, Infinity, Infinity);
+ setCurrentTransformToNonfinite(ctx, Infinity, 0, 0, 0, 0, Infinity);
+ setCurrentTransformToNonfinite(ctx, 0, Infinity, Infinity, 0, 0, 0);
+ setCurrentTransformToNonfinite(ctx, 0, Infinity, Infinity, Infinity, 0, 0);
+ setCurrentTransformToNonfinite(ctx, 0, Infinity, Infinity, Infinity, Infinity, 0);
+ setCurrentTransformToNonfinite(ctx, 0, Infinity, Infinity, Infinity, Infinity, Infinity);
+ setCurrentTransformToNonfinite(ctx, 0, Infinity, Infinity, Infinity, 0, Infinity);
+ setCurrentTransformToNonfinite(ctx, 0, Infinity, Infinity, 0, Infinity, 0);
+ setCurrentTransformToNonfinite(ctx, 0, Infinity, Infinity, 0, Infinity, Infinity);
+ setCurrentTransformToNonfinite(ctx, 0, Infinity, Infinity, 0, 0, Infinity);
+ setCurrentTransformToNonfinite(ctx, 0, Infinity, 0, Infinity, 0, 0);
+ setCurrentTransformToNonfinite(ctx, 0, Infinity, 0, Infinity, Infinity, 0);
+ setCurrentTransformToNonfinite(ctx, 0, Infinity, 0, Infinity, Infinity, Infinity);
+ setCurrentTransformToNonfinite(ctx, 0, Infinity, 0, Infinity, 0, Infinity);
+ setCurrentTransformToNonfinite(ctx, 0, Infinity, 0, 0, Infinity, 0);
+ setCurrentTransformToNonfinite(ctx, 0, Infinity, 0, 0, Infinity, Infinity);
+ setCurrentTransformToNonfinite(ctx, 0, Infinity, 0, 0, 0, Infinity);
+ setCurrentTransformToNonfinite(ctx, 0, 0, Infinity, Infinity, 0, 0);
+ setCurrentTransformToNonfinite(ctx, 0, 0, Infinity, Infinity, Infinity, 0);
+ setCurrentTransformToNonfinite(ctx, 0, 0, Infinity, Infinity, Infinity, Infinity);
+ setCurrentTransformToNonfinite(ctx, 0, 0, Infinity, Infinity, 0, Infinity);
+ setCurrentTransformToNonfinite(ctx, 0, 0, Infinity, 0, Infinity, 0);
+ setCurrentTransformToNonfinite(ctx, 0, 0, Infinity, 0, Infinity, Infinity);
+ setCurrentTransformToNonfinite(ctx, 0, 0, Infinity, 0, 0, Infinity);
+ setCurrentTransformToNonfinite(ctx, 0, 0, 0, Infinity, Infinity, 0);
+ setCurrentTransformToNonfinite(ctx, 0, 0, 0, Infinity, Infinity, Infinity);
+ setCurrentTransformToNonfinite(ctx, 0, 0, 0, Infinity, 0, Infinity);
+ setCurrentTransformToNonfinite(ctx, 0, 0, 0, 0, Infinity, Infinity);
+ matrix = ctx.currentTransform;
+ assert_equals(matrix.a, 1);
+ assert_equals(matrix.b, 0);
+ assert_equals(matrix.c, 0);
+ assert_equals(matrix.d, 1);
+ assert_equals(matrix.e, 100);
+ assert_equals(matrix.f, 10);
+
+ ctx.fillStyle = 'green';
+ ctx.fillRect(-100, -10, 100, 100);
+
+ imageData = ctx.getImageData(1, 1, 98, 98);
+ imgdata = imageData.data;
+ assert_equals(imgdata[4], 0);
+ assert_equals(imgdata[5], 128);
+ assert_equals(imgdata[6], 0);
+}, "Series of tests to ensure correct behaviour of canvas.currentTransform");
+</script>
</body>
-</html>

Powered by Google App Engine
This is Rietveld 408576698