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="200" height="200"> | |
8 <text id="text1" x="500 1000 1500" y="50"> ABC </text> | |
9 <text id="text2" x="500 100 150 50" y="75"> ABC </text> | |
10 <text id="text3" x="50 50 100 100 150" y="100"> ABC</text> | |
11 <text id="text4" x="100 50 150 150" y="125"> ABC</text> | |
12 <text id="reference" x="50 100 150" y="150">ABC </text> | |
13 </svg> | |
14 | |
15 <p id="description"></p> | |
16 <div id="console"></div> | |
17 <script type="text/javascript"> | |
18 <![CDATA[ | |
19 description("This is a test of the SVGLengthList::replaceItem() API."); | |
20 | |
21 var svg = document.getElementById("svg"); | |
22 var text1 = document.getElementById("text1"); | |
23 var text2 = document.getElementById("text2"); | |
24 var text3 = document.getElementById("text3"); | |
25 var text4 = document.getElementById("text4"); | |
26 | |
27 debug(""); | |
28 debug("Create three SVGLength objects, with values=50,100,150"); | |
29 var newLength1 = svg.createSVGLength(); | |
30 newLength1.value = 50; | |
31 shouldBe("newLength1.value", "50"); | |
32 | |
33 var newLength2 = svg.createSVGLength(); | |
34 newLength2.value = 100; | |
35 shouldBe("newLength2.value", "100"); | |
36 | |
37 var newLength3 = svg.createSVGLength(); | |
38 newLength3.value = 150; | |
39 shouldBe("newLength3.value", "150"); | |
40 | |
41 debug(""); | |
42 debug("Check initial list state of text1"); | |
43 shouldBe("text1.x.baseVal.numberOfItems", "3"); | |
44 shouldBe("text1.x.baseVal.getItem(0).value", "500"); | |
45 shouldBe("text1.x.baseVal.getItem(1).value", "1000"); | |
46 shouldBe("text1.x.baseVal.getItem(2).value", "1500"); | |
47 shouldThrow("text1.x.baseVal.getItem(3)"); | |
48 | |
49 debug(""); | |
50 debug("Replace the first three values in text1 x list with 'newLength1/2/3'"
); | |
51 shouldBe("text1.x.baseVal.replaceItem(newLength1, 0)", "newLength1"); | |
52 shouldBe("text1.x.baseVal.replaceItem(newLength2, 1)", "newLength2"); | |
53 shouldBe("text1.x.baseVal.replaceItem(newLength3, 2)", "newLength3"); | |
54 shouldThrow("text1.x.baseVal.replaceItem(newLength3, -100)"); | |
55 shouldThrow("text1.x.baseVal.replaceItem(newLength3, -1)"); | |
56 shouldThrow("text1.x.baseVal.replaceItem(newLength3, 3)"); | |
57 shouldThrow("text1.x.baseVal.replaceItem(newLength3, 100)"); | |
58 | |
59 debug(""); | |
60 debug("Verify that the text1 x value list is correct"); | |
61 shouldBe("text1.x.baseVal.numberOfItems", "3"); | |
62 shouldBe("text1.x.baseVal.getItem(0).value", "50"); | |
63 shouldBe("text1.x.baseVal.getItem(1).value", "100"); | |
64 shouldBe("text1.x.baseVal.getItem(2).value", "150"); | |
65 | |
66 debug(""); | |
67 debug("Check initial list state of text2"); | |
68 shouldBe("text2.x.baseVal.numberOfItems", "4"); | |
69 shouldBe("text2.x.baseVal.getItem(0).value", "500"); | |
70 shouldBe("text2.x.baseVal.getItem(1).value", "100"); | |
71 shouldBe("text2.x.baseVal.getItem(2).value", "150"); | |
72 shouldBe("text2.x.baseVal.getItem(3).value", "50"); | |
73 shouldThrow("text2.x.baseVal.getItem(4)"); | |
74 | |
75 // Spec: If newItem is already in a list, then a new object is created with
the same values as newItem and this item is inserted into the list. | |
76 // Otherwise, newItem itself is inserted into the list. | |
77 debug(""); | |
78 debug("Replace the first item in text2 x list with the fourth item in the li
st"); | |
79 shouldBe("text2.x.baseVal.replaceItem(text2.x.baseVal.getItem(3), 0).value",
"50"); | |
80 shouldBe("text2.x.baseVal.numberOfItems", "4"); | |
81 shouldBe("text2.x.baseVal.getItem(0).value", "50"); | |
82 shouldBe("text2.x.baseVal.getItem(1).value", "100"); | |
83 shouldBe("text2.x.baseVal.getItem(2).value", "150"); | |
84 shouldBe("text2.x.baseVal.getItem(3).value", "50"); | |
85 | |
86 debug(""); | |
87 debug("Check initial list state of text3"); | |
88 shouldBe("text3.x.baseVal.numberOfItems", "5"); | |
89 shouldBe("text3.x.baseVal.getItem(0).value", "50"); | |
90 shouldBe("text3.x.baseVal.getItem(1).value", "50"); | |
91 shouldBe("text3.x.baseVal.getItem(2).value", "100"); | |
92 shouldBe("text3.x.baseVal.getItem(3).value", "100"); | |
93 shouldBe("text3.x.baseVal.getItem(4).value", "150"); | |
94 shouldThrow("text3.x.baseVal.getItem(5)"); | |
95 | |
96 debug(""); | |
97 debug("Check initial list state of text4"); | |
98 shouldBe("text4.x.baseVal.numberOfItems", "4"); | |
99 shouldBe("text4.x.baseVal.getItem(0).value", "100"); | |
100 shouldBe("text4.x.baseVal.getItem(1).value", "50"); | |
101 shouldBe("text4.x.baseVal.getItem(2).value", "150"); | |
102 shouldBe("text4.x.baseVal.getItem(3).value", "150"); | |
103 shouldThrow("text4.x.baseVal.getItem(4)"); | |
104 | |
105 debug(""); | |
106 debug("Replace the first item in text4 x list with the second item in the te
xt3 x list"); | |
107 shouldBe("text4.x.baseVal.replaceItem(text3.x.baseVal.getItem(1), 0).value",
"50"); | |
108 shouldBe("text3.x.baseVal.numberOfItems", "5"); | |
109 shouldBe("text3.x.baseVal.getItem(0).value", "50"); | |
110 shouldBe("text3.x.baseVal.getItem(1).value", "50"); | |
111 shouldBe("text3.x.baseVal.getItem(2).value", "100"); | |
112 shouldBe("text3.x.baseVal.getItem(3).value", "100"); | |
113 shouldBe("text3.x.baseVal.getItem(4).value", "150"); | |
114 shouldThrow("text3.x.baseVal.getItem(5)"); | |
115 shouldBe("text4.x.baseVal.numberOfItems", "4"); | |
116 shouldBe("text4.x.baseVal.getItem(0).value", "50"); | |
117 shouldBe("text4.x.baseVal.getItem(1).value", "50"); | |
118 shouldBe("text4.x.baseVal.getItem(2).value", "150"); | |
119 shouldBe("text4.x.baseVal.getItem(3).value", "150"); | |
120 shouldThrow("text4.x.baseVal.getItem(4)"); | |
121 | |
122 debug(""); | |
123 debug("Replace the second item in text4 x list with the second item in the t
ext4 x list"); | |
124 shouldBe("text4.x.baseVal.replaceItem(text3.x.baseVal.getItem(2), 1).value",
"100"); | |
125 shouldBe("text4.x.baseVal.numberOfItems", "4"); | |
126 shouldBe("text4.x.baseVal.getItem(0).value", "50"); | |
127 shouldBe("text4.x.baseVal.getItem(1).value", "100"); | |
128 shouldBe("text4.x.baseVal.getItem(2).value", "150"); | |
129 shouldBe("text4.x.baseVal.getItem(3).value", "150"); | |
130 shouldThrow("text4.x.baseVal.getItem(4)"); | |
131 | |
132 debug(""); | |
133 debug("Replace the items of text3 x list with the same text3 x list"); | |
134 shouldBe("text3.x.baseVal.replaceItem(text3.x.baseVal.getItem(2), 1).value",
"100"); | |
135 shouldBe("text3.x.baseVal.replaceItem(text3.x.baseVal.getItem(4), 2).value",
"150"); | |
136 shouldBe("text3.x.baseVal.numberOfItems", "5"); | |
137 shouldBe("text3.x.baseVal.getItem(0).value", "50"); | |
138 shouldBe("text3.x.baseVal.getItem(1).value", "100"); | |
139 shouldBe("text3.x.baseVal.getItem(2).value", "150"); | |
140 shouldBe("text3.x.baseVal.getItem(3).value", "100"); | |
141 shouldBe("text3.x.baseVal.getItem(4).value", "150"); | |
142 shouldThrow("text3.x.baseVal.getItem(5)"); | |
143 | |
144 debug(""); | |
145 debug("Check final list state of text1"); | |
146 shouldBe("text1.x.baseVal.numberOfItems", "3"); | |
147 shouldBe("text1.x.baseVal.getItem(0).value", "50"); | |
148 shouldBe("text1.x.baseVal.getItem(1).value", "100"); | |
149 shouldBe("text1.x.baseVal.getItem(2).value", "150"); | |
150 shouldThrow("text1.x.baseVal.getItem(3)"); | |
151 | |
152 debug(""); | |
153 debug("Check final list state of text2"); | |
154 shouldBe("text2.x.baseVal.numberOfItems", "4"); | |
155 shouldBe("text2.x.baseVal.getItem(0).value", "50"); | |
156 shouldBe("text2.x.baseVal.getItem(1).value", "100"); | |
157 shouldBe("text2.x.baseVal.getItem(2).value", "150"); | |
158 shouldBe("text2.x.baseVal.getItem(3).value", "50"); | |
159 shouldThrow("text2.x.baseVal.getItem(4)"); | |
160 | |
161 debug(""); | |
162 debug("Check final list state of text3"); | |
163 shouldBe("text3.x.baseVal.numberOfItems", "5"); | |
164 shouldBe("text3.x.baseVal.getItem(0).value", "50"); | |
165 shouldBe("text3.x.baseVal.getItem(1).value", "100"); | |
166 shouldBe("text3.x.baseVal.getItem(2).value", "150"); | |
167 shouldBe("text3.x.baseVal.getItem(3).value", "100"); | |
168 shouldBe("text3.x.baseVal.getItem(4).value", "150"); | |
169 shouldThrow("text3.x.baseVal.getItem(5)"); | |
170 | |
171 debug(""); | |
172 debug("Check final list state of text4"); | |
173 shouldBe("text4.x.baseVal.numberOfItems", "4"); | |
174 shouldBe("text4.x.baseVal.getItem(0).value", "50"); | |
175 shouldBe("text4.x.baseVal.getItem(1).value", "100"); | |
176 shouldBe("text4.x.baseVal.getItem(2).value", "150"); | |
177 shouldBe("text4.x.baseVal.getItem(3).value", "150"); | |
178 shouldThrow("text4.x.baseVal.getItem(4)"); | |
179 | |
180 debug(""); | |
181 debug("The test passes if you only see 'PASS' messages, and all five text el
ements on top look the same"); | |
182 debug(""); | |
183 | |
184 ]]> | |
185 </script> | |
186 </body> | |
187 </html> | |
OLD | NEW |