OLD | NEW |
1 <!DOCTYPE HTML> | 1 <!DOCTYPE HTML> |
2 <title>SVGLengthList, replaceItem()</title> | 2 <title>SVGLengthList, replaceItem()</title> |
3 <script src="../../resources/testharness.js"></script> | 3 <script src="../../resources/testharness.js"></script> |
4 <script src="../../resources/testharnessreport.js"></script> | 4 <script src="../../resources/testharnessreport.js"></script> |
| 5 <script src="resources/SVGLengthList-helper.js"></script> |
5 <svg width="200" height="200"> | 6 <svg width="200" height="200"> |
6 <text id="text1" x="500 1000 1500" y="50"> ABC </text> | 7 <text id="text1" x="500 1000 1500" y="50"> ABC </text> |
7 <text id="text2" x="500 100 150 50" y="75"> ABC </text> | 8 <text id="text2" x="500 100 150 50" y="75"> ABC </text> |
8 <text id="text3" x="50 50 100 100 150" y="100"> ABC</text> | 9 <text id="text3" x="50 50 100 100 150" y="100"> ABC</text> |
9 <text id="text4" x="100 50 150 150" y="125"> ABC</text> | 10 <text id="text4" x="100 50 150 150" y="125"> ABC</text> |
10 </svg> | 11 </svg> |
11 <script> | 12 <script> |
12 function assert_list(list, expectedValues) { | |
13 assert_equals(list.numberOfItems, expectedValues.length); | |
14 for (var index = 0; index < expectedValues.length; ++index) | |
15 assert_equals(list.getItem(index).value, expectedValues[index]); | |
16 | |
17 assert_throws("IndexSizeError", function() { list.getItem(expectedValues.lengt
h); }); | |
18 } | |
19 | |
20 test(function() { | 13 test(function() { |
21 // This is a test of the SVGLengthList.replaceItem() API. | 14 // This is a test of the SVGLengthList.replaceItem() API. |
22 | 15 |
23 var svg = document.querySelector("svg"); | 16 var svg = document.querySelector("svg"); |
24 var list1 = document.getElementById("text1").x.baseVal; | 17 var list1 = document.getElementById("text1").x.baseVal; |
25 var list2 = document.getElementById("text2").x.baseVal; | 18 var list2 = document.getElementById("text2").x.baseVal; |
26 var list3 = document.getElementById("text3").x.baseVal; | 19 var list3 = document.getElementById("text3").x.baseVal; |
27 var list4 = document.getElementById("text4").x.baseVal; | 20 var list4 = document.getElementById("text4").x.baseVal; |
28 | 21 |
29 // Create three SVGLength objects, with values=50,100,150. | 22 // Create three SVGLength objects, with values=50,100,150. |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // Check final list state of text2. | 83 // Check final list state of text2. |
91 assert_list(list2, [50, 100, 150, 50]); | 84 assert_list(list2, [50, 100, 150, 50]); |
92 | 85 |
93 // Check final list state of text3. | 86 // Check final list state of text3. |
94 assert_list(list3, [50, 100, 150, 100, 150]); | 87 assert_list(list3, [50, 100, 150, 100, 150]); |
95 | 88 |
96 // Check final list state of text4. | 89 // Check final list state of text4. |
97 assert_list(list4, [50, 100, 150, 150]); | 90 assert_list(list4, [50, 100, 150, 150]); |
98 }); | 91 }); |
99 </script> | 92 </script> |
OLD | NEW |