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

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/drawImage-with-negative-source-destination.html

Issue 2700823002: 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/drawImage-with-negative-source-destination.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/drawImage-with-negative-source-destination.html b/third_party/WebKit/LayoutTests/fast/canvas/drawImage-with-negative-source-destination.html
index ad0dbc6ad33b4a557fde1f27b8ab405261cf3c3b..3d866ef2dfc1c4b7aa637283f499171fded56d90 100644
--- a/third_party/WebKit/LayoutTests/fast/canvas/drawImage-with-negative-source-destination.html
+++ b/third_party/WebKit/LayoutTests/fast/canvas/drawImage-with-negative-source-destination.html
@@ -1,13 +1,38 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<!-- Test based on that found at
http://philip.html5.org/tests/canvas/suite/tests/2d.drawImage.negativesource.html
-->
-<html>
-<head>
-<script src="../../resources/js-test.js"></script>
-</head>
-<body>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
<canvas id="canvas" width="100" height="100"></canvas>
-<script src="drawImage-with-negative-source-destination.js"></script>
-</body>
-</html>
+<script>
+
+test(function(){
+
+ var canvas2 = document.createElement('canvas');
+ canvas2.width = 100;
+ canvas2.height = 100;
+ var ctx2 = canvas2.getContext('2d');
+ ctx2.fillStyle = '#f00';
+ ctx2.fillRect(0, 0, 100, 50);
+ ctx2.fillStyle = '#0f0';
+ ctx2.fillRect(0, 50, 100, 50);
+
+ var canvas = document.getElementById('canvas').getContext('2d');
+ canvas.drawImage(canvas2, 100, 50, -50, 50, 0, 0, 50, 50);
+ canvas.drawImage(canvas2, 100, 100, -50, -50, 0, 100, 50, -50);
+ canvas.drawImage(canvas2, 0, 100, 100, -50, 100, 100, -50, -50);
+ canvas.drawImage(canvas2, 0, 50, 100, 50, 100, 0, -50, 50);
+
+ var imageData = canvas.getImageData(1, 0, 1, 1).data;
+ assert_array_equals(imageData.slice(0,3), [0, 255, 0]);
+
+ // test width or height -1
+ canvas.fillStyle = '#000';
+ canvas.fillRect(0, 0, 1, 2);
+ canvas.drawImage(canvas2, 0, 0, 1, 1, 1, 1, -1, -1);
+ var imageData = canvas.getImageData(0, 0, 1, 2).data;
+ assert_array_equals(imageData.slice(0,3), [255, 0, 0]);
+ assert_array_equals(imageData.slice(4,7), [0, 0, 0]);
+
+}, "Series of tests to ensure correct behaviour on negative source/destination of a HTMLCanvasElement");
+</script>

Powered by Google App Engine
This is Rietveld 408576698