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

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-save-restore-with-path.html

Issue 2696023002: Use testharness.js instead of js-test.js in LayoutTests/fast/canvas tests. (Closed)
Patch Set: Rebaseline 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-save-restore-with-path.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-save-restore-with-path.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-save-restore-with-path.html
index 41589b16f6100d8fa7a88718954e72f56a98c38d..ef6ddccbbcb5e29d66fe12226c0656981e2b0446 100644
--- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-save-restore-with-path.html
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-save-restore-with-path.html
@@ -1,2 +1,57 @@
-<script src="../../resources/js-test.js"></script>
-<script src="canvas-save-restore-with-path.js"></script>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script>
+test(function(t) {
+}, "This test ensures that paths are correctly handled over save/restore boundaries");
+
+function pixelShouldBe(x, y, color) {
+ assert_array_equals(context.getImageData(x, y, 1, 1).data, color);
+}
+
+var canvas = document.createElement("canvas");
+canvas.width = 100;
+canvas.height = 100;
+
+var context = canvas.getContext("2d");
+context.fillStyle = "red";
+context.fillRect(0, 0, 100, 100);
+context.fillStyle = "green";
+
+// Test translate
+context.beginPath();
+context.save();
+context.translate(100, 100);
+context.rect(-100, -100, 50, 50);
+context.restore();
+context.fill();
+pixelShouldBe(25, 25, [0, 128, 0, 255]);
+
+// Test scale
+context.beginPath();
+context.save();
+context.scale(2, 2);
+context.rect(25, 0, 25, 25);
+context.restore();
+context.fill();
+pixelShouldBe(75, 25, [0, 128, 0, 255]);
+pixelShouldBe(75, 75, [255, 0, 0, 255]);
+
+// Test rotate
+context.beginPath();
+context.save();
+context.rotate(90/180 * Math.PI);
+context.rect(50, -50, 50, 50);
+context.restore();
+context.fill();
+pixelShouldBe(25, 75, [0, 128, 0, 255]);
+pixelShouldBe(75, 75, [255, 0, 0, 255]);
+
+// Test transform
+context.beginPath();
+context.save();
+context.transform(1, 0, 0, 1, 50, 50);
+context.rect(0, 0, 50, 50);
+context.restore();
+context.fill();
+pixelShouldBe(75, 75, [0, 128, 0, 255]);
+</script>

Powered by Google App Engine
This is Rietveld 408576698