blob: f0e246d82ef2ac149c36c7c682bd67f81310c88b [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" x="10" y="10" width="150" height="100" 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 r1 = document.getElementById("r1");
function run() {
description("Test SVGGeometryElement APIs for rect.");
debug("");
debug("Test isPointInFill()");
shouldBeFalse("r1.isPointInFill({})");
shouldBeFalse("r1.isPointInFill({x: 9, y: 9})");
shouldBeTrue("r1.isPointInFill({x: 10, y: 10})");
shouldBeFalse("r1.isPointInFill({x: 159, y: 9})");
shouldBeTrue("r1.isPointInFill({x: 160, y: 10})");
shouldBeFalse("r1.isPointInFill({x: 161, y: 110})");
shouldBeTrue("r1.isPointInFill({x: 160, y: 109})");
shouldBeFalse("r1.isPointInFill({x: 9, y: 109})");
shouldBeTrue("r1.isPointInFill({x: 10, y: 110})");
debug("");
debug("Test isPointInStroke()");
shouldBeTrue("r1.isPointInStroke({x: 20, y: 20})");
shouldBeFalse("r1.isPointInStroke({x: 21, y: 21})");
shouldBeTrue("r1.isPointInStroke({x: 150, y: 20})");
shouldBeFalse("r1.isPointInStroke({x: 149, y: 21})");
shouldBeTrue("r1.isPointInStroke({x: 150, y: 100})");
shouldBeFalse("r1.isPointInStroke({x: 149, y: 99})");
shouldBeTrue("r1.isPointInStroke({x: 20, y: 100})");
shouldBeFalse("r1.isPointInStroke({x: 21, y: 99})");
debug("");
debug("Test getTotalLength()");
shouldBeCloseTo("r1.getTotalLength()", 500, 0.1);
debug("");
debug("Test getPointAtLength()");
shouldBeCloseTo("r1.getPointAtLength(0).x", 10, 0.1);
shouldBeCloseTo("r1.getPointAtLength(0).y", 10, 0.1);
shouldBeCloseTo("r1.getPointAtLength(150).x", 160, 0.1);
shouldBeCloseTo("r1.getPointAtLength(150).y", 10, 0.1);
shouldBeCloseTo("r1.getPointAtLength(250).x", 160, 0.1);
shouldBeCloseTo("r1.getPointAtLength(250).y", 110, 0.1);
shouldBeCloseTo("r1.getPointAtLength(400).x", 10, 0.1);
shouldBeCloseTo("r1.getPointAtLength(400).y", 110, 0.1);
shouldBeCloseTo("r1.getPointAtLength(500).x", 10, 0.1);
shouldBeCloseTo("r1.getPointAtLength(500).y", 10, 0.1);
finishJSTest();
}
]]>
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>