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

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-pattern-modify.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-modify.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-pattern-modify.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-pattern-modify.html
index 8a5e616d3d152ad9d57ef097fad66aff3704e1d3..412077f71a7caeac02d1e705e88f673e90a248e4 100644
--- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-pattern-modify.html
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-pattern-modify.html
@@ -1,2 +1,40 @@
-<script src="../../resources/js-test.js"></script>
-<script src="canvas-pattern-modify.js"></script>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script>
+// Based on http://philip.html5.org/tests/canvas/suite/tests/2d.pattern.modify.canvas1.html
+
+function pixelShouldBe(ctx, x, y, color) {
+ assert_array_equals(ctx.getImageData(x, y, 1, 1).data, color);
+}
+
+function createCanvasImage(width, height, color) {
+ var c = document.createElement("canvas");
+ c.width = width;
+ c.height = height;
+ var context = c.getContext("2d");
+ context.fillStyle = color;
+ context.fillRect(0, 0, width, height);
+ return c;
+}
+
+test(function(t) {
+ var canvas = createCanvasImage(100, 50, '#fff');
+ var ctx = canvas.getContext('2d');
+
+ var patternCanvas = createCanvasImage(100, 50, '#0f0');
+ var pattern = ctx.createPattern(patternCanvas, 'no-repeat');
+
+ // Modify the original canvas after we create a pattern.
+ var patternCtx = patternCanvas.getContext('2d');
+ patternCtx.fillStyle = '#f00';
+ patternCtx.fillRect(0, 0, 100, 50);
+
+ ctx.fillStyle = pattern;
+ ctx.fillRect(0, 0, 100, 50);
+
+ pixelShouldBe(ctx, 1, 1, [0, 255, 0, 255]);
+ pixelShouldBe(ctx, 98, 1, [0, 255, 0, 255]);
+ pixelShouldBe(ctx, 1, 48, [0, 255, 0, 255]);
+ pixelShouldBe(ctx, 98, 48, [0, 255, 0, 255]);
+}, "This test checks if pattern changes after the source canvas is modified. See https://bugs.webkit.org/show_bug.cgi?id=20578 .");
+</script>

Powered by Google App Engine
This is Rietveld 408576698