blob: c461924524d68d6763d67ed60d7f392d2773bf75 [file] [log] [blame]
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>window.enablePixelTesting = true;</script>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<svg id="svg" xmlns="http://www.w3.org/2000/svg" width="250" height="250">
<g transform="translate(10, 10)">
<path id="path1" d="M 100 100 L 100 0 L 100 100" fill="green"/>
<path transform="translate(110, 0)" id="path2" d="M 50 50 L 0 100 M 0 0" fill="green"/>
</g>
</svg>
<p id="description"></p>
<div id="console"></div>
<script type="text/javascript">
<![CDATA[
description("This is a test of the SVGPathSegList::appendItem() API.");
var svg = document.getElementById("svg");
var path1 = document.getElementById("path1");
var path2 = document.getElementById("path2");
debug("");
debug("Check initial 'pathSegList' value of path1");
shouldBe("path1.pathSegList.numberOfItems", "3");
shouldBeEqualToString("path1.pathSegList.getItem(0).toString()", "[object SVGPathSegMovetoAbs]");
shouldBe("path1.pathSegList.getItem(0).x", "100");
shouldBe("path1.pathSegList.getItem(0).y", "100");
shouldBeEqualToString("path1.pathSegList.getItem(1).toString()", "[object SVGPathSegLinetoAbs]");
shouldBe("path1.pathSegList.getItem(1).x", "100");
shouldBe("path1.pathSegList.getItem(1).y", "0");
shouldBeEqualToString("path1.pathSegList.getItem(2).toString()", "[object SVGPathSegLinetoAbs]");
shouldBe("path1.pathSegList.getItem(2).x", "100");
shouldBe("path1.pathSegList.getItem(2).y", "100");
debug("");
debug("Check initial 'pathSegList' value of path2");
shouldBe("path2.pathSegList.numberOfItems", "3");
shouldBeEqualToString("path2.pathSegList.getItem(0).toString()", "[object SVGPathSegMovetoAbs]");
shouldBe("path2.pathSegList.getItem(0).x", "50");
shouldBe("path2.pathSegList.getItem(0).y", "50");
shouldBeEqualToString("path2.pathSegList.getItem(1).toString()", "[object SVGPathSegLinetoAbs]");
shouldBe("path2.pathSegList.getItem(1).x", "0");
shouldBe("path2.pathSegList.getItem(1).y", "100");
shouldBeEqualToString("path2.pathSegList.getItem(2).toString()", "[object SVGPathSegMovetoAbs]");
shouldBe("path2.pathSegList.getItem(2).x", "0");
shouldBe("path2.pathSegList.getItem(2).y", "0");
debug("");
debug("Cache first item of path1 in local variable 'item0'");
var item0 = path1.pathSegList.getItem(0);
shouldBe("item0.x", "100");
shouldBe("item0.y", "100");
debug("");
debug("Clear path1 segment list");
shouldBeUndefined("path1.pathSegList.clear()");
debug("");
debug("Verify that item0 is still alive, and can be modified");
shouldBe("item0.x", "100");
shouldBe("item0.y", "100");
shouldBe("item0.x += 50", "150");
shouldBe("item0.y += 50", "150");
debug("");
debug("Check intermediate list state of path1");
shouldBe("path1.pathSegList.numberOfItems", "0");
shouldThrow("path1.pathSegList.getItem(0)");
debug("");
debug("Check intermediate list state of path2");
shouldBe("path2.pathSegList.numberOfItems", "3");
shouldBeEqualToString("path2.pathSegList.getItem(0).toString()", "[object SVGPathSegMovetoAbs]");
shouldBe("path2.pathSegList.getItem(0).x", "50");
shouldBe("path2.pathSegList.getItem(0).y", "50");
shouldBeEqualToString("path2.pathSegList.getItem(1).toString()", "[object SVGPathSegLinetoAbs]");
shouldBe("path2.pathSegList.getItem(1).x", "0");
shouldBe("path2.pathSegList.getItem(1).y", "100");
shouldBeEqualToString("path2.pathSegList.getItem(2).toString()", "[object SVGPathSegMovetoAbs]");
shouldBe("path2.pathSegList.getItem(2).x", "0");
shouldBe("path2.pathSegList.getItem(2).y", "0");
debug("");
debug("Initialize path1 list with first item of path2");
shouldBeEqualToString("path1.pathSegList.initialize(path2.pathSegList.getItem(0)).toString()", "[object SVGPathSegMovetoAbs]");
debug("");
debug("Check intermediate list state of path1");
shouldBe("path1.pathSegList.numberOfItems", "1");
shouldBeEqualToString("path1.pathSegList.getItem(0).toString()", "[object SVGPathSegMovetoAbs]");
shouldBe("path1.pathSegList.getItem(0).x", "50");
shouldBe("path1.pathSegList.getItem(0).y", "50");
debug("");
debug("Check intermediate list state of path2");
shouldBe("path2.pathSegList.numberOfItems", "2");
shouldBeEqualToString("path2.pathSegList.getItem(0).toString()", "[object SVGPathSegLinetoAbs]");
shouldBe("path2.pathSegList.getItem(0).x", "0");
shouldBe("path2.pathSegList.getItem(0).y", "100");
shouldBeEqualToString("path2.pathSegList.getItem(1).toString()", "[object SVGPathSegMovetoAbs]");
shouldBe("path2.pathSegList.getItem(1).x", "0");
shouldBe("path2.pathSegList.getItem(1).y", "0");
debug("");
debug("Initialize path2 list with item0");
shouldBeEqualToString("path2.pathSegList.initialize(item0).toString()", "[object SVGPathSegMovetoAbs]");
debug("");
debug("Check final list state of path1");
shouldBe("path1.pathSegList.numberOfItems", "1");
shouldBeEqualToString("path1.pathSegList.getItem(0).toString()", "[object SVGPathSegMovetoAbs]");
shouldBe("path1.pathSegList.getItem(0).x", "50");
shouldBe("path1.pathSegList.getItem(0).y", "50");
debug("");
debug("Check final list state of path2");
shouldBe("path2.pathSegList.numberOfItems", "1");
shouldBeEqualToString("path2.pathSegList.getItem(0).toString()", "[object SVGPathSegMovetoAbs]");
shouldBe("path2.pathSegList.getItem(0).x", "150");
shouldBe("path2.pathSegList.getItem(0).y", "150");
]]>
</script>
</body>
</html>