1 <html xmlns="http://www.w3.org/1999/xhtml">
3 <script>window.enablePixelTesting = true;</script>
4 <script src="../../fast/js/resources/js-test-pre.js"></script>
7 <svg id="svg" xmlns="http://www.w3.org/2000/svg" width="250" height="250">
8 <g transform="translate(10, 10)">
9 <path id="path1" d="M 100 100 L 100 0 L 100 100" fill="green"/>
10 <path transform="translate(110, 0)" id="path2" d="M 50 50 L 0 100 M 0 0" fill="green"/>
14 <p id="description"></p>
15 <div id="console"></div>
16 <script type="text/javascript">
18 description("This is a test of the SVGPathSegList::appendItem() API.");
20 var svg = document.getElementById("svg");
21 var path1 = document.getElementById("path1");
22 var path2 = document.getElementById("path2");
25 debug("Check initial 'pathSegList' value of path1");
26 shouldBe("path1.pathSegList.numberOfItems", "3");
27 shouldBeEqualToString("path1.pathSegList.getItem(0).toString()", "[object SVGPathSegMovetoAbs]");
28 shouldBe("path1.pathSegList.getItem(0).x", "100");
29 shouldBe("path1.pathSegList.getItem(0).y", "100");
30 shouldBeEqualToString("path1.pathSegList.getItem(1).toString()", "[object SVGPathSegLinetoAbs]");
31 shouldBe("path1.pathSegList.getItem(1).x", "100");
32 shouldBe("path1.pathSegList.getItem(1).y", "0");
33 shouldBeEqualToString("path1.pathSegList.getItem(2).toString()", "[object SVGPathSegLinetoAbs]");
34 shouldBe("path1.pathSegList.getItem(2).x", "100");
35 shouldBe("path1.pathSegList.getItem(2).y", "100");
38 debug("Check initial 'pathSegList' value of path2");
39 shouldBe("path2.pathSegList.numberOfItems", "3");
40 shouldBeEqualToString("path2.pathSegList.getItem(0).toString()", "[object SVGPathSegMovetoAbs]");
41 shouldBe("path2.pathSegList.getItem(0).x", "50");
42 shouldBe("path2.pathSegList.getItem(0).y", "50");
43 shouldBeEqualToString("path2.pathSegList.getItem(1).toString()", "[object SVGPathSegLinetoAbs]");
44 shouldBe("path2.pathSegList.getItem(1).x", "0");
45 shouldBe("path2.pathSegList.getItem(1).y", "100");
46 shouldBeEqualToString("path2.pathSegList.getItem(2).toString()", "[object SVGPathSegMovetoAbs]");
47 shouldBe("path2.pathSegList.getItem(2).x", "0");
48 shouldBe("path2.pathSegList.getItem(2).y", "0");
51 debug("Cache first item of path1 in local variable 'item0'");
52 var item0 = path1.pathSegList.getItem(0);
53 shouldBe("item0.x", "100");
54 shouldBe("item0.y", "100");
57 debug("Clear path1 segment list");
58 shouldBeUndefined("path1.pathSegList.clear()");
61 debug("Verify that item0 is still alive, and can be modified");
62 shouldBe("item0.x", "100");
63 shouldBe("item0.y", "100");
64 shouldBe("item0.x += 50", "150");
65 shouldBe("item0.y += 50", "150");
68 debug("Check intermediate list state of path1");
69 shouldBe("path1.pathSegList.numberOfItems", "0");
70 shouldThrow("path1.pathSegList.getItem(0)");
73 debug("Check intermediate list state of path2");
74 shouldBe("path2.pathSegList.numberOfItems", "3");
75 shouldBeEqualToString("path2.pathSegList.getItem(0).toString()", "[object SVGPathSegMovetoAbs]");
76 shouldBe("path2.pathSegList.getItem(0).x", "50");
77 shouldBe("path2.pathSegList.getItem(0).y", "50");
78 shouldBeEqualToString("path2.pathSegList.getItem(1).toString()", "[object SVGPathSegLinetoAbs]");
79 shouldBe("path2.pathSegList.getItem(1).x", "0");
80 shouldBe("path2.pathSegList.getItem(1).y", "100");
81 shouldBeEqualToString("path2.pathSegList.getItem(2).toString()", "[object SVGPathSegMovetoAbs]");
82 shouldBe("path2.pathSegList.getItem(2).x", "0");
83 shouldBe("path2.pathSegList.getItem(2).y", "0");
86 debug("Initialize path1 list with first item of path2");
87 shouldBeEqualToString("path1.pathSegList.initialize(path2.pathSegList.getItem(0)).toString()", "[object SVGPathSegMovetoAbs]");
90 debug("Check intermediate list state of path1");
91 shouldBe("path1.pathSegList.numberOfItems", "1");
92 shouldBeEqualToString("path1.pathSegList.getItem(0).toString()", "[object SVGPathSegMovetoAbs]");
93 shouldBe("path1.pathSegList.getItem(0).x", "50");
94 shouldBe("path1.pathSegList.getItem(0).y", "50");
97 debug("Check intermediate list state of path2");
98 shouldBe("path2.pathSegList.numberOfItems", "2");
99 shouldBeEqualToString("path2.pathSegList.getItem(0).toString()", "[object SVGPathSegLinetoAbs]");
100 shouldBe("path2.pathSegList.getItem(0).x", "0");
101 shouldBe("path2.pathSegList.getItem(0).y", "100");
102 shouldBeEqualToString("path2.pathSegList.getItem(1).toString()", "[object SVGPathSegMovetoAbs]");
103 shouldBe("path2.pathSegList.getItem(1).x", "0");
104 shouldBe("path2.pathSegList.getItem(1).y", "0");
107 debug("Initialize path2 list with item0");
108 shouldBeEqualToString("path2.pathSegList.initialize(item0).toString()", "[object SVGPathSegMovetoAbs]");
111 debug("Check final list state of path1");
112 shouldBe("path1.pathSegList.numberOfItems", "1");
113 shouldBeEqualToString("path1.pathSegList.getItem(0).toString()", "[object SVGPathSegMovetoAbs]");
114 shouldBe("path1.pathSegList.getItem(0).x", "50");
115 shouldBe("path1.pathSegList.getItem(0).y", "50");
118 debug("Check final list state of path2");
119 shouldBe("path2.pathSegList.numberOfItems", "1");
120 shouldBeEqualToString("path2.pathSegList.getItem(0).toString()", "[object SVGPathSegMovetoAbs]");
121 shouldBe("path2.pathSegList.getItem(0).x", "150");
122 shouldBe("path2.pathSegList.getItem(0).y", "150");
126 <script src="../../fast/js/resources/js-test-post.js"></script>