blob: 433607bf373dd4259072c6f185d1d8947f1bd8b0 [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">
<polygon 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 polygon.");
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()", 500, 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(250).x", 160, 0.1);
shouldBeCloseTo("p1.getPointAtLength(250).y", 110, 0.1);
shouldBeCloseTo("p1.getPointAtLength(400).x", 10, 0.1);
shouldBeCloseTo("p1.getPointAtLength(400).y", 110, 0.1);
shouldBeCloseTo("p1.getPointAtLength(500).x", 10, 0.1);
shouldBeCloseTo("p1.getPointAtLength(500).y", 10, 0.1);
finishJSTest();
}
]]>
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>