Tests the classList attribute and its properties.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Tests from http://simon.html5.org/test/html/dom/reflecting/DOMTokenList/
PASS String(element.classList) is "y"
PASS String(element.className) is "y"
PASS element.classList.length is 0
PASS element.classList.length is 1
PASS element.classList.length is 1
PASS element.classList.length is 2
PASS element.className is "x"
PASS element.className is "x"
PASS element.className is "x"
PASS element.className is "y x"
PASS element.className is ""
PASS element.className is ""
PASS element.className is "y"
PASS element.className is "y"
Ensure that we can handle empty class name correctly
PASS element.classList.toggle('x') is true
PASS element.className is "x"
PASS element.classList.toggle('x') is false
PASS element.className is ""
PASS element.classList.contains('x') is false
PASS element.classList[1] is undefined.
Test toggle with force argument
PASS element.classList.toggle('x', true) is true
PASS element.className is "x"
PASS element.classList.toggle('x', true) is true
PASS element.className is "x"
PASS element.classList.toggle('x', false) is false
PASS element.className is ""
PASS element.classList.toggle('x', false) is false
PASS element.className is ""
PASS element.classList.toggle('', true) threw expected DOMException with code 12
PASS element.classList.toggle('x y', false) threw expected DOMException with code 5
Testing add in presence of trailing white spaces.
PASS element.className is "x y"
PASS element.className is "x y"
PASS element.className is "y"
Test invalid tokens
PASS element.classList.contains("") did not throw exception.
PASS element.classList.contains("x y") did not throw exception.
PASS element.classList.add('') threw expected DOMException with code 12
PASS element.classList.add('x y') threw expected DOMException with code 5
PASS element.classList.remove('') threw expected DOMException with code 12
PASS element.classList.remove('x y') threw expected DOMException with code 5
PASS element.classList.toggle('') threw expected DOMException with code 12
PASS element.classList.toggle('x y') threw expected DOMException with code 5
PASS element.classList.toggle() threw exception TypeError: Failed to execute 'toggle' on 'DOMTokenList': 1 argument required, but only 0 present..
Indexing
PASS element.classList[0] is "x"
PASS element.classList.item(0) is "x"
PASS element.classList[1] is undefined.
PASS element.classList.item(1) is null
PASS element.classList[1] is "y"
PASS element.classList.item(1) is "y"
PASS element.classList[0] is undefined.
PASS element.classList.item(0) is null
PASS element.classList[4] is undefined.
PASS element.classList.item(4) is null
PASS element.classList[-1] is undefined.
PASS element.classList.item(-1) is null
PASS element.classList.item() threw exception TypeError: Failed to execute 'item' on 'DOMTokenList': 1 argument required, but only 0 present..
Test case since DOMTokenList is case sensitive
PASS element.classList.contains('x') is true
PASS element.classList.contains('X') is false
PASS element.classList[0] is "x"
PASS element.classList.contains() threw exception TypeError: Failed to execute 'contains' on 'DOMTokenList': 1 argument required, but only 0 present..
PASS element.classList.contains('X') is true
PASS element.classList.contains('x') is false
PASS element.classList[0] is "X"
Testing whitespace
PASS element.classList.length is 2
PASS element.classList.length is 2
PASS element.classList.length is 2
PASS element.classList.length is 2
PASS element.classList.length is 2
DOMTokenList presence and type
PASS 'undefined' != typeof DOMTokenList is true
PASS typeof DOMTokenList.prototype is "object"
PASS typeof element.classList is "object"
PASS element.classList.constructor is DOMTokenList
PASS element.classList === element.classList is true
PASS document.body.classList.contains("FAIL") is true
PASS document.body.className is ""
Variadic calls
PASS element.className is "a b"
PASS element.className is "a b c"
PASS element.className is "a b c null d undefined 0 false"
PASS element.className is "a b"
PASS element.classList.add('a', 'b', '') threw expected DOMException with code 12
PASS element.className is ""
PASS element.classList.add('a', 'b', 'c d') threw expected DOMException with code 5
PASS element.className is ""
PASS element.classList.add("a", {toString: function() { throw new Error("user error"); }}, "b") threw exception Error: user error.
PASS element.className is ""
PASS element.classList.add() did not throw exception.
PASS observer.takeRecords().length is 1
PASS element.className is "b c"
PASS element.className is "a c"
PASS element.className is "a b"
PASS element.className is "b d"
PASS element.className is "d"
PASS element.className is "a b c"
PASS element.classList.remove('a', 'b', '') threw expected DOMException with code 12
PASS element.className is "a b"
PASS element.classList.remove('a', 'b', 'c d') threw expected DOMException with code 5
PASS element.className is "a b"
PASS element.classList.remove("a", {toString: function() { throw new Error("user error"); }}, "b") threw exception Error: user error.
PASS element.className is "a b"
PASS element.classList.remove() did not throw exception.
PASS observer.takeRecords().length is 1
PASS areArraysEqual(seen, ['a', 'b', 'c']) is true
PASS successfullyParsed is true
TEST COMPLETE