OLD | NEW |
1 description('Tests the classList attribute and its properties.'); | 1 description('Tests the classList attribute and its properties.'); |
2 | 2 |
3 var element; | 3 var element; |
4 | 4 |
5 function createElement(className) | 5 function createElement(className) |
6 { | 6 { |
7 element = document.createElement('p'); | 7 element = document.createElement('p'); |
8 element.className = className; | 8 element.className = className; |
9 } | 9 } |
10 | 10 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 testFailed('Wrong exception code: ' + ex.code); | 147 testFailed('Wrong exception code: ' + ex.code); |
148 return; | 148 return; |
149 } | 149 } |
150 } | 150 } |
151 var formattedFunction = String(f).replace(/^function.+\{\s*/m, ''). | 151 var formattedFunction = String(f).replace(/^function.+\{\s*/m, ''). |
152 replace(/;?\s+\}/m, ''); | 152 replace(/;?\s+\}/m, ''); |
153 testPassed(formattedFunction + ' threw expected DOMException with code ' + e
c); | 153 testPassed(formattedFunction + ' threw expected DOMException with code ' + e
c); |
154 } | 154 } |
155 | 155 |
156 createElement('x'); | 156 createElement('x'); |
157 shouldThrowDOMException(function() { | 157 shouldNotThrow('element.classList.contains("")'); |
158 element.classList.contains(''); | |
159 }, DOMException.SYNTAX_ERR); | |
160 | 158 |
161 createElement('x y'); | 159 createElement('x y'); |
162 shouldThrowDOMException(function() { | 160 shouldNotThrow('element.classList.contains("x y")'); |
163 element.classList.contains('x y'); | |
164 }, DOMException.INVALID_CHARACTER_ERR); | |
165 | 161 |
166 createElement(''); | 162 createElement(''); |
167 shouldThrowDOMException(function() { | 163 shouldThrowDOMException(function() { |
168 element.classList.add(''); | 164 element.classList.add(''); |
169 }, DOMException.SYNTAX_ERR); | 165 }, DOMException.SYNTAX_ERR); |
170 | 166 |
171 createElement(''); | 167 createElement(''); |
172 shouldThrowDOMException(function() { | 168 shouldThrowDOMException(function() { |
173 element.classList.add('x y'); | 169 element.classList.add('x y'); |
174 }, DOMException.INVALID_CHARACTER_ERR); | 170 }, DOMException.INVALID_CHARACTER_ERR); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 element.classList.remove('a', 'c'); | 364 element.classList.remove('a', 'c'); |
369 shouldBe('observer.takeRecords().length', '1'); | 365 shouldBe('observer.takeRecords().length', '1'); |
370 | 366 |
371 // iterable<DOMString>; | 367 // iterable<DOMString>; |
372 createElement('a b c'); | 368 createElement('a b c'); |
373 var seen = []; | 369 var seen = []; |
374 for (var t of element.classList) { | 370 for (var t of element.classList) { |
375 seen.push(t); | 371 seen.push(t); |
376 } | 372 } |
377 shouldBeTrue("areArraysEqual(seen, ['a', 'b', 'c'])"); | 373 shouldBeTrue("areArraysEqual(seen, ['a', 'b', 'c'])"); |
OLD | NEW |