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

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-ImageData-behaviour.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-ImageData-behaviour.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-ImageData-behaviour.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-ImageData-behaviour.html
index 81522056f80625255bf8f495d2c215402c76dc04..3870cb7682435bcaee9576548e7517dd7c17b0d2 100644
--- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-ImageData-behaviour.html
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-ImageData-behaviour.html
@@ -1,10 +1,34 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html>
-<head>
-<script src="../../resources/js-test.js"></script>
-</head>
-<body>
-<canvas id="canvas"></canvas>
-<script src="canvas-ImageData-behaviour.js"></script>
-</body>
-</html>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script>
+test(function(t){
+
+ imageData = document.createElement("canvas").getContext("2d").getImageData(0,0,2,2);
+
+ assert_equals(imageData.width, 2);
+ assert_equals(imageData.height, 2);
+ assert_equals(imageData.data.length, 16);
+ for (var i = 0; i < imageData.data.length; i++)
+ assert_equals(imageData.data[i], 0);
+
+ var testValues = [NaN, true, false, "\"garbage\"", "-1",
+ "0", "1", "2", Infinity, -Infinity,
+ -5, -0.5, 0, 0.5, 5,
+ 5.4, 255, 256, null, undefined];
+ var testResults = [0, 1, 0, 0, 0,
+ 0, 1, 2, 255, 0,
+ 0, 0, 0, 0, 5,
+ 5, 255, 255, 0, 0];
+ for (var i = 0; i < testValues.length; i++) {
+ imageData.data[0] = testValues[i];
+ assert_equals(imageData.data[0], testResults[i]);
+ }
+
+ imageData.data['foo']='garbage';
+ assert_equals(imageData.data['foo'], 'garbage');
+ imageData.data[-1]='garbage';
+ assert_equals(imageData.data[-1], undefined);
+ imageData.data[17]='garbage';
+ assert_equals(imageData.data[17], undefined);
+}, 'Series of tests to ensure correct behaviour of the ImageData object');
+</script>

Powered by Google App Engine
This is Rietveld 408576698