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

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

Issue 2694703004: Use testharness.js instead of js-test.js in LayoutTests/fast/canvas tests. (Closed)
Patch Set: 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-path-addpath.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-path-addpath.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-path-addpath.html
index ea354b0ee62a5b62c556ae6695c8eda56ec2a0be..154ec2ba02c12f21e45d7f357a641bc832da9243 100644
--- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-path-addpath.html
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-path-addpath.html
@@ -1,9 +1,80 @@
-<!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-path-addpath.js"></script>
+<script>
+test(function(t) {
+ var canvas = document.createElement('canvas');
+ var ctx = canvas.getContext('2d');
+
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+ ctx.beginPath();
+ var p1 = new Path2D();
+ p1.rect(0,0,100,100);
+ var p2 = new Path2D();
+ p2.rect(0,100,100,100);
+ var m = ctx.currentTransform;
+ p1.addPath(p2, m);
+ ctx.fillStyle = 'yellow';
+ ctx.fill(p1);
+ assert_array_equals(ctx.getImageData(1, 100, 1, 1).data, [255, 255, 0, 255]);
+
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+ ctx.beginPath();
+ var p3 = new Path2D();
+ p3.rect(0,0,100,100);
+ var p4 = new Path2D();
+ p4.rect(0,100,100,100);
+ m.a = 1; m.b = 0;
+ m.c = 0; m.d = 1;
+ m.e = 100; m.f = -100;
+ p3.addPath(p4, m);
+ ctx.fillStyle = 'yellow';
+ ctx.fill(p3);
+ assert_array_equals(ctx.getImageData(101, 0, 1, 1).data, [255, 255, 0, 255]);
+
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+ ctx.beginPath();
+ var p5 = new Path2D();
+ p5.rect(0,0,100,100);
+ var p6 = new Path2D();
+ p6.rect(100,100,100,100);
+ m.a = 0; m.b = 0;
+ m.c = 0; m.d = 0;
+ m.e = 0; m.f = 0;
+ p5.addPath(p6, m);
+ ctx.fillStyle = 'yellow';
+ ctx.fill(p5);
+ assert_array_equals(ctx.getImageData(101, 100, 1, 1).data, [0, 0, 0, 0]);
+
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+ ctx.beginPath();
+ var p7 = new Path2D();
+ p7.rect(0,0,100,100);
+ var p8 = new Path2D();
+ p8.rect(100,100,100,100);
+ p7.addPath(p8, null);
+ assert_throws(null, function() {p7.addPath(p8, []);});
+ assert_throws(null, function() {p7.addPath(p8, {});});
+ ctx.fillStyle = 'red';
+ ctx.fill(p7);
+ assert_array_equals(ctx.getImageData(101, 100, 1, 1).data, [255, 0, 0, 255]);
+
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+ ctx.beginPath();
+ var p9 = new Path2D();
+ var p10 = new Path2D();
+ p9.rect(0,0,10,10);
+ p10.addPath(p9);
+ ctx.fillStyle = 'red';
+ ctx.fill(p10);
+ assert_array_equals(ctx.getImageData(1, 1, 1, 1).data, [255, 0, 0, 255]);
+
+ var p9 = new Path2D();
+ p9.rect(0,0,100,100);
+ assert_throws(null, function() {p7.addPath(null, m);});
+ assert_throws(null, function() {p7.addPath([], m);});
+ assert_throws(null, function() {p7.addPath({}, m);});
+
+}, "Test addPath() method.");
+</script>
</body>
-</html>

Powered by Google App Engine
This is Rietveld 408576698