Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: third_party/WebKit/LayoutTests/svg/dom/SVGLengthList-replaceItem.html

Issue 2344403002: Convert LayoutTests/svg/dom/SVGLengthList*.html js-tests.js to testharness.js based tests (Closed)
Patch Set: align with review commetns Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE HTML>
2 <title>SVGLengthList, replaceItem()</title>
3 <script src="../../resources/testharness.js"></script>
4 <script src="../../resources/testharnessreport.js"></script>
5 <svg width="200" height="200">
6 <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="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 </svg>
11 <script>
12 test(function() {
13 // This is a test of the SVGLengthList::replaceItem() API.
fs 2016/09/17 17:42:37 Like...
Shanmuga Pandi 2016/09/19 07:40:04 Done.
14
15 var svg = document.querySelector("svg");
16 var list1 = document.getElementById("text1").x.baseVal;
17 var list2 = document.getElementById("text2").x.baseVal;
18 var list3 = document.getElementById("text3").x.baseVal;
19 var list4 = document.getElementById("text4").x.baseVal;
20
21 // Create three SVGLength objects, with values=50,100,150.
22 var newLength1 = svg.createSVGLength();
23 newLength1.value = 50;
24 assert_equals(newLength1.value, 50);
25
26 var newLength2 = svg.createSVGLength();
27 newLength2.value = 100;
28 assert_equals(newLength2.value, 100);
29
30 var newLength3 = svg.createSVGLength();
31 newLength3.value = 150;
32 assert_equals(newLength3.value, 150);
33
34 // Check initial list state of text1.
35 assert_equals(list1.numberOfItems, 3);
Srirama 2016/09/17 12:48:41 this checking looks common in most of the places,
fs 2016/09/17 17:42:37 Yes, that sounds like a good idea. Would cut down
Shanmuga Pandi 2016/09/19 07:40:04 Done.
36 assert_equals(list1.getItem(0).value, 500);
37 assert_equals(list1.getItem(1).value, 1000);
38 assert_equals(list1.getItem(2).value, 1500);
39 assert_throws("IndexSizeError", function() { list1.getItem(3); });
40
41 // Replace the first three values in text1 x list with 'newLength1/2/3'.
42 assert_equals(list1.replaceItem(newLength1, 0).value, newLength1.value);
43 assert_equals(list1.replaceItem(newLength2, 1).value, newLength2.value);
44 assert_equals(list1.replaceItem(newLength3, 2).value, newLength3.value);
45 assert_throws("IndexSizeError", function() { list1.replaceItem(newLength3, -10 0); });
46 assert_throws("IndexSizeError", function() { list1.replaceItem(newLength3, -1) ; });
47 assert_throws("IndexSizeError", function() { list1.replaceItem(newLength3, 3); });
48 assert_throws("IndexSizeError", function() { list1.replaceItem(newLength3, 100 ); });
49
50 // Verify that the text1 x value list is correct.
51 assert_equals(list1.numberOfItems, 3);
52 assert_equals(list1.getItem(0).value, 50);
53 assert_equals(list1.getItem(1).value, 100);
54 assert_equals(list1.getItem(2).value, 150);
55
56 // Check initial list state of text2.
57 assert_equals(list2.numberOfItems, 4);
58 assert_equals(list2.getItem(0).value, 500);
59 assert_equals(list2.getItem(1).value, 100);
60 assert_equals(list2.getItem(2).value, 150);
61 assert_equals(list2.getItem(3).value, 50);
62 assert_throws("IndexSizeError", function() { list2.getItem(4); });
63
64 // Spec: If newItem is already in a list, then a new object is created with th e same values as newItem and this item is inserted into the list.
65 // Otherwise, newItem itself is inserted into the list.
66
67 // Replace the first item in text2 x list with the fourth item in the list/
68 assert_equals(list2.replaceItem(list2.getItem(3), 0).value, 50);
69 assert_equals(list2.numberOfItems, 4);
70 assert_equals(list2.getItem(0).value, 50);
71 assert_equals(list2.getItem(1).value, 100);
72 assert_equals(list2.getItem(2).value, 150);
73 assert_equals(list2.getItem(3).value, 50);
74
75 // Check initial list state of text3.
76 assert_equals(list3.numberOfItems, 5);
77 assert_equals(list3.getItem(0).value, 50);
78 assert_equals(list3.getItem(1).value, 50);
79 assert_equals(list3.getItem(2).value, 100);
80 assert_equals(list3.getItem(3).value, 100);
81 assert_equals(list3.getItem(4).value, 150);
82 assert_throws("IndexSizeError", function() { list3.getItem(5); });
83
84 // Check initial list state of text4.
85 assert_equals(list4.numberOfItems, 4);
86 assert_equals(list4.getItem(0).value, 100);
87 assert_equals(list4.getItem(1).value, 50);
88 assert_equals(list4.getItem(2).value, 150);
89 assert_equals(list4.getItem(3).value, 150);
90 assert_throws("IndexSizeError", function() { list4.getItem(4); });
91
92 // Replace the first item in text4 x list with the second item in the text3 x list.
93 assert_equals(list4.replaceItem(list3.getItem(1), 0).value, 50);
94 assert_equals(list3.numberOfItems, 5);
95 assert_equals(list3.getItem(0).value, 50);
96 assert_equals(list3.getItem(1).value, 50);
97 assert_equals(list3.getItem(2).value, 100);
98 assert_equals(list3.getItem(3).value, 100);
99 assert_equals(list3.getItem(4).value, 150);
100 assert_throws("IndexSizeError", function() { list3.getItem(5); });
101 assert_equals(list4.numberOfItems, 4);
102 assert_equals(list4.getItem(0).value, 50);
103 assert_equals(list4.getItem(1).value, 50);
104 assert_equals(list4.getItem(2).value, 150);
105 assert_equals(list4.getItem(3).value, 150);
106 assert_throws("IndexSizeError", function() { list4.getItem(4); });
107
108 // Replace the second item in text4 x list with the second item in the text4 x list.
fs 2016/09/17 17:42:37 ...with the third item in the text3 x list. ?
Shanmuga Pandi 2016/09/19 07:40:04 Done.
109 assert_equals(list4.replaceItem(list3.getItem(2), 1).value, 100);
110 assert_equals(list4.numberOfItems, 4);
111 assert_equals(list4.getItem(0).value, 50);
112 assert_equals(list4.getItem(1).value, 100);
113 assert_equals(list4.getItem(2).value, 150);
114 assert_equals(list4.getItem(3).value, 150);
115 assert_throws("IndexSizeError", function() { list4.getItem(4); });
116
117 // Replace the items of text3 x list with the same text3 x list.
118 assert_equals(list3.replaceItem(list3.getItem(2), 1).value, 100);
119 assert_equals(list3.replaceItem(list3.getItem(4), 2).value, 150);
120 assert_equals(list3.numberOfItems, 5);
121 assert_equals(list3.getItem(0).value, 50);
122 assert_equals(list3.getItem(1).value, 100);
123 assert_equals(list3.getItem(2).value, 150);
124 assert_equals(list3.getItem(3).value, 100);
125 assert_equals(list3.getItem(4).value, 150);
126 assert_throws("IndexSizeError", function() { list3.getItem(5); });
127
128 // Check final list state of text1.
129 assert_equals(list1.numberOfItems, 3);
130 assert_equals(list1.getItem(0).value, 50);
131 assert_equals(list1.getItem(1).value, 100);
132 assert_equals(list1.getItem(2).value, 150);
133 assert_throws("IndexSizeError", function() { list1.getItem(3); });
134
135 // Check final list state of text2.
136 assert_equals(list2.numberOfItems, 4);
137 assert_equals(list2.getItem(0).value, 50);
138 assert_equals(list2.getItem(1).value, 100);
139 assert_equals(list2.getItem(2).value, 150);
140 assert_equals(list2.getItem(3).value, 50);
141 assert_throws("IndexSizeError", function() { list2.getItem(4); });
142
143 // Check final list state of text3.
144 assert_equals(list3.numberOfItems, 5);
145 assert_equals(list3.getItem(0).value, 50);
146 assert_equals(list3.getItem(1).value, 100);
147 assert_equals(list3.getItem(2).value, 150);
148 assert_equals(list3.getItem(3).value, 100);
149 assert_equals(list3.getItem(4).value, 150);
150 assert_throws("IndexSizeError", function() { list3.getItem(5); });
151
152 // Check final list state of text4.
153 assert_equals(list4.numberOfItems, 4);
154 assert_equals(list4.getItem(0).value, 50);
155 assert_equals(list4.getItem(1).value, 100);
156 assert_equals(list4.getItem(2).value, 150);
157 assert_equals(list4.getItem(3).value, 150);
158 assert_throws("IndexSizeError", function() { list4.getItem(4); });
159 });
160 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698