blob: f83f9a2e51d7aa60dca1a280bb47d7ae8b71ddfc [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">
<rect id="r1" rx="50" ry="40" width="150" height="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 r1 = document.getElementById("r1");
function run() {
description("Test SVGGeometryElement APIs for rect.");
debug("");
debug("Test isPointInFill()");
shouldBe("r1.isPointInFill({})", "false");
shouldBe("r1.isPointInFill({x: 48, y: 0})", "false");
shouldBe("r1.isPointInFill({x: 52, y: 0})", "true");
shouldBe("r1.isPointInFill({x: 98, y: 0})", "true");
shouldBe("r1.isPointInFill({x: 102, y: 0})", "false");
shouldBe("r1.isPointInFill({x: 150, y: 38})", "false");
shouldBe("r1.isPointInFill({x: 150, y: 42})", "true");
shouldBe("r1.isPointInFill({x: 150, y: 58})", "true");
shouldBe("r1.isPointInFill({x: 150, y: 62})", "false");
shouldBe("r1.isPointInFill({x: 48, y: 100})", "false");
shouldBe("r1.isPointInFill({x: 52, y: 100})", "true");
shouldBe("r1.isPointInFill({x: 98, y: 100})", "true");
shouldBe("r1.isPointInFill({x: 102, y: 100})", "false");
shouldBe("r1.isPointInFill({x: 0, y: 38})", "false");
shouldBe("r1.isPointInFill({x: 0, y: 42})", "true");
shouldBe("r1.isPointInFill({x: 0, y: 58})", "true");
shouldBe("r1.isPointInFill({x: 0, y: 62})", "false");
shouldBe("r1.isPointInFill({x: 75, y: 50})", "true");
debug("");
debug("Test isPointInStroke()");
shouldBe("r1.isPointInStroke({x: 52, y: 0})", "false");
shouldBe("r1.isPointInStroke({x: 72, y: 0})", "true");
shouldBe("r1.isPointInStroke({x: 92, y: 0})", "false");
shouldBe("r1.isPointInStroke({x: 112, y: 10})", "true");
debug("");
debug("Test getTotalLength()");
shouldBeCloseTo("r1.getTotalLength()", 424, 1);
debug("");
debug("Test getPointAtLength()");
shouldBeCloseTo("r1.getPointAtLength(0).x", 50, 1);
shouldBeCloseTo("r1.getPointAtLength(0).y", 0, 1);
shouldBeCloseTo("r1.getPointAtLength(25).x", 75, 1);
shouldBeCloseTo("r1.getPointAtLength(25).y", 0, 1);
shouldBeCloseTo("r1.getPointAtLength(200).x", 112, 3);
shouldBeCloseTo("r1.getPointAtLength(200).y", 100, 3);
shouldBeCloseTo("r1.getPointAtLength(300).x", 14, 3);
shouldBeCloseTo("r1.getPointAtLength(300).y", 88, 3);
shouldBeCloseTo("r1.getPointAtLength(400).x", 27, 3);
shouldBeCloseTo("r1.getPointAtLength(400).y", 5, 3);
finishJSTest();
}
]]>
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>