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

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

Issue 2693193003: 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-setTransform.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-setTransform.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-setTransform.html
index 997802085d625ab8a2009b21fde3ed3ea7533534..3819827b01b2be5e1b96c5fc0dab2dc8c400a5ff 100644
--- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-setTransform.html
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-setTransform.html
@@ -1,9 +1,73 @@
-<!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-setTransform.js"></script>
+<script>
+var ctx = document.createElement('canvas').getContext('2d');
+
+function checkPixel(x, y, rgb) {
+ assert_array_equals(ctx.getImageData(x, y, 1, 1).data.slice(0,3), rgb);
+}
+
+test(function(t) {
+
+ ctx.beginPath();
+ ctx.scale(0.5, 0.5);
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
+ ctx.fillStyle = 'green';
+ ctx.fillRect(0, 0, 100, 100);
+ checkPixel(2, 1, [0, 128, 0]);
+
+ ctx.beginPath();
+ ctx.rect(0, 0, 100, 100);
+ ctx.save();
+ ctx.setTransform(0.5, 0, 0, 0.5, 10, 10);
+ ctx.fillStyle = 'red';
+ ctx.fillRect(0, 0, 100, 100);
+ ctx.restore();
+ ctx.fillStyle = 'green';
+ ctx.fillRect(0, 0, 100, 100);
+ checkPixel(2, 1, [0, 128, 0]);
+
+ ctx.beginPath();
+ ctx.fillStyle = 'green';
+ ctx.save();
+ ctx.setTransform(0.5, 0, 0, 0.5, 0, 0);
+ ctx.fillStyle = 'red';
+ ctx.fillRect(0, 0, 100, 100);
+ ctx.restore();
+ ctx.fillRect(0, 0, 100, 100);
+ checkPixel(2, 1, [0, 128, 0]);
+
+ ctx.beginPath();
+ ctx.fillStyle = 'green';
+ ctx.fillRect(0, 0, 100, 100);
+ ctx.setTransform(0, 0, 0, 0, 0, 0);
+ ctx.fillStyle = 'red';
+ ctx.fillRect(0, 0, 100, 100);
+ checkPixel(2, 1, [0, 128, 0]);
+
+ ctx.beginPath();
+ ctx.resetTransform();
+ ctx.save();
+ ctx.setTransform(0, 0, 0, 0, 0, 0);
+ ctx.fillStyle = 'red';
+ ctx.fillRect(0, 0, 100, 100);
+ ctx.restore();
+ ctx.fillStyle = 'blue';
+ ctx.fillRect(0, 0, 100, 100);
+ checkPixel(2, 1, [0, 0, 255]);
+
+ ctx.beginPath();
+ ctx.fillStyle = 'red';
+ ctx.fillRect(0, 0, 100, 100);
+ ctx.setTransform(0, 0, 0, 0, 0, 0);
+ ctx.fillStyle = 'green';
+ ctx.fillRect(0, 0, 100, 100);
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
+ ctx.fillStyle = 'blue';
+ ctx.fillRect(0, 0, 100, 100);
+ checkPixel(2, 1, [0, 0, 255]);
+
+}, "Series of tests to ensure correct behaviour of canvas.setTransform()");
+</script>
</body>
-</html>

Powered by Google App Engine
This is Rietveld 408576698