Index: third_party/WebKit/LayoutTests/fast/canvas/pointInPath.html |
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/pointInPath.html b/third_party/WebKit/LayoutTests/fast/canvas/pointInPath.html |
index 8355c6dfb4af834d534103ca62eca03c5296de8d..7a151204421e28af53f28ce8f1d9f0775b0bcb5a 100644 |
--- a/third_party/WebKit/LayoutTests/fast/canvas/pointInPath.html |
+++ b/third_party/WebKit/LayoutTests/fast/canvas/pointInPath.html |
@@ -1,10 +1,71 @@ |
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
-<html> |
-<head> |
-<script src="../../resources/js-test.js"></script> |
-</head> |
-<body> |
-<canvas id="canvas"></canvas> |
-<script src="pointInPath.js"></script> |
-</body> |
-</html> |
+<script src="../../resources/testharness.js"></script> |
+<script src="../../resources/testharnessreport.js"></script> |
+<script> |
+test(function(){ |
+ |
+ ctx = document.createElement("canvas").getContext("2d"); |
+ ctx.save(); |
+ // Rectangle at (0,0) 20x20 |
+ ctx.rect(0, 0, 20, 20); |
+ assert_true(ctx.isPointInPath(5, 5)); |
+ assert_true(ctx.isPointInPath(10, 10)); |
+ assert_true(ctx.isPointInPath(19, 19)); |
+ assert_false(ctx.isPointInPath(30, 30)); |
+ assert_false(ctx.isPointInPath(-1, 10)); |
+ assert_false(ctx.isPointInPath(10, -1)); |
+ |
+ // Translate context (10,10) |
+ ctx.translate(10,10); |
+ assert_true(ctx.isPointInPath(5, 5)); |
+ assert_true(ctx.isPointInPath(10, 10)); |
+ assert_true(ctx.isPointInPath(19, 19)); |
+ assert_false(ctx.isPointInPath(30, 30)); |
+ assert_false(ctx.isPointInPath(-1, 10)); |
+ assert_false(ctx.isPointInPath(10, -1)); |
+ |
+ // Collapse ctm to non-invertible matrix |
+ ctx.scale(0,0); |
+ assert_false(ctx.isPointInPath(5, 5)); |
+ assert_false(ctx.isPointInPath(10, 10)); |
+ assert_false(ctx.isPointInPath(20, 20)); |
+ assert_false(ctx.isPointInPath(30, 30)); |
+ assert_false(ctx.isPointInPath(-1, 10)); |
+ assert_false(ctx.isPointInPath(10, -1)); |
+ // Resetting context to a clean state |
+ ctx.restore(); |
+ |
+ ctx.save(); |
+ ctx.beginPath(); |
+ // Translate context (10,10) |
+ ctx.translate(10,10); |
+ // Rectangle at (0,0) 20x20 |
+ ctx.rect(0, 0, 20, 20); |
+ assert_false(ctx.isPointInPath(5, 5)); |
+ assert_true(ctx.isPointInPath(10, 10)); |
+ assert_true(ctx.isPointInPath(20, 20)); |
+ assert_true(ctx.isPointInPath(29, 29)); |
+ assert_false(ctx.isPointInPath(-1, 10)); |
+ assert_false(ctx.isPointInPath(10, -1)); |
+ ctx.restore(); |
+ |
+ ctx.save(); |
+ ctx.beginPath(); |
+ // Translate context (10,20) |
+ ctx.translate(10,20); |
+ // Transform context (1, 0, 0, -1, 0, 0) |
+ ctx.transform(1, 0, 0, -1, 0, 0); |
+ // Rectangle at (0,0) 20x20 |
+ ctx.rect(0, 0, 20, 20); |
+ // After the flip, rect is actually 10, 0, 20, 20 |
+ assert_false(ctx.isPointInPath(5, 5)); |
+ assert_true(ctx.isPointInPath(10, 0)); |
+ assert_true(ctx.isPointInPath(29, 0)); |
+ assert_true(ctx.isPointInPath(10, 19)); |
+ assert_true(ctx.isPointInPath(21, 10)); |
+ assert_true(ctx.isPointInPath(29, 19)); |
+ ctx.strokeStyle = 'green'; |
+ ctx.stroke(); |
+ ctx.restore(); |
+ |
+}, "Series of tests for Canvas.isPointInPath"); |
+</script> |