2010-11-04 Kenichi Ishibashi <bashi@google.com>

        Reviewed by Kent Tamura.

        [HTML5][Forms] Support for <output> element
        https://bugs.webkit.org/show_bug.cgi?id=29363

        Adds tests for the DOMSettableTokenList and the output element.

        * fast/dom/HTMLOutputElement/dom-settable-token-list-expected.txt: Added.
        * fast/dom/HTMLOutputElement/dom-settable-token-list.html: Added.
        * fast/dom/HTMLOutputElement/htmloutputelement-expected.txt: Added.
        * fast/dom/HTMLOutputElement/htmloutputelement-reset-event-expected.txt: Added.
        * fast/dom/HTMLOutputElement/htmloutputelement-reset-event.html: Added.
        * fast/dom/HTMLOutputElement/htmloutputelement-validity-expected.txt: Added.
        * fast/dom/HTMLOutputElement/htmloutputelement-validity.html: Added.
        * fast/dom/HTMLOutputElement/htmloutputelement-value-expected.txt: Added.
        * fast/dom/HTMLOutputElement/htmloutputelement-value.html: Added.
        * fast/dom/HTMLOutputElement/htmloutputelement.html: Added.
        * fast/dom/HTMLOutputElement/script-tests/dom-settable-token-list.js: Added.
        (createElement):
        * fast/dom/HTMLOutputElement/script-tests/htmloutputelement-reset-event.js: Added.
        * fast/dom/HTMLOutputElement/script-tests/htmloutputelement-validity.js: Added.
        * fast/dom/HTMLOutputElement/script-tests/htmloutputelement-value.js: Added.
        * fast/dom/Window/window-properties-expected.txt: Updated expectation.
        * fast/dom/Window/window-property-descriptors-expected.txt: Updated expectation.
        * fast/dom/prototype-inheritance-2-expected.txt: Updated expectation.
        * fast/dom/prototype-inheritance-expected.txt: Updated expectation.
        * fast/js/global-constructors-expected.txt: Updated expectation.
        * platform/chromium/fast/dom/prototype-inheritance-expected.txt: Updated expectation.
        * platform/gtk/fast/dom/Window/window-properties-expected.txt: Updated expectation.
        * platform/gtk/fast/dom/Window/window-property-descriptors-expected.txt: Updated expectation.
        * platform/gtk/fast/dom/prototype-inheritance-expected.txt: Updated expectation.
        * platform/gtk/fast/js/global-constructors-expected.txt: Updated expectation.
        * platform/qt/fast/dom/Window/window-properties-expected.txt: Updated expectation.
        * platform/qt/fast/dom/Window/window-property-descriptors-expected.txt: Updated expectation.
        * platform/qt/fast/dom/prototype-inheritance-expected.txt: Updated expectation.
        * platform/qt/fast/js/global-constructors-expected.txt: Updated expectation.
        * platform/win/fast/dom/Window/window-property-descriptors-expected.txt: Updated expectation.
        * platform/win/fast/dom/prototype-inheritance-2-expected.txt: Updated expectation.
        * platform/win/fast/dom/prototype-inheritance-expected.txt: Updated expectation.
        * platform/win/fast/js/global-constructors-expected.txt: Updated expectation.
