Chromium Code Reviews| 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..dd927cc9b81f372e66e18215d220b524474e66fa 100644 |
| --- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-currentTransform.html |
| +++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-currentTransform.html |
| @@ -1,9 +1,329 @@ |
| -<!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(parameters) |
| + { |
| + ctx = parameters[0]; |
| + matrix.a = parameters[1]; |
| + matrix.b = parameters[2]; |
| + matrix.c = parameters[3]; |
| + matrix.d = parameters[4]; |
| + matrix.e = parameters[5]; |
| + matrix.f = parameters[6]; |
| + 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); |
| + |
| + testScenarios = [ |
| + ['', [ctx, Infinity, 0, 0, 0, 0, 0]], |
|
Justin Novosad
2017/02/08 20:19:29
The scenarios should have names so that a reported
zakerinasab
2017/02/09 15:39:50
Done.
|
| + ['', [ctx, -Infinity, 0, 0, 0, 0, 0]], |
| + ['', [ctx, NaN, 0, 0, 0, 0, 0]], |
| + ['', [ctx, 0, Infinity, 0, 0, 0, 0]], |
| + ['', [ctx, 0, -Infinity, 0, 0, 0, 0]], |
| + ['', [ctx, 0, NaN, 0, 0, 0, 0]], |
| + ['', [ctx, 0, 0, Infinity, 0, 0, 0]], |
| + ['', [ctx, 0, 0, -Infinity, 0, 0, 0]], |
| + ['', [ctx, 0, 0, NaN, 0, 0, 0]], |
| + ['', [ctx, 0, 0, 0, Infinity, 0, 0]], |
| + ['', [ctx, 0, 0, 0, -Infinity, 0, 0]], |
| + ['', [ctx, 0, 0, 0, NaN, 0, 0]], |
| + ['', [ctx, 0, 0, 0, 0, Infinity, 0]], |
| + ['', [ctx, 0, 0, 0, 0, -Infinity, 0]], |
| + ['', [ctx, 0, 0, 0, 0, NaN, 0]], |
| + ['', [ctx, 0, 0, 0, 0, 0, Infinity]], |
| + ['', [ctx, 0, 0, 0, 0, 0, -Infinity]], |
| + ['', [ctx, 0, 0, 0, 0, 0, NaN]], |
| + ['', [ctx, Infinity, Infinity, 0, 0, 0, 0]], |
| + ['', [ctx, Infinity, Infinity, Infinity, 0, 0, 0]], |
| + ['', [ctx, Infinity, Infinity, Infinity, Infinity, 0, 0]], |
| + ['', [ctx, Infinity, Infinity, Infinity, Infinity, Infinity, 0]], |
| + ['', [ctx, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity]], |
| + ['', [ctx, Infinity, Infinity, Infinity, Infinity, 0, Infinity]], |
| + ['', [ctx, Infinity, Infinity, Infinity, 0, Infinity, 0]], |
| + ['', [ctx, Infinity, Infinity, Infinity, 0, Infinity, Infinity]], |
| + ['', [ctx, Infinity, Infinity, Infinity, 0, 0, Infinity]], |
| + ['', [ctx, Infinity, Infinity, 0, Infinity, 0, 0]], |
| + ['', [ctx, Infinity, Infinity, 0, Infinity, Infinity, 0]], |
| + ['', [ctx, Infinity, Infinity, 0, Infinity, Infinity, Infinity]], |
| + ['', [ctx, Infinity, Infinity, 0, Infinity, 0, Infinity]], |
| + ['', [ctx, Infinity, Infinity, 0, 0, Infinity, 0]], |
| + ['', [ctx, Infinity, Infinity, 0, 0, Infinity, Infinity]], |
| + ['', [ctx, Infinity, Infinity, 0, 0, 0, Infinity]], |
| + ['', [ctx, Infinity, 0, Infinity, 0, 0, 0]], |
| + ['', [ctx, Infinity, 0, Infinity, Infinity, 0, 0]], |
| + ['', [ctx, Infinity, 0, Infinity, Infinity, Infinity, 0]], |
| + ['', [ctx, Infinity, 0, Infinity, Infinity, Infinity, Infinity]], |
| + ['', [ctx, Infinity, 0, Infinity, Infinity, 0, Infinity]], |
| + ['', [ctx, Infinity, 0, Infinity, 0, Infinity, 0]], |
| + ['', [ctx, Infinity, 0, Infinity, 0, Infinity, Infinity]], |
| + ['', [ctx, Infinity, 0, Infinity, 0, 0, Infinity]], |
| + ['', [ctx, Infinity, 0, 0, Infinity, 0, 0]], |
| + ['', [ctx, Infinity, 0, 0, Infinity, Infinity, 0]], |
| + ['', [ctx, Infinity, 0, 0, Infinity, Infinity, Infinity]], |
| + ['', [ctx, Infinity, 0, 0, Infinity, 0, Infinity]], |
| + ['', [ctx, Infinity, 0, 0, 0, Infinity, 0]], |
| + ['', [ctx, Infinity, 0, 0, 0, Infinity, Infinity]], |
| + ['', [ctx, Infinity, 0, 0, 0, 0, Infinity]], |
| + ['', [ctx, 0, Infinity, Infinity, 0, 0, 0]], |
| + ['', [ctx, 0, Infinity, Infinity, Infinity, 0, 0]], |
| + ['', [ctx, 0, Infinity, Infinity, Infinity, Infinity, 0]], |
| + ['', [ctx, 0, Infinity, Infinity, Infinity, Infinity, Infinity]], |
| + ['', [ctx, 0, Infinity, Infinity, Infinity, 0, Infinity]], |
| + ['', [ctx, 0, Infinity, Infinity, 0, Infinity, 0]], |
| + ['', [ctx, 0, Infinity, Infinity, 0, Infinity, Infinity]], |
| + ['', [ctx, 0, Infinity, Infinity, 0, 0, Infinity]], |
| + ['', [ctx, 0, Infinity, 0, Infinity, 0, 0]], |
| + ['', [ctx, 0, Infinity, 0, Infinity, Infinity, 0]], |
| + ['', [ctx, 0, Infinity, 0, Infinity, Infinity, Infinity]], |
| + ['', [ctx, 0, Infinity, 0, Infinity, 0, Infinity]], |
| + ['', [ctx, 0, Infinity, 0, 0, Infinity, 0]], |
| + ['', [ctx, 0, Infinity, 0, 0, Infinity, Infinity]], |
| + ['', [ctx, 0, Infinity, 0, 0, 0, Infinity]], |
| + ['', [ctx, 0, 0, Infinity, Infinity, 0, 0]], |
| + ['', [ctx, 0, 0, Infinity, Infinity, Infinity, 0]], |
| + ['', [ctx, 0, 0, Infinity, Infinity, Infinity, Infinity]], |
| + ['', [ctx, 0, 0, Infinity, Infinity, 0, Infinity]], |
| + ['', [ctx, 0, 0, Infinity, 0, Infinity, 0]], |
| + ['', [ctx, 0, 0, Infinity, 0, Infinity, Infinity]], |
| + ['', [ctx, 0, 0, Infinity, 0, 0, Infinity]], |
| + ['', [ctx, 0, 0, 0, Infinity, Infinity, 0]], |
| + ['', [ctx, 0, 0, 0, Infinity, Infinity, Infinity]], |
| + ['', [ctx, 0, 0, 0, Infinity, 0, Infinity]], |
| + ['', [ctx, 0, 0, 0, 0, Infinity, Infinity]] |
| + ] |
| + generate_tests(setCurrentTransformToNonfinite, testScenarios); |
| + |
| + 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> |