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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/HTMLElement/script-tests/class-list.js

Issue 1629403003: Merge DOMSettableTokensList into DOMTokensList (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moar fixed tests Created 4 years, 10 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
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
11 debug('Tests from http://simon.html5.org/test/html/dom/reflecting/DOMTokenList/' ); 11 debug('Tests from http://simon.html5.org/test/html/dom/reflecting/DOMTokenList/' );
12 12
13 // http://simon.html5.org/test/html/dom/reflecting/DOMTokenList/setting/001.htm 13 // Even though classList is readonly, PutForwards=value means that its value is forwarded.
14 // Firefox throws here but WebKit does not throw on setting readonly idl
15 // attributes.
16 createElement('x'); 14 createElement('x');
17 try { 15 try {
18 element.classList = 'y'; 16 element.classList = 'y';
19 shouldBeEqualToString('String(element.classList)', 'x'); 17 shouldBeEqualToString('String(element.classList)', 'y');
18 shouldBeEqualToString('String(element.className)', 'y');
20 } catch (ex) { 19 } catch (ex) {
21 testPassed('Throwing on set is acceptable'); 20 testFailed('Throwing on set should not happen');
22 } 21 }
23 22
24 // http://simon.html5.org/test/html/dom/reflecting/DOMTokenList/getting/001.htm 23 // http://simon.html5.org/test/html/dom/reflecting/DOMTokenList/getting/001.htm
25 createElement(''); 24 createElement('');
26 shouldEvaluateTo('element.classList.length', 0); 25 shouldEvaluateTo('element.classList.length', 0);
27 26
28 // http://simon.html5.org/test/html/dom/reflecting/DOMTokenList/getting/002.htm 27 // http://simon.html5.org/test/html/dom/reflecting/DOMTokenList/getting/002.htm
29 createElement('x'); 28 createElement('x');
30 shouldEvaluateTo('element.classList.length', 1); 29 shouldEvaluateTo('element.classList.length', 1);
31 30
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 element.classList.remove('a', 'c'); 368 element.classList.remove('a', 'c');
370 shouldBe('observer.takeRecords().length', '1'); 369 shouldBe('observer.takeRecords().length', '1');
371 370
372 // iterable<DOMString>; 371 // iterable<DOMString>;
373 createElement('a b c'); 372 createElement('a b c');
374 var seen = []; 373 var seen = [];
375 for (var t of element.classList) { 374 for (var t of element.classList) {
376 seen.push(t); 375 seen.push(t);
377 } 376 }
378 shouldBeTrue("areArraysEqual(seen, ['a', 'b', 'c'])"); 377 shouldBeTrue("areArraysEqual(seen, ['a', 'b', 'c'])");
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698