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

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

Issue 2679083003: Use testharness.js instead of js-test.js in LayoutTests/fast/canvas tests. (Closed)
Patch Set: Adding virtual/gpu/fast/canvas/canvas-imageSmoothingQuality.html to TestExpectations 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-imageSmoothingEnabled.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-imageSmoothingEnabled.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-imageSmoothingEnabled.html
index d9004064bd0626e2863b512a157ab5db97ecc9de..4e43cd70d873b095806c17da817913cecd743410 100644
--- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-imageSmoothingEnabled.html
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-imageSmoothingEnabled.html
@@ -1,9 +1,72 @@
-<!DOCTYPE html>
-<html>
-<head>
- <script src="../../resources/js-test.js"></script>
-</head>
-<body>
- <script src="script-tests/canvas-imageSmoothingEnabled.js"></script>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script>
+test(function(t) {
+
+var ctx = document.createElement('canvas').getContext('2d');
+ assert_equals(ctx.imageSmoothingEnabled, true);
+
+ ctx.imageSmoothingEnabled = false;
+ assert_equals(ctx.imageSmoothingEnabled, false);
+
+ ctx.save();
+ ctx.imageSmoothingEnabled = true;
+ ctx.restore();
+ assert_equals(ctx.imageSmoothingEnabled, false);
+
+ var image = document.createElement('canvas');
+ image.width = 2;
+ image.height = 1;
+
+ // We use this to color the individual pixels
+ var dotter = ctx.createImageData(1, 1);
+
+ // Color the left pixel black.
+ dotter.data.fill(0);
+ dotter.data[3] = 255;
+ image.getContext('2d').putImageData(dotter, 0, 0);
+
+ // Color the right pixel white.
+ dotter.data.fill(255);
+ image.getContext('2d').putImageData(dotter, 1, 0);
+
+ var canvas = document.createElement('canvas');
+ canvas.width = 4;
+ canvas.height = 1;
+ ctx = canvas.getContext('2d');
+ ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
+ left_of_center_pixel = ctx.getImageData(1, 0, 1, 1);
+
+ assert_not_equals(left_of_center_pixel.data[0], 0);
+ assert_not_equals(left_of_center_pixel.data[1], 0);
+ assert_not_equals(left_of_center_pixel.data[2], 0);
+
+ ctx.imageSmoothingEnabled = false;
+ ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
+ left_of_center_pixel = ctx.getImageData(1, 0, 1, 1);
+
+ assert_equals(left_of_center_pixel.data[0], 0);
+ assert_equals(left_of_center_pixel.data[1], 0);
+ assert_equals(left_of_center_pixel.data[2], 0);
+
+ ctx.imageSmoothingEnabled = true;
+ ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
+ left_of_center_pixel = ctx.getImageData(1, 0, 1, 1);
+
+ assert_not_equals(left_of_center_pixel.data[0], 0);
+ assert_not_equals(left_of_center_pixel.data[1], 0);
+ assert_not_equals(left_of_center_pixel.data[2], 0);
+
+ ctx.imageSmoothingEnabled = false;
+ ctx.save();
+ ctx.imageSmoothingEnabled = true;
+ ctx.restore();
+ ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
+ left_of_center_pixel = ctx.getImageData(1, 0, 1, 1);
+ assert_equals(left_of_center_pixel.data[0], 0);
+ assert_equals(left_of_center_pixel.data[1], 0);
+ assert_equals(left_of_center_pixel.data[2], 0);
+
+ }, "Tests for the imageSmoothingEnabled attribute.");
+</script>
</body>
-</html>

Powered by Google App Engine
This is Rietveld 408576698