2010-11-04  Kenichi Ishibashi  <bashi@google.com>

        Reviewed by Kent Tamura.

        [HTML5][Forms] Support for <output> element
        https://bugs.webkit.org/show_bug.cgi?id=29363

        Support for <output> element.

        Tests: fast/dom/HTMLOutputElement/dom-settable-token-list.html
               fast/dom/HTMLOutputElement/htmloutputelement-reset-event.html
               fast/dom/HTMLOutputElement/htmloutputelement-validity.html
               fast/dom/HTMLOutputElement/htmloutputelement-value.html
               fast/dom/HTMLOutputElement/htmloutputelement.html

        * Android.derived.jscbindings.mk: Added JSHTMLOutputElement.h.
        * Android.derived.v8bindings.mk: Added V8HTMLOutputElement.h.
        * Android.jscbindings.mk: Added JSHTMLOutputElementCustom.cpp.
        * Android.mk: Added HTMLOutputElement.cpp.
        * Android.v8bindings.mk: Added V8HTMLOutputElementCustom.cpp.
        * CMakeLists.txt: Added HTMLOutputElement.{idl,cpp} and JSHTMLOutputElementCustom.cpp.
        * DerivedSources.cpp: Added JSHTMLOutputElement.cpp.
        * DerivedSources.make: Added HTMLOutputElement entry.
        * GNUmakefile.am: Added JSHTMLOutputElement.{cpp,h}
        * WebCore.gypi: Added HTMLOutputElement.{idl,cpp,h}, JSHTMLOutputElementCustom.cpp and V8HTMLOutputElementCustom.cpp
        * WebCore.pri: Added HTMLOutputElement.idl.
        * WebCore.pro: Added V8HTMLOutputElementCustom.cpp, JSHTMLOutputElementCustom.cpp and HTMLOutputElement.cpp.
        * WebCore.vcproj/WebCore.vcproj: Added entries for JSHTMLOutputElement.{cpp,h} and JSHTMLOutputElementCustom.cpp.
        * WebCore.xcodeproj/project.pbxproj: Added entries for JSHTMLOutputElementCustom.cpp, HTMLOutputElement.{cpp,h,idl}, JSHTMLOutputElement.{cpp,h}
        * bindings/js/JSBindingsAllInOne.cpp: Added JSHTMLOutputElementCustom.cpp.
        * bindings/js/JSHTMLOutputElementCustom.cpp: Added.
        (WebCore::JSHTMLOutputElement::htmlFor):
        (WebCore::JSHTMLOutputElement::setHtmlFor):
        * bindings/v8/custom/V8DOMSettableTokenListCustom.cpp: Modified.
        (WebCore::V8DOMSettableTokenList::indexedPropertyGetter): Returns null if the index is out of range.
        * bindings/v8/custom/V8HTMLOutputElementCustom.cpp: Added.
        (WebCore::V8HTMLOutputElement::htmlForAccessorGetter):
        (WebCore::V8HTMLOutputElement::htmlForAccessorSetter):
        * css/html.css: Added a default style of output element.
        (output):
        * html/DOMSettableTokenList.cpp: Fix bugs.
        (WebCore::DOMSettableTokenList::item): Returns null string if the index is out of range.
        (WebCore::DOMSettableTokenList::addInternal): Added check m_tokens.isNull().
        (WebCore::DOMSettableTokenList::setValue): Set the value case sensitive.
        * html/HTMLOutputElement.cpp: Added.
        (WebCore::HTMLOutputElement::HTMLOutputElement):
        (WebCore::HTMLOutputElement::create):
        (WebCore::HTMLOutputElement::formControlType):
        (WebCore::HTMLOutputElement::parseMappedAttribute):
        (WebCore::HTMLOutputElement::htmlFor):
        (WebCore::HTMLOutputElement::setFor):
        (WebCore::HTMLOutputElement::setForm):
        (WebCore::HTMLOutputElement::childrenChanged):
        (WebCore::HTMLOutputElement::reset):
        (WebCore::HTMLOutputElement::value):
        (WebCore::HTMLOutputElement::setValue):
        (WebCore::HTMLOutputElement::defaultValue):
        (WebCore::HTMLOutputElement::setDefaultValue):
        (WebCore::HTMLOutputElement::setTextContentInternal):
        * html/HTMLOutputElement.h: Added.
        (WebCore::HTMLOutputElement::isEnumeratable):
        (WebCore::HTMLOutputElement::willValidate):
        * html/HTMLOutputElement.idl: Added.
        * html/HTMLTagNames.in: Added "output".
        * page/DOMWindow.idl: Added an attribute for HTMLOutputElement.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@71373 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1fab1fa4
