Skip to content

Commit

Permalink
Merge pull request web-platform-tests#459 from w3c/deniak/opera-class…
Browse files Browse the repository at this point in the history
…list

case sensitivity of the classList attribute
  • Loading branch information
zcorpan committed Dec 6, 2013
2 parents b382431 + 8d695ac commit 453ab70
Showing 1 changed file with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!doctype html>
<html>
<head class="test test">
<title class=" ">HTMLElement.classList in case-sensitive documents</title>
<link rel="" href="http://www.w3.org/TR/html5/global-attributes.html#dom-classlist">
<title class=" ">Element.classList in case-sensitive documents</title>
<link rel="help" href="http://dom.spec.whatwg.org/#concept-class">
<script type="text/javascript" src="/resources/testharness.js"></script>
<script type="text/javascript" src="/resources/testharnessreport.js"></script>
<style type="text/css">
Expand All @@ -12,10 +12,10 @@
var elem = document.getElementsByTagName('title')[0], secondelem = document.getElementsByTagName('head')[0];
test(function () {
assert_equals( typeof elem.classList, 'object', 'critical test; ignore any results after this' );
}, 'HTMLElement.classList must exist as an object');
}, 'Element.classList must exist as an object');
test(function () {
assert_equals( typeof document.documentElement.classList, 'object' );
}, 'HTMLElement.classList must exist as an object even if the element has no class attribute');
}, 'Element.classList must exist as an object even if the element has no class attribute');
test(function () {
assert_true( !!window.DOMTokenList );
}, 'DOMTokenList should be exposed for prototyping');
Expand All @@ -26,12 +26,12 @@
test(function () {
assert_true( elem.classList instanceof window.DOMTokenList );
assert_equals( elem.classList.constructor, window.DOMTokenList );
}, 'HTMLElement.classList must implement DOMTokenList');
}, 'Element.classList must implement DOMTokenList');
test(function () {
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 453ab70

Please sign in to comment.