OLD | NEW |
| (Empty) |
1 <html xmlns="http://www.w3.org/1999/xhtml"> | |
2 <head> | |
3 <script>window.enablePixelTesting = true;</script> | |
4 <script src="../../resources/js-test.js"></script> | |
5 </head> | |
6 <body> | |
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 0 0 L 100 0 L 100 100" fill="green"/> | |
10 <path transform="translate(110, 0)" id="path2" d="M 0 0 L 50 100 h 100 h
100 v 100" fill="green"/> | |
11 </g> | |
12 </svg> | |
13 | |
14 <p id="description"></p> | |
15 <div id="console"></div> | |
16 <script type="text/javascript"> | |
17 <![CDATA[ | |
18 description("This is a test of the SVGPathSegList::appendItem() API."); | |
19 | |
20 var svg = document.getElementById("svg"); | |
21 var path1 = document.getElementById("path1"); | |
22 var path2 = document.getElementById("path2"); | |
23 | |
24 debug(""); | |
25 debug("Check initial 'pathSegList' value of path1"); | |
26 shouldBe("path1.pathSegList.numberOfItems", "3"); | |
27 shouldBeEqualToString("path1.pathSegList.getItem(0).toString()", "[object SV
GPathSegMovetoAbs]"); | |
28 shouldBe("path1.pathSegList.getItem(0).x", "0"); | |
29 shouldBe("path1.pathSegList.getItem(0).y", "0"); | |
30 shouldBeEqualToString("path1.pathSegList.getItem(1).toString()", "[object SV
GPathSegLinetoAbs]"); | |
31 shouldBe("path1.pathSegList.getItem(1).x", "100"); | |
32 shouldBe("path1.pathSegList.getItem(1).y", "0"); | |
33 shouldBeEqualToString("path1.pathSegList.getItem(2).toString()", "[object SV
GPathSegLinetoAbs]"); | |
34 shouldBe("path1.pathSegList.getItem(2).x", "100"); | |
35 shouldBe("path1.pathSegList.getItem(2).y", "100"); | |
36 | |
37 debug(""); | |
38 debug("Check initial 'pathSegList' value of path2"); | |
39 shouldBe("path2.pathSegList.numberOfItems", "5"); | |
40 shouldBeEqualToString("path2.pathSegList.getItem(0).toString()", "[object SV
GPathSegMovetoAbs]"); | |
41 shouldBe("path2.pathSegList.getItem(0).x", "0"); | |
42 shouldBe("path2.pathSegList.getItem(0).y", "0"); | |
43 shouldBeEqualToString("path2.pathSegList.getItem(1).toString()", "[object SV
GPathSegLinetoAbs]"); | |
44 shouldBe("path2.pathSegList.getItem(1).x", "50"); | |
45 shouldBe("path2.pathSegList.getItem(1).y", "100"); | |
46 shouldBeEqualToString("path2.pathSegList.getItem(2).toString()", "[object SV
GPathSegLinetoHorizontalRel]"); | |
47 shouldBe("path2.pathSegList.getItem(2).x", "100"); | |
48 shouldBeEqualToString("path2.pathSegList.getItem(3).toString()", "[object SV
GPathSegLinetoHorizontalRel]"); | |
49 shouldBe("path2.pathSegList.getItem(3).x", "100"); | |
50 shouldBeEqualToString("path2.pathSegList.getItem(4).toString()", "[object SV
GPathSegLinetoVerticalRel]"); | |
51 shouldBe("path2.pathSegList.getItem(4).y", "100"); | |
52 | |
53 debug(""); | |
54 debug("Negate x value of fourth segment in path2"); | |
55 shouldBe("path2.pathSegList.getItem(3).x = -path2.pathSegList.getItem(3).x",
"-100"); | |
56 | |
57 debug("") | |
58 debug("Append second item from path1 to path2 list"); | |
59 shouldBeEqualToString("path2.pathSegList.appendItem(path2.pathSegList.getIte
m(3)).toString()", "[object SVGPathSegLinetoHorizontalRel]"); | |
60 shouldBe("path2.pathSegList.numberOfItems", "6"); | |
61 shouldBeEqualToString("path2.pathSegList.getItem(0).toString()", "[object SV
GPathSegMovetoAbs]"); | |
62 shouldBe("path2.pathSegList.getItem(0).x", "0"); | |
63 shouldBe("path2.pathSegList.getItem(0).y", "0"); | |
64 shouldBeEqualToString("path2.pathSegList.getItem(1).toString()", "[object SV
GPathSegLinetoAbs]"); | |
65 shouldBe("path2.pathSegList.getItem(1).x", "50"); | |
66 shouldBe("path2.pathSegList.getItem(1).y", "100"); | |
67 shouldBeEqualToString("path2.pathSegList.getItem(2).toString()", "[object SV
GPathSegLinetoHorizontalRel]"); | |
68 shouldBe("path2.pathSegList.getItem(2).x", "100"); | |
69 shouldBeEqualToString("path2.pathSegList.getItem(3).toString()", "[object SV
GPathSegLinetoHorizontalRel]"); | |
70 shouldBe("path2.pathSegList.getItem(3).x", "-100"); | |
71 shouldBeEqualToString("path2.pathSegList.getItem(4).toString()", "[object SV
GPathSegLinetoVerticalRel]"); | |
72 shouldBe("path2.pathSegList.getItem(4).y", "100"); | |
73 shouldBeEqualToString("path2.pathSegList.getItem(5).toString()", "[object SV
GPathSegLinetoHorizontalRel]"); | |
74 shouldBe("path2.pathSegList.getItem(5).x", "-100"); | |
75 | |
76 debug(""); | |
77 debug("Append second item from path2 to path1 list"); | |
78 shouldBeEqualToString("path1.pathSegList.appendItem(path2.pathSegList.getIte
m(1)).toString()", "[object SVGPathSegLinetoAbs]"); | |
79 | |
80 debug(""); | |
81 debug("Change last item of path1 list, that came from path2 list, assure it'
s updating path1"); | |
82 shouldBe("path1.pathSegList.getItem(3).x -= 50", "0"); | |
83 | |
84 debug(""); | |
85 debug("Reset points attribute to M 0 0 L 100 0 v 100"); | |
86 shouldBeUndefined("path2.setAttribute('d', 'M 0 0 L 100 0 v 100')"); | |
87 | |
88 debug("") | |
89 debug("Append fourth item from path1 to path2 list - now should look like a
rectangle"); | |
90 shouldBeEqualToString("path2.pathSegList.appendItem(path1.pathSegList.getIte
m(3)).toString()", "[object SVGPathSegLinetoAbs]"); | |
91 | |
92 debug(""); | |
93 debug("Check final 'pathSegList' value of path1"); | |
94 shouldBe("path1.pathSegList.numberOfItems", "4"); | |
95 shouldBeEqualToString("path1.pathSegList.getItem(0).toString()", "[object SV
GPathSegMovetoAbs]"); | |
96 shouldBe("path1.pathSegList.getItem(0).x", "0"); | |
97 shouldBe("path1.pathSegList.getItem(0).y", "0"); | |
98 shouldBeEqualToString("path1.pathSegList.getItem(1).toString()", "[object SV
GPathSegLinetoAbs]"); | |
99 shouldBe("path1.pathSegList.getItem(1).x", "100"); | |
100 shouldBe("path1.pathSegList.getItem(1).y", "0"); | |
101 shouldBeEqualToString("path1.pathSegList.getItem(2).toString()", "[object SV
GPathSegLinetoAbs]"); | |
102 shouldBe("path1.pathSegList.getItem(2).x", "100"); | |
103 shouldBe("path1.pathSegList.getItem(2).y", "100"); | |
104 shouldBeEqualToString("path1.pathSegList.getItem(3).toString()", "[object SV
GPathSegLinetoAbs]"); | |
105 shouldBe("path1.pathSegList.getItem(3).x", "0"); | |
106 shouldBe("path1.pathSegList.getItem(3).y", "100"); | |
107 | |
108 debug(""); | |
109 debug("Check final 'pathSegList' value of path2"); | |
110 shouldBe("path2.pathSegList.numberOfItems", "4"); | |
111 shouldBeEqualToString("path2.pathSegList.getItem(0).toString()", "[object SV
GPathSegMovetoAbs]"); | |
112 shouldBe("path2.pathSegList.getItem(0).x", "0"); | |
113 shouldBe("path2.pathSegList.getItem(0).y", "0"); | |
114 shouldBeEqualToString("path2.pathSegList.getItem(1).toString()", "[object SV
GPathSegLinetoAbs]"); | |
115 shouldBe("path2.pathSegList.getItem(1).x", "100"); | |
116 shouldBe("path1.pathSegList.getItem(1).y", "0"); | |
117 shouldBeEqualToString("path2.pathSegList.getItem(2).toString()", "[object SV
GPathSegLinetoVerticalRel]"); | |
118 shouldBe("path2.pathSegList.getItem(2).y", "100"); | |
119 shouldBeEqualToString("path2.pathSegList.getItem(3).toString()", "[object SV
GPathSegLinetoAbs]"); | |
120 shouldBe("path2.pathSegList.getItem(3).x", "0"); | |
121 shouldBe("path1.pathSegList.getItem(3).y", "100"); | |
122 | |
123 ]]> | |
124 </script> | |
125 </body> | |
126 </html> | |
OLD | NEW |