blob: 75ed9917954d00ceaac3fb370893019b43c0ec8f [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="10,10 160,10 160,110 10,110" fill="none" stroke="black" stroke-width="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()");
shouldBeFalse("p1.isPointInFill({})");
shouldBeFalse("p1.isPointInFill({x: 9, y: 9})");
shouldBeTrue("p1.isPointInFill({x: 10, y: 10})");
shouldBeFalse("p1.isPointInFill({x: 159, y: 9})");
shouldBeTrue("p1.isPointInFill({x: 160, y: 10})");
shouldBeFalse("p1.isPointInFill({x: 161, y: 110})");
shouldBeTrue("p1.isPointInFill({x: 160, y: 109})");
shouldBeFalse("p1.isPointInFill({x: 9, y: 109})");
shouldBeTrue("p1.isPointInFill({x: 10, y: 110})");
debug("");
debug("Test isPointInStroke()");
shouldBeTrue("p1.isPointInStroke({x: 20, y: 20})");
shouldBeFalse("p1.isPointInStroke({x: 21, y: 21})");
shouldBeTrue("p1.isPointInStroke({x: 150, y: 20})");
shouldBeFalse("p1.isPointInStroke({x: 149, y: 21})");
shouldBeTrue("p1.isPointInStroke({x: 150, y: 100})");
shouldBeFalse("p1.isPointInStroke({x: 149, y: 99})");
shouldBeTrue("p1.isPointInStroke({x: 20, y: 100})");
shouldBeFalse("p1.isPointInStroke({x: 21, y: 99})");
debug("");
debug("Test getTotalLength()");
shouldBeCloseTo("p1.getTotalLength()", 400, 1);
debug("");
debug("Test getPointAtLength()");
shouldBeCloseTo("p1.getPointAtLength(0).x", 10, 0.1);
shouldBeCloseTo("p1.getPointAtLength(0).y", 10, 0.1);
shouldBeCloseTo("p1.getPointAtLength(150).x", 160, 0.1);
shouldBeCloseTo("p1.getPointAtLength(150).y", 10, 0.1);
shouldBeCloseTo("p1.getPointAtLength(200).x", 160, 0.1);
shouldBeCloseTo("p1.getPointAtLength(200).y", 60, 0.1);
shouldBeCloseTo("p1.getPointAtLength(300).x", 110, 0.1);
shouldBeCloseTo("p1.getPointAtLength(300).y", 110, 0.1);
shouldBeCloseTo("p1.getPointAtLength(450).x", 10, 0.1);
shouldBeCloseTo("p1.getPointAtLength(450).y", 110, 0.1);
finishJSTest();
}
]]>
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>