| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 shouldBeEqualToString('element.className', 'x'); | 42 shouldBeEqualToString('element.className', 'x'); |
| 43 | 43 |
| 44 // http://simon.html5.org/test/html/dom/reflecting/DOMTokenList/getting/006.htm | 44 // http://simon.html5.org/test/html/dom/reflecting/DOMTokenList/getting/006.htm |
| 45 createElement('x'); | 45 createElement('x'); |
| 46 element.classList.add('x'); | 46 element.classList.add('x'); |
| 47 shouldBeEqualToString('element.className', 'x'); | 47 shouldBeEqualToString('element.className', 'x'); |
| 48 | 48 |
| 49 // http://simon.html5.org/test/html/dom/reflecting/DOMTokenList/getting/007.htm | 49 // http://simon.html5.org/test/html/dom/reflecting/DOMTokenList/getting/007.htm |
| 50 createElement('x x'); | 50 createElement('x x'); |
| 51 element.classList.add('x'); | 51 element.classList.add('x'); |
| 52 shouldBeEqualToString('element.className', 'x x'); | 52 shouldBeEqualToString('element.className', 'x x'); |
| 53 | 53 |
| 54 // http://simon.html5.org/test/html/dom/reflecting/DOMTokenList/getting/008.htm | 54 // http://simon.html5.org/test/html/dom/reflecting/DOMTokenList/getting/008.htm |
| 55 createElement('y'); | 55 createElement('y'); |
| 56 element.classList.add('x'); | 56 element.classList.add('x'); |
| 57 shouldBeEqualToString('element.className', 'y x'); | 57 shouldBeEqualToString('element.className', 'y x'); |
| 58 | 58 |
| 59 // http://simon.html5.org/test/html/dom/reflecting/DOMTokenList/getting/009.htm | 59 // http://simon.html5.org/test/html/dom/reflecting/DOMTokenList/getting/009.htm |
| 60 createElement(''); | 60 createElement(''); |
| 61 element.classList.remove('x'); | 61 element.classList.remove('x'); |
| 62 shouldBeEqualToString('element.className', ''); | 62 shouldBeEqualToString('element.className', ''); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 113 |
| 114 | 114 |
| 115 debug('Testing add in presence of trailing white spaces.'); | 115 debug('Testing add in presence of trailing white spaces.'); |
| 116 | 116 |
| 117 createElement('x '); | 117 createElement('x '); |
| 118 element.classList.add('y'); | 118 element.classList.add('y'); |
| 119 shouldBeEqualToString('element.className', 'x y'); | 119 shouldBeEqualToString('element.className', 'x y'); |
| 120 | 120 |
| 121 createElement('x\t'); | 121 createElement('x\t'); |
| 122 element.classList.add('y'); | 122 element.classList.add('y'); |
| 123 shouldBeEqualToString('element.className', 'x\ty'); | 123 shouldBeEqualToString('element.className', 'x y'); |
| 124 | 124 |
| 125 createElement(' '); | 125 createElement(' '); |
| 126 element.classList.add('y'); | 126 element.classList.add('y'); |
| 127 shouldBeEqualToString('element.className', ' y'); | 127 shouldBeEqualToString('element.className', 'y'); |
| 128 | 128 |
| 129 | 129 |
| 130 debug('Test invalid tokens'); | 130 debug('Test invalid tokens'); |
| 131 | 131 |
| 132 // Testing exception due to invalid token | 132 // Testing exception due to invalid token |
| 133 | 133 |
| 134 // shouldThrow from js-test.js is not sufficient. | 134 // shouldThrow from js-test.js is not sufficient. |
| 135 function shouldThrowDOMException(f, ec) | 135 function shouldThrowDOMException(f, ec) |
| 136 { | 136 { |
| 137 try { | 137 try { |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 element.classList.remove('a', 'c'); | 364 element.classList.remove('a', 'c'); |
| 365 shouldBe('observer.takeRecords().length', '1'); | 365 shouldBe('observer.takeRecords().length', '1'); |
| 366 | 366 |
| 367 // iterable<DOMString>; | 367 // iterable<DOMString>; |
| 368 createElement('a b c'); | 368 createElement('a b c'); |
| 369 var seen = []; | 369 var seen = []; |
| 370 for (var t of element.classList) { | 370 for (var t of element.classList) { |
| 371 seen.push(t); | 371 seen.push(t); |
| 372 } | 372 } |
| 373 shouldBeTrue("areArraysEqual(seen, ['a', 'b', 'c'])"); | 373 shouldBeTrue("areArraysEqual(seen, ['a', 'b', 'c'])"); |
| OLD | NEW |