Skip to content

Commit

Permalink
Update test using the latest DOM spec
Browse files Browse the repository at this point in the history
  • Loading branch information
deniak committed Dec 5, 2013
1 parent 00acf55 commit c8f54a7
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions html/dom/elements/global-attributes/classlist-casesensitive.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
assert_not_equals( getComputedStyle(elem,null).fontStyle, 'italic', 'critical test; required by the testsuite' );
}, 'CSS .foo selectors must not match elements without any class');
test(function () {
assert_equals( secondelem.classList.length, 2, 'duplicates in initial string should be preserved' );
assert_equals( secondelem.classList.length, 1, 'duplicates in initial string should be removed per http://dom.spec.whatwg.org/#concept-class' );
assert_equals( secondelem.classList.item(0), 'test' );
assert_true( secondelem.classList.contains('test') );
}, 'classList must be correct for an element that has classes');
Expand All @@ -49,7 +49,7 @@
}, 'classList.item() must return null for negative index');
test(function () {
/* the normative part of the spec states that:
"unless the length is zero, in which case there are no supported property indices"
"unless tokens is empty, in which case there are no supported property indices"
...
"The term[...] supported property indices [is] used as defined in the WebIDL specification."
WebIDL creates actual OwnProperties and then [] just acts as a normal property lookup */
Expand All @@ -62,9 +62,9 @@
assert_equals( elem.className, ' ' );
}, 'className should contain initial markup whitespace');
test(function () {
assert_equals( elem.classList + '', ' ', 'implicit' );
assert_equals( elem.classList.toString(), ' ', 'explicit' );
}, 'empty classList should stringify to contain initial markup whitespace');
assert_equals( elem.classList + '', '', 'implicit' );
assert_equals( elem.classList.toString(), '', 'explicit' );
}, 'empty classList should return the empty string since the ordered set parser skip the whitespaces');
test(function () {
assert_throws( 'SYNTAX_ERR', function () { elem.classList.contains(''); } );
}, '.contains(empty_string) must throw a SYNTAX_ERR');
Expand Down Expand Up @@ -135,7 +135,7 @@
}, 'classList[index] must return case-sensitive strings and preserve token order');
test(function () {
/* the normative part of the spec states that:
"unless the length is zero, in which case there are no supported property indices"
"The object's supported property indices are the numbers in the range zero to the number of tokens in tokens minus one"
...
"The term[...] supported property indices [is] used as defined in the WebIDL specification."
WebIDL creates actual OwnProperties and then [] just acts as a normal property lookup */
Expand All @@ -153,13 +153,13 @@
assert_equals( elem.classList.length, 2 );
assert_equals( elem.classList + '', 'foo FOO', 'implicit' );
assert_equals( elem.classList.toString(), 'foo FOO', 'explicit' );
}, 'classList.add must not make any changes if an existing token is added');
}, 'classList.add should not add a token if it already exists');
test(function () {
elem.classList.remove('bar');
assert_equals( elem.classList.length, 2 );
assert_equals( elem.classList + '', 'foo FOO', 'implicit' );
assert_equals( elem.classList.toString(), 'foo FOO', 'explicit' );
}, 'classList.remove must not make any changes if a non-existing token is removed');
}, 'classList.remove removes arguments passed, if they are present.');
test(function () {
elem.classList.remove('foo');
assert_equals( elem.classList.length, 1 );
Expand All @@ -185,27 +185,27 @@
test(function () {
secondelem.className = ' token1 token2 ';
secondelem.classList.remove('token2');
assert_equals( secondelem.classList + '', ' token1', 'implicit' );
assert_equals( secondelem.classList.toString(), ' token1', 'explicit' );
}, 'classList.remove must only remove whitespace around removed tokens');
assert_equals( secondelem.classList + '', 'token1', 'implicit' );
assert_equals( secondelem.classList.toString(), 'token1', 'explicit' );
}, 'classList.remove must collapse whitespaces around each token');
test(function () {
secondelem.className = ' token1 token2 token1 ';
secondelem.classList.remove('token2');
assert_equals( secondelem.classList + '', ' token1 token1 ', 'implicit' );
assert_equals( secondelem.classList.toString(), ' token1 token1 ', 'explicit' );
}, 'classList.remove must collapse multiple whitespace around removed tokens');
assert_equals( secondelem.classList + '', 'token1', 'implicit' );
assert_equals( secondelem.classList.toString(), 'token1', 'explicit' );
}, 'classList.remove must collapse whitespaces around each token and remove duplicates');
test(function () {
secondelem.className = ' token1 token2 token1 ';
secondelem.classList.remove('token1');
assert_equals( secondelem.classList + '', 'token2', 'implicit' );
assert_equals( secondelem.classList.toString(), 'token2', 'explicit' );
}, 'classList.remove must collapse whitespace when removing multiple tokens');
}, 'classList.remove must collapse whitespace when removing duplicate tokens');
test(function () {
secondelem.className = ' token1 token1 ';
secondelem.classList.add('token1');
assert_equals( secondelem.classList + '', ' token1 token1 ', 'implicit' );
assert_equals( secondelem.classList.toString(), ' token1 token1 ', 'explicit' );
}, 'classList.add must not affect whitespace when the token already exists');
assert_equals( secondelem.classList + '', 'token1', 'implicit' );
assert_equals( secondelem.classList.toString(), 'token1', 'explicit' );
}, 'classList.add must collapse whitespaces and remove duplicates when adding a token that already exists');
test(function () {
assert_true(elem.classList.toggle('foo'));
assert_equals( elem.classList.length, 2 );
Expand Down Expand Up @@ -245,7 +245,7 @@
WebIDL creates actual OwnProperties and then [] just acts as a normal property lookup */
assert_equals( elem.classList[0], undefined );
}, 'classList[0] must be undefined when all classes have been removed');
//if the last character of DOMTokenSting underlying character is not a space character, append U+0020", where "space character" is from " \t\r\n\f"
// The ordered set parser must skip ASCII whitespace (U+0009, U+000A, U+000C, U+000D, and U+0020.)
test(function () {
var foo = document.createElement('div');
foo.className = 'a ';
Expand All @@ -256,25 +256,25 @@
var foo = document.createElement('div');
foo.className = 'a\t';
foo.classList.add('b');
assert_equals(foo.className,'a\tb');
assert_equals(foo.className,'a b');
}, 'classList.add should treat \\t as a space');
test(function () {
var foo = document.createElement('div');
foo.className = 'a\r';
foo.classList.add('b');
assert_equals(foo.className,'a\rb');
assert_equals(foo.className,'a b');
}, 'classList.add should treat \\r as a space');
test(function () {
var foo = document.createElement('div');
foo.className = 'a\n';
foo.classList.add('b');
assert_equals(foo.className,'a\nb');
assert_equals(foo.className,'a b');
}, 'classList.add should treat \\n as a space');
test(function () {
var foo = document.createElement('div');
foo.className = 'a\f';
foo.classList.add('b');
assert_equals(foo.className,'a\fb');
assert_equals(foo.className,'a b');
}, 'classList.add should treat \\f as a space');
test(function () {
//WebIDL and ECMAScript 5 - a readonly property has a getter but not a setter
Expand Down

0 comments on commit c8f54a7

Please sign in to comment.