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

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-pattern-set-transform.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-pattern-set-transform.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-pattern-set-transform.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-pattern-set-transform.html
index d870d6090ca7fc35ac7d4ac1b76a64b7145b7533..25f0c6f11b71d7b0f34188704b3127e502f80db0 100644
--- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-pattern-set-transform.html
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-pattern-set-transform.html
@@ -1,9 +1,47 @@
-<!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-pattern-set-transform.js"></script>
+<script>
+function fillWithColor(context, canvas, color1, color2) {
+ context.save();
+ context.fillStyle = color1;
+ context.fillRect(0, 0, canvas.width / 2, canvas.height);
+ context.fillStyle = color2;
+ context.fillRect(canvas.width / 2, 0, canvas.width / 2, canvas.height);
+ context.restore();
+}
+
+test(function(t) {
+
+ var canvas = document.createElement("canvas");
+ canvas.height = 100;
+ canvas.width = 100;
+ canvas.style.height = "100";
+ canvas.style.width = "100";
+
+ document.body.appendChild(canvas);
+
+ var patternImage = document.createElement("canvas");
+ patternImage.height = 10;
+ patternImage.width = 20;
+ var patternImageCtx = patternImage.getContext('2d');
+ fillWithColor(patternImageCtx, patternImage, "red", "green");
+ var greenPixel = patternImageCtx.getImageData(10, 0, 1, 1).data;
+
+ var ctx = canvas.getContext('2d');
+ var pattern = ctx.createPattern(patternImage, "repeat-x");
+ var svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg");
+ var matrix = svgElement.createSVGMatrix();
+ matrix = matrix.translate(10, 0);
+ pattern.setTransform(matrix);
+
+ fillWithColor(ctx, canvas, "blue", "blue");
+
+ ctx.fillStyle = pattern;
+ ctx.translate(20, 20);
+ ctx.fillRect(0, 0, 10, 10);
+ assert_array_equals(ctx.getImageData(20, 20, 1, 1).data, greenPixel);
+
+}, "Test for supporting setTransform on canvas patterns");
+</script>
</body>
-</html>

Powered by Google App Engine
This is Rietveld 408576698