blob: 6549f1848f3de4c397c930aabd22cb98cbcd1efa [file] [log] [blame]
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body onload="run()">
<svg id="svg" xmlns="http://www.w3.org/2000/svg" width="200" height="200">
<polyline id="p1" points="0,0 150,0 150,100 0,100" fill="none" stroke="black" stroke-width="20" stroke-dashoffset="20" stroke-dasharray="20 20"/>
</svg>
<p id="description"></p>
<div id="console"></div>
<script type="text/javascript">
<![CDATA[
window.enablePixelTesting = false;
window.jsTestIsAsync = true;
var p1 = document.getElementById("p1");
function run() {
description("Test SVGGeometryElement APIs for polyline.");
debug("");
debug("Test isPointInFill()");
shouldBe("p1.isPointInFill({})", "true");
shouldBe("p1.isPointInFill({x: 100, y: 0})", "true");
shouldBe("p1.isPointInFill({x: 152, y: 0})", "false");
shouldBe("p1.isPointInFill({x: 150, y: 50})", "true");
shouldBe("p1.isPointInFill({x: 150, y: 100})", "true");
shouldBe("p1.isPointInFill({x: 150, y: 101})", "false");
shouldBe("p1.isPointInFill({x: 100, y: 100})", "true");
shouldBe("p1.isPointInFill({x: 75, y: 50})", "true");
debug("");
debug("Test isPointInStroke()");
shouldBe("p1.isPointInStroke({x: 0, y: 0})", "false");
shouldBe("p1.isPointInStroke({x: 20, y: 0})", "true");
shouldBe("p1.isPointInStroke({x: 150, y: 0})", "true");
shouldBe("p1.isPointInStroke({x: 150, y: 35})", "true");
shouldBe("p1.isPointInStroke({x: 75, y: 50})", "false");
debug("");
debug("Test getTotalLength()");
shouldBeCloseTo("p1.getTotalLength()", 400, 1);
debug("");
debug("Test getPointAtLength()");
shouldBeCloseTo("p1.getPointAtLength(0).x", 0, 0.1);
shouldBeCloseTo("p1.getPointAtLength(0).y", 0, 0.1);
shouldBeCloseTo("p1.getPointAtLength(150).x", 150, 0.1);
shouldBeCloseTo("p1.getPointAtLength(150).y", 0, 0.1);
shouldBeCloseTo("p1.getPointAtLength(200).x", 150, 0.1);
shouldBeCloseTo("p1.getPointAtLength(200).y", 50, 0.1);
shouldBeCloseTo("p1.getPointAtLength(300).x", 100, 0.1);
shouldBeCloseTo("p1.getPointAtLength(300).y", 100, 0.1);
shouldBeCloseTo("p1.getPointAtLength(450).x", 0, 0.1);
shouldBeCloseTo("p1.getPointAtLength(450).y", 100, 0.1);
finishJSTest();
}
]]>
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>