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

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

Issue 2340733002: Convert LayoutTests/svg/dom/SVGLengthList*.html js-tests.js to testharness.js based tests (Closed)
Patch Set: Align with review comments 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, basics</title>
3 <script src="../../resources/testharness.js"></script>
4 <script src="../../resources/testharnessreport.js"></script>
5 <svg xmlns="http://www.w3.org/2000/svg" width="200" height="200">
6 <text x="500 1000 1500" y="50"> ABC </text>
7 </svg>
8 <script>
9 test(function() {
10 var text1 = document.querySelector("text");
11 var xBaseValList = text1.x.baseVal;
12 var xAnimValList = text1.x.animVal;
13
14 // Spec: The object referenced by animVal will always be distinct from the one referenced by baseVal, even when the attribute is not animated.
15 assert_not_equals(xBaseValList, xAnimValList);
16
17 assert_equals(xBaseValList.numberOfItems, 3);
18 assert_equals(xAnimValList.numberOfItems, 3);
19 assert_equals(xBaseValList.getItem(0).value, 500);
20 assert_equals(xBaseValList.getItem(1).value, 1000);
21 assert_equals(xBaseValList.getItem(2).value, 1500);
22
23 // Test uncommon arguments for initialize().
24 assert_throws(new TypeError(), function() { xBaseValList.initialize(30); });
25 assert_throws(new TypeError(), function() { xBaseValList.initialize('aString') ; });
26 assert_throws(new TypeError(), function() { xBaseValList.initialize(text1); }) ;
27 assert_throws(new TypeError(), function() { xBaseValList.initialize(null); });
28
29 // Test uncommon arguments for getItem().
30 assert_throws("IndexSizeError", function() { xBaseValList.getItem(30); });
31 assert_equals(xBaseValList.getItem('aString').value, xBaseValList.getItem(0).v alue);
32 assert_equals(xBaseValList.getItem(text1).value, xBaseValList.getItem(0).value );
33 assert_equals(xBaseValList.getItem(null).value, xBaseValList.getItem(0).value) ;
34
35 // Test uncommon arguments for insertItemBefore().
36 assert_throws(new TypeError(), function() { xBaseValList.insertItemBefore(30); });
37 assert_throws(new TypeError(), function() { xBaseValList.insertItemBefore('aSt ring'); });
38 assert_throws(new TypeError(), function() { xBaseValList.insertItemBefore(text 1); });
39 assert_throws(new TypeError(), function() { xBaseValList.insertItemBefore(null ); });
40
41 assert_equals(xBaseValList.insertItemBefore(xBaseValList.getItem(1), 'aString' ).value, xBaseValList.getItem(0).value);
42 assert_equals(xBaseValList.numberOfItems, 4);
43 assert_equals(xBaseValList.getItem(0).value, 1000);
44 assert_equals(xBaseValList.getItem(1).value, 500);
45 assert_equals(xBaseValList.getItem(2).value, 1000);
46 assert_equals(xBaseValList.getItem(3).value, 1500);
47 assert_equals(text1.getAttribute('x'), "1000 500 1000 1500");
48
49 assert_equals(xBaseValList.insertItemBefore(xBaseValList.getItem(1), text1).va lue, xBaseValList.getItem(0).value);
50 assert_equals(xBaseValList.numberOfItems, 5);
51 assert_equals(xBaseValList.getItem(0).value, 500);
52 assert_equals(xBaseValList.getItem(1).value, 1000);
53 assert_equals(xBaseValList.getItem(2).value, 500);
54 assert_equals(xBaseValList.getItem(3).value, 1000);
55 assert_equals(xBaseValList.getItem(4).value, 1500);
56
57 assert_equals(text1.getAttribute('x'), "500 1000 500 1000 1500");
58
59 assert_equals(xBaseValList.insertItemBefore(xBaseValList.getItem(1), null).val ue, xBaseValList.getItem(0).value);
60 assert_equals(xBaseValList.numberOfItems, 6);
61 assert_equals(xBaseValList.getItem(0).value, 1000);
62 assert_equals(xBaseValList.getItem(1).value, 500);
63 assert_equals(xBaseValList.getItem(2).value, 1000);
64 assert_equals(xBaseValList.getItem(3).value, 500);
65 assert_equals(xBaseValList.getItem(4).value, 1000);
66 assert_equals(xBaseValList.getItem(5).value, 1500);
67 assert_equals(text1.getAttribute('x'), "1000 500 1000 500 1000 1500");
68
69 assert_equals(xBaseValList.insertItemBefore(xBaseValList.getItem(1), 0).value, xBaseValList.getItem(0).value);
70 assert_equals(xBaseValList.numberOfItems, 7);
71 assert_equals(xBaseValList.getItem(0).value, 500);
72 assert_equals(xBaseValList.getItem(1).value, 1000);
73 assert_equals(xBaseValList.getItem(2).value, 500);
74 assert_equals(xBaseValList.getItem(3).value, 1000);
75 assert_equals(xBaseValList.getItem(4).value, 500);
76 assert_equals(xBaseValList.getItem(5).value, 1000);
77 assert_equals(xBaseValList.getItem(6).value, 1500);
78 assert_equals(text1.getAttribute('x'), "500 1000 500 1000 500 1000 1500");
79
80 assert_throws(new TypeError(), function() { xBaseValList.insertItemBefore(30, 0); });
81 assert_throws(new TypeError(), function() { xBaseValList.insertItemBefore('aSt ring', 0); });
82 assert_throws(new TypeError(), function() { xBaseValList.insertItemBefore(text 1, 0); });
83 assert_throws(new TypeError(), function() { xBaseValList.insertItemBefore(null , 0); });
84
85 // Set x='1 2 3 4' for text1.
86 text1.setAttribute('x', '1 2 3 4');
87
88 // Test edge cases for insertItemBefore().
89 assert_equals(xBaseValList.insertItemBefore(xBaseValList.getItem(3), 3).value, xBaseValList.getItem(3).value);
90 assert_equals(text1.getAttribute('x'), "1 2 3 4 4");
91 assert_equals(xBaseValList.insertItemBefore(xBaseValList.getItem(1), 5).value, xBaseValList.getItem(5).value);
92 assert_equals(text1.getAttribute('x'), "1 2 3 4 4 2");
93 assert_equals(xBaseValList.insertItemBefore(xBaseValList.getItem(1), 0).value, xBaseValList.getItem(0).value);
94 assert_equals(text1.getAttribute('x'), "2 1 2 3 4 4 2");
95
96 // Set x='1 2 3 4' for text1.
97 text1.setAttribute('x', '1 2 3 4');
98 assert_equals(xBaseValList.numberOfItems, 4);
99 assert_equals(xBaseValList.getItem(0).value, 1);
100 assert_equals(xBaseValList.getItem(1).value, 2);
101 assert_equals(xBaseValList.getItem(2).value, 3);
102 assert_equals(xBaseValList.getItem(3).value, 4);
103 assert_equals(text1.getAttribute('x'), "1 2 3 4");
104
105 // Test uncommon arguments for replaceItem().
106 assert_throws(new TypeError(), function() { xBaseValList.replaceItem(30); });
107 assert_throws(new TypeError(), function() { xBaseValList.replaceItem('aString' ); });
108 assert_throws(new TypeError(), function() { xBaseValList.replaceItem(text1); } );
109 assert_throws(new TypeError(), function() { xBaseValList.replaceItem(null); }) ;
110 assert_throws(new TypeError(), function() { xBaseValList.replaceItem(30, 0); } );
111 assert_throws(new TypeError(), function() { xBaseValList.replaceItem('aString' , 0); });
112 assert_throws(new TypeError(), function() { xBaseValList.replaceItem(text1, 0) ; });
113 assert_throws(new TypeError(), function() { xBaseValList.replaceItem(null, 0); });
114
115 // Test uncommon values for indexed setter.
116 assert_throws(new TypeError(), function() { xBaseValList[0] = 30; });
117 assert_throws(new TypeError(), function() { xBaseValList[0] = 'aString'; });
118 assert_throws(new TypeError(), function() { xBaseValList[0] = text1; });
119 assert_throws(new TypeError(), function() { xBaseValList[0] = null; });
120
121 assert_equals(xBaseValList.replaceItem(xBaseValList.getItem(0), 0).value, xBas eValList.getItem(0).value);
122 assert_equals(xBaseValList.numberOfItems, 4);
123 assert_equals(xBaseValList.getItem(0).value, 1);
124 assert_equals(xBaseValList.getItem(1).value, 2);
125 assert_equals(xBaseValList.getItem(2).value, 3);
126 assert_equals(xBaseValList.getItem(3).value, 4);
127 assert_equals(text1.getAttribute('x'), "1 2 3 4");
128
129 assert_equals(xBaseValList.replaceItem(xBaseValList.getItem(0), 'aString').val ue, xBaseValList.getItem(0).value);
130 assert_equals(xBaseValList.numberOfItems, 4);
131 assert_equals(xBaseValList.getItem(0).value, 1);
132 assert_equals(xBaseValList.getItem(1).value, 2);
133 assert_equals(xBaseValList.getItem(2).value, 3);
134 assert_equals(xBaseValList.getItem(3).value, 4);
135 assert_equals(text1.getAttribute('x'), "1 2 3 4");
136
137 assert_equals(xBaseValList.replaceItem(xBaseValList.getItem(0), text1).value, xBaseValList.getItem(0).value);
138 assert_equals(xBaseValList.numberOfItems, 4);
139 assert_equals(text1.getAttribute('x'), "1 2 3 4");
140
141 // Set x='1 2 3 4' for text1.
142 text1.setAttribute('x', '1 2 3 4');
143
144 // Test edge cases for replaceItem().
145 assert_equals(xBaseValList.replaceItem(xBaseValList.getItem(3), 3).value, xBas eValList.getItem(3).value);
146 assert_equals(xBaseValList.numberOfItems, 4);
147 assert_equals(text1.getAttribute('x'), "1 2 3 4");
148 assert_equals(xBaseValList.replaceItem(xBaseValList.getItem(1), 3).value, xBas eValList.getItem(3).value);
149 assert_equals(xBaseValList.numberOfItems, 4);
150 assert_equals(text1.getAttribute('x'), "1 2 3 2");
151 assert_throws("IndexSizeError", function() { xBaseValList.replaceItem(xBaseVal List.getItem(3), 4); });
152
153 // Set x='1 2 3 4' for text1.
154 text1.setAttribute('x', '1 2 3 4');
155
156 // Test uncommon arguments for removeItem().
157 assert_throws("IndexSizeError", function() { xBaseValList.removeItem(30); });
158
159 assert_equals(xBaseValList.removeItem(0).value, 1);
160 assert_equals(xBaseValList.numberOfItems, 3);
161 assert_equals(xBaseValList.getItem(0).value, 2);
162 assert_equals(xBaseValList.getItem(1).value, 3);
163 assert_equals(xBaseValList.getItem(2).value, 4);
164 assert_equals(text1.getAttribute('x'), "2 3 4");
165
166 assert_equals(xBaseValList.removeItem(text1).value, 2);
167 assert_equals(xBaseValList.numberOfItems, 2);
168 assert_equals(xBaseValList.getItem(0).value, 3);
169 assert_equals(xBaseValList.getItem(1).value, 4);
170 assert_equals(text1.getAttribute('x'), "3 4");
171
172 // Test uncommon arguments for appendItem().
173 assert_throws(new TypeError(), function() { xBaseValList.appendItem(30); });
174 assert_throws(new TypeError(), function() { xBaseValList.appendItem('aString') ; });
175 assert_throws(new TypeError(), function() { xBaseValList.appendItem(text1); }) ;
176 assert_throws(new TypeError(), function() { xBaseValList.appendItem(null); });
177
178 // Testing animVal clear throws.
179 assert_throws("NoModificationAllowedError", function() { xAnimValList.clear(); });
180 xBaseValList.clear();
181 });
182 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698