2010-11-04 Kenichi Ishibashi <bashi@google.com>
Reviewed by Kent Tamura.
[HTML5][Forms] Support for <output> element
https://bugs.webkit.org/show_bug.cgi?id=29363
Adds tests for the DOMSettableTokenList and the output element.
* fast/dom/HTMLOutputElement/dom-settable-token-list-expected.txt: Added.
* fast/dom/HTMLOutputElement/dom-settable-token-list.html: Added.
* fast/dom/HTMLOutputElement/htmloutputelement-expected.txt: Added.
* fast/dom/HTMLOutputElement/htmloutputelement-reset-event-expected.txt: Added.
* fast/dom/HTMLOutputElement/htmloutputelement-reset-event.html: Added.
* fast/dom/HTMLOutputElement/htmloutputelement-validity-expected.txt: Added.
* fast/dom/HTMLOutputElement/htmloutputelement-validity.html: Added.
* fast/dom/HTMLOutputElement/htmloutputelement-value-expected.txt: Added.
* fast/dom/HTMLOutputElement/htmloutputelement-value.html: Added.
* fast/dom/HTMLOutputElement/htmloutputelement.html: Added.
* fast/dom/HTMLOutputElement/script-tests/dom-settable-token-list.js: Added.
(createElement):
* fast/dom/HTMLOutputElement/script-tests/htmloutputelement-reset-event.js: Added.
* fast/dom/HTMLOutputElement/script-tests/htmloutputelement-validity.js: Added.
* fast/dom/HTMLOutputElement/script-tests/htmloutputelement-value.js: Added.
* fast/dom/Window/window-properties-expected.txt: Updated expectation.
* fast/dom/Window/window-property-descriptors-expected.txt: Updated expectation.
* fast/dom/prototype-inheritance-2-expected.txt: Updated expectation.
* fast/dom/prototype-inheritance-expected.txt: Updated expectation.
* fast/js/global-constructors-expected.txt: Updated expectation.
* platform/chromium/fast/dom/prototype-inheritance-expected.txt: Updated expectation.
* platform/gtk/fast/dom/Window/window-properties-expected.txt: Updated expectation.
* platform/gtk/fast/dom/Window/window-property-descriptors-expected.txt: Updated expectation.
* platform/gtk/fast/dom/prototype-inheritance-expected.txt: Updated expectation.
* platform/gtk/fast/js/global-constructors-expected.txt: Updated expectation.
* platform/qt/fast/dom/Window/window-properties-expected.txt: Updated expectation.
* platform/qt/fast/dom/Window/window-property-descriptors-expected.txt: Updated expectation.
* platform/qt/fast/dom/prototype-inheritance-expected.txt: Updated expectation.
* platform/qt/fast/js/global-constructors-expected.txt: Updated expectation.
* platform/win/fast/dom/Window/window-property-descriptors-expected.txt: Updated expectation.
* platform/win/fast/dom/prototype-inheritance-2-expected.txt: Updated expectation.
* platform/win/fast/dom/prototype-inheritance-expected.txt: Updated expectation.
* platform/win/fast/js/global-constructors-expected.txt: Updated expectation.
2010-11-04 Zhenyao Mo <zmo@google.com>
Reviewed by Kenneth Russell.
Tests the htmlFor 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.htmlFor) is "y"
PASS element.htmlFor.length is 0
PASS element.htmlFor.length is 1
PASS element.htmlFor.length is 2
PASS element.htmlFor.length is 2
PASS element.htmlFor.toString() is "x"
PASS element.htmlFor.toString() is "x"
PASS element.htmlFor.toString() is "x x"
PASS element.htmlFor.toString() is "y x"
PASS element.htmlFor.toString() is ""
PASS element.htmlFor.toString() is ""
PASS element.htmlFor.toString() is " y y "
PASS element.htmlFor.toString() is "y"
- Ensure that we can handle empty form attribute correctly
PASS list.value is "x"
PASS list.value is ""
PASS element.htmlFor.contains('x') is false
PASS element.htmlFor[1] is null
PASS element.htmlFor.contains('x') is true
PASS element.htmlFor[1] is null
- Testing add in presence of trailing white spaces.
PASS element.htmlFor.toString() is "x y"
PASS element.htmlFor.toString() is "x y"
PASS element.htmlFor.toString() is " y"
- Test invalid tokens
PASS element.htmlFor.contains('') threw expected DOMException with code 12
PASS element.htmlFor.contains('x y') threw expected DOMException with code 5
PASS element.htmlFor.add('') threw expected DOMException with code 12
PASS element.htmlFor.add('x y') threw expected DOMException with code 5
PASS element.htmlFor.remove('') threw expected DOMException with code 12
PASS element.htmlFor.remove('x y') threw expected DOMException with code 5
PASS element.htmlFor.toggle('') threw expected DOMException with code 12
PASS element.htmlFor.toggle('x y') threw expected DOMException with code 5
- Indexing
PASS element.htmlFor[0] is "x"
PASS element.htmlFor.item(0) is "x"
PASS element.htmlFor[1] is "x"
PASS element.htmlFor.item(1) is "x"
PASS element.htmlFor[1] is "y"
PASS element.htmlFor.item(1) is "y"
PASS element.htmlFor[0] is null
PASS element.htmlFor.item(0) is null
PASS element.htmlFor[4] is null
PASS element.htmlFor.item(4) is null
PASS element.htmlFor[-1] is undefined.
PASS element.htmlFor.item(-1) is null
- Test case since DOMTokenList is case sensitive
PASS element.htmlFor.contains('x') is true
PASS element.htmlFor.contains('X') is false
PASS element.htmlFor[0] is "x"
PASS element.htmlFor.contains('X') is true
PASS element.htmlFor.contains('x') is false
PASS element.htmlFor[0] is "X"
- Testing whitespace
PASS element.htmlFor.length is 2
PASS element.htmlFor.length is 2
PASS element.htmlFor.length is 2
PASS element.htmlFor.length is 2
PASS element.htmlFor.length is 2
- DOMSettableTokenList presence and type
PASS 'undefined' != typeof DOMSettableTokenList is true
PASS typeof DOMSettableTokenList.prototype is "object"
PASS typeof element.htmlFor is "object"
PASS element.htmlFor.constructor is DOMSettableTokenList
PASS element.htmlFor === element.htmlFor is true
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="../../js/resources/js-test-style.css">
<script src="../../js/resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script src="script-tests/dom-settable-token-list.js"></script>
<script src="../../js/resources/js-test-post.js"></script>
</body>
</html>
Tests for content attributes of the output element.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS output1.type is "output"
PASS output1.name is "output1"
PASS output1.value is "A value"
PASS output2.htmlFor.length is 1
PASS output2.htmlFor[0] is "for-target1"
PASS output2.htmlFor.value is "for-target1"
PASS output3.htmlFor.length is 2
PASS output3.htmlFor[0] is "for-target1"
PASS output3.htmlFor[1] is "for-target2"
PASS output3.htmlFor.value is " for-target1 for-target2 "
PASS successfullyParsed is true
TEST COMPLETE
A value
A Test for sending a reset event to output elements.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
- Sets the value attribute of the output element.
PASS output.defaultValue is "defaultValue"
PASS output.value is "aValue"
PASS output.innerText is "aValue"
PASS output.innerHTML is "aValue"
- Sends a reset event to reset the value to the default value.
PASS output.defaultValue is "defaultValue"
PASS output.value is "defaultValue"
PASS output.innerText is "defaultValue"
PASS output.innerHTML is "defaultValue"
- Ensures that the value mode flags is in mode "default".
PASS output.defaultValue is "another defaultValue"
PASS output.value is "another defaultValue"
PASS output.innerText is "another defaultValue"
PASS output.innerHTML is "another defaultValue"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<link rel="stylesheet" href="../../js/resources/js-test-style.css">
<script src="../../js/resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script src="script-tests/htmloutputelement-reset-event.js"></script>
<script src="../../js/resources/js-test-post.js"></script>
</body>
</html>
Tests for the validation APIs of output elements.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
- Ensures whether the willValidate is defined and it always returns false.
PASS typeof output.willValidate is "boolean"
PASS output.willValidate is false
PASS output.willValidate is false
- Ensures validity is always "valid" and validationMessage() always returns an empty string.
PASS output.validationMessage is ""
PASS output.checkValidity() is true
PASS output.validationMessage is ""
PASS output.checkValidity() is true
PASS successfullyParsed is true
TEST COMPLETE
aValue
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<link rel="stylesheet" href="../../js/resources/js-test-style.css">
<script src="../../js/resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script src="script-tests/htmloutputelement-validity.js"></script>
<script src="../../js/resources/js-test-post.js"></script>
</body>
</html>
Tests for assigning the value attribute to output elements.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
- Sets the defaultValue attribute with the value mode flag is in mode "defalut".
PASS output.defaultValue is "defaultValue"
PASS output.value is "defaultValue"
PASS output.innerText is "defaultValue"
PASS output.innerHTML is "defaultValue"
- Sets the value attribute. This will change the value mode flag from "default" to "value".
PASS output.defaultValue is "defaultValue"
PASS output.value is "aValue"
PASS output.innerText is "aValue"
PASS output.innerHTML is "aValue"
- Sets the defaultValue attribute with the value mode flag is in mode "value".
PASS output.defaultValue is "another defaultValue"
PASS output.value is "aValue"
PASS output.innerText is "aValue"
PASS output.innerHTML is "aValue"
- Ensures that setting text to the value attribute works as setTextContent().
PASS output.value is '<strong>A <span style="color: red;">strong</span> text</strong>'
PASS output.innerText is '<strong>A <span style="color: red;">strong</span> text</strong>'
PASS output.innerHTML is '&lt;strong&gt;A &lt;span style="color: red;"&gt;strong&lt;/span&gt; text&lt;/strong&gt;'
- Sets the innerText attribute with the value mode flag is in mode "default".
PASS output.defaultValue is "text"
PASS output.value is "text"
PASS output.innerText is "text"
PASS output.innerHTML is "text"
PASS output.defaultValue is "<strong>strong</strong> text"
PASS output.value is "<strong>strong</strong> text"
PASS output.innerText is "<strong>strong</strong> text"
PASS output.innerHTML is "&lt;strong&gt;strong&lt;/strong&gt; text"
- Sets the innerText attribute with the value mode flag is in mode "value".
PASS output.defaultValue is "defaultValue"
PASS output.value is "text"
PASS output.innerText is "text"
PASS output.innerHTML is "text"
- Sets the innerHTML attribute with the value mode flag is in mode "default".
PASS output.defaultValue is "text"
PASS output.value is "text"
PASS output.innerText is "text"
PASS output.innerHTML is "text"
PASS output.defaultValue is "strong text"
PASS output.value is "strong text"
PASS output.innerText is "strong text"
PASS output.innerHTML is "<strong>strong</strong> text"
- Sets the innerHTML attribute with the value mode flag is in mode "value".
PASS output.defaultValue is "defaultValue"
PASS output.value is "text"
PASS output.innerText is "text"
PASS output.innerHTML is "text"
PASS output.defaultValue is "defaultValue"
PASS output.value is "strong text"
PASS output.innerText is "strong text"
PASS output.innerHTML is "<strong>strong</strong> text"
- Appends a child node to the output element with the value mode flag is in mode "default".
PASS output.defaultValue is "childText"
PASS output.value is "childText"
PASS output.innerText is "childText"
PASS output.innerHTML is "<span>childText</span>"
- Then removes the child node from the output element with the value mode flag is in mode "default".
PASS output.defaultValue is ""
PASS output.value is ""
PASS output.innerText is ""
PASS output.innerHTML is ""
- Appends a child node to the output element with the value mode flag is in mode "value".
PASS output.defaultValue is "defaultValue"
PASS output.value is "aValue and childText"
PASS output.innerText is "aValue and childText"
PASS output.innerHTML is "aValue<span> and childText</span>"
- Then removes the child node from the output element with the value mode flag is in mode "default".
PASS output.defaultValue is "defaultValue"
PASS output.value is "aValue"
PASS output.innerText is "aValue"
PASS output.innerHTML is "aValue"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<link rel="stylesheet" href="../../js/resources/js-test-style.css">
<script src="../../js/resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script src="script-tests/htmloutputelement-value.js"></script>
<script src="../../js/resources/js-test-post.js"></script>
</body>
</html>
<html>
<head>
<link rel="stylesheet" href="../../js/resources/js-test-style.css">
<script src="../../js/resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<span id="for-target1"></span>
<span id="for-target2"></span>
<output id="output1" name="output1">A value</output>
<output id="output2" for="for-target1"></output>
<output id="output3" for=" for-target1 for-target2 "></output>
<script>
description('Tests for content attributes of the output element.');
var output1 = document.getElementById('output1');
var output2 = document.getElementById('output2');
var output3 = document.getElementById('output3');
shouldBeEqualToString('output1.type', 'output');
shouldBeEqualToString('output1.name', 'output1');
shouldBeEqualToString('output1.value', 'A value');
shouldEvaluateTo('output2.htmlFor.length', 1);
shouldBeEqualToString('output2.htmlFor[0]', 'for-target1');
shouldBeEqualToString('output2.htmlFor.value', 'for-target1');
shouldEvaluateTo('output3.htmlFor.length', 2);
shouldBeEqualToString('output3.htmlFor[0]', 'for-target1');
shouldBeEqualToString('output3.htmlFor[1]', 'for-target2');
shouldBeEqualToString('output3.htmlFor.value', ' for-target1 for-target2 ');
var successfullyParsed = true;
</script>
<script src="../../js/resources/js-test-post.js"></script>
</body>
</html>
// This test mostly comes from fast/dom/HTMLElement/script-tests/class-list.js
description('Tests the htmlFor attribute and its properties.');
var container = document.createElement('div');
document.body.appendChild(container);
var element;
function createElement(tokenList)
{
container.innerHTML = '<output for="' + tokenList + '"></output>';
element = container.lastChild;
}
debug('- Tests from http://simon.html5.org/test/html/dom/reflecting/DOMTokenList/');
// Setting a value to a DOMSettableTokenList should be forwared to the 'value' attribute.
createElement('x');
element.htmlFor = 'y';
shouldBeEqualToString('String(element.htmlFor)', 'y');
// http://simon.html5.org/test/html/dom/reflecting/DOMTokenList/getting/001.htm
createElement('');
shouldEvaluateTo('element.htmlFor.length', 0);
// http://simon.html5.org/test/html/dom/reflecting/DOMTokenList/getting/002.htm
createElement('x');
shouldEvaluateTo('element.htmlFor.length', 1);
// http://simon.html5.org/test/html/dom/reflecting/DOMTokenList/getting/003.htm
createElement('x x');
shouldEvaluateTo('element.htmlFor.length', 2);
// http://simon.html5.org/test/html/dom/reflecting/DOMTokenList/getting/004.htm
createElement('x y');
shouldEvaluateTo('element.htmlFor.length', 2);
// http://simon.html5.org/test/html/dom/reflecting/DOMTokenList/getting/005.htm
createElement('');
element.htmlFor.add('x');
shouldBeEqualToString('element.htmlFor.toString()', 'x');
// http://simon.html5.org/test/html/dom/reflecting/DOMTokenList/getting/006.htm
createElement('x');
element.htmlFor.add('x');
shouldBeEqualToString('element.htmlFor.toString()', 'x');
// http://simon.html5.org/test/html/dom/reflecting/DOMTokenList/getting/007.htm
createElement('x x');
element.htmlFor.add('x');
shouldBeEqualToString('element.htmlFor.toString()', 'x x');
// http://simon.html5.org/test/html/dom/reflecting/DOMTokenList/getting/008.htm
createElement('y');
element.htmlFor.add('x');
shouldBeEqualToString('element.htmlFor.toString()', 'y x');
// http://simon.html5.org/test/html/dom/reflecting/DOMTokenList/getting/009.htm
createElement('');
element.htmlFor.remove('x');
shouldBeEqualToString('element.htmlFor.toString()', '');
// http://simon.html5.org/test/html/dom/reflecting/DOMTokenList/getting/010.htm
createElement('x');
element.htmlFor.remove('x');
shouldBeEqualToString('element.htmlFor.toString()', '');
// http://simon.html5.org/test/html/dom/reflecting/DOMTokenList/getting/011.htm
createElement(' y x y ');
element.htmlFor.remove('x');
shouldBeEqualToString('element.htmlFor.toString()', ' y y ');
// http://simon.html5.org/test/html/dom/reflecting/DOMTokenList/getting/012.htm
createElement(' x y x ');
element.htmlFor.remove('x');
shouldBeEqualToString('element.htmlFor.toString()', 'y');
debug('- Ensure that we can handle empty form attribute correctly');
element = document.createElement('output');
var list = element.htmlFor;
list.toggle('x');
shouldBeEqualToString('list.value', 'x');
list.toggle('x');
shouldBeEqualToString('list.value', '');
element = document.createElement('output');
shouldBeFalse('element.htmlFor.contains(\'x\')');
shouldBeNull('element.htmlFor[1]');
element.htmlFor.remove('x');
element.htmlFor.add('x')
shouldBeTrue('element.htmlFor.contains(\'x\')');
shouldBeNull('element.htmlFor[1]');
debug('- Testing add in presence of trailing white spaces.');
createElement('x ');
element.htmlFor.add('y');
shouldBeEqualToString('element.htmlFor.toString()', 'x y');
createElement('x\t');
element.htmlFor.add('y');
shouldBeEqualToString('element.htmlFor.toString()', 'x\t y');
createElement(' ');
element.htmlFor.add('y');
shouldBeEqualToString('element.htmlFor.toString()', ' y');
debug('- Test invalid tokens');
// Testing exception due to invalid token
// shouldThrow from js-test-pre.js is not sufficient.
function shouldThrowDOMException(f, ec)
{
try {
f();
testFailed('Expected an exception');
} catch (ex) {
if (!(ex instanceof DOMException)) {
testFailed('Exception is not an instance of DOMException, found: ' +
Object.toString.call(ex));
return;
}
if (ec !== ex.code) {
testFailed('Wrong exception code: ' + ex.code);
return;
}
}
var formattedFunction = String(f).replace(/^function.+\{\s*/m, '').
replace(/;?\s+\}/m, '');
testPassed(formattedFunction + ' threw expected DOMException with code ' + ec);
}
createElement('x');
shouldThrowDOMException(function() {
element.htmlFor.contains('');
}, DOMException.SYNTAX_ERR);
createElement('x y');
shouldThrowDOMException(function() {
element.htmlFor.contains('x y');
}, DOMException.INVALID_CHARACTER_ERR);
createElement('');
shouldThrowDOMException(function() {
element.htmlFor.add('');
}, DOMException.SYNTAX_ERR);
createElement('');
shouldThrowDOMException(function() {
element.htmlFor.add('x y');
}, DOMException.INVALID_CHARACTER_ERR);
createElement('');
shouldThrowDOMException(function() {
element.htmlFor.remove('');
}, DOMException.SYNTAX_ERR);
createElement('');
shouldThrowDOMException(function() {
element.htmlFor.remove('x y');
}, DOMException.INVALID_CHARACTER_ERR);
createElement('');
shouldThrowDOMException(function() {
element.htmlFor.toggle('');
}, DOMException.SYNTAX_ERR);
createElement('x y');
shouldThrowDOMException(function() {
element.htmlFor.toggle('x y');
}, DOMException.INVALID_CHARACTER_ERR);
debug('- Indexing');
createElement('x');
shouldBeEqualToString('element.htmlFor[0]', 'x');
shouldBeEqualToString('element.htmlFor.item(0)', 'x');
createElement('x x');
shouldBeEqualToString('element.htmlFor[1]', 'x');
shouldBeEqualToString('element.htmlFor.item(1)', 'x');
createElement('x y');
shouldBeEqualToString('element.htmlFor[1]', 'y');
shouldBeEqualToString('element.htmlFor.item(1)', 'y');
createElement('');
shouldBeNull('element.htmlFor[0]');
shouldBeNull('element.htmlFor.item(0)');
createElement('x y z');
shouldBeNull('element.htmlFor[4]');
shouldBeNull('element.htmlFor.item(4)');
shouldBeUndefined('element.htmlFor[-1]'); // Not a valid index so should not trigger item().
shouldBeNull('element.htmlFor.item(-1)');
debug('- Test case since DOMTokenList is case sensitive');
createElement('x');
shouldBeTrue('element.htmlFor.contains(\'x\')');
shouldBeFalse('element.htmlFor.contains(\'X\')');
shouldBeEqualToString('element.htmlFor[0]', 'x');
createElement('X');
shouldBeTrue('element.htmlFor.contains(\'X\')');
shouldBeFalse('element.htmlFor.contains(\'x\')');
shouldBeEqualToString('element.htmlFor[0]', 'X');
debug('- Testing whitespace');
// U+0020 SPACE, U+0009 CHARACTER TABULATION (tab), U+000A LINE FEED (LF),