/** Test for Bug 535043 **/
function checkTextArea(textArea) { textArea.value = ''; textArea.focus();
for (var j = 0; j < 3; j++) {
sendString("x");
} var htmlMaxLength = textArea.getAttribute('maxlength'); var domMaxLength = textArea.maxLength;
if (htmlMaxLength == null) {
is(domMaxLength, -1, 'maxlength is unset but maxLength DOM attribute is not -1');
} else if (htmlMaxLength < 0) {
// Per the HTML5 spec, out-of-range values are supposed to translate to -1,
// not 0, but they don't?
is(domMaxLength, -1, 'maxlength is out of range but maxLength DOM attribute is not -1');
} else {
is(domMaxLength, parseInt(htmlMaxLength), 'maxlength in DOM does not match provided value');
}
if (textArea.maxLength == -1) {
is(textArea.value.length, 3, 'textarea with maxLength -1 should have no length limit');
} else {
is(textArea.value.length, textArea.maxLength, 'textarea has maxLength ' + textArea.maxLength + ' but length ' + textArea.value.length );
}
}
SimpleTest.waitForFocus(function() { var textAreas = document.getElementsByTagName('textarea');
for (var i = 0; i < textAreas.length; i++) {
checkTextArea(textAreas[i]);
}
textArea = textAreas[0];
testNums = [-42, -1, 0, 2];
for (var i = 0; i < testNums.length; i++) { textArea.removeAttribute('maxlength');
var caught = false;
try { textArea.maxLength = testNums[i];
} catch (e) {
caught = true;
}
if (testNums[i] < 0) {
ok(caught, 'Setting negative maxLength should throw exception');
} else {
ok(!caught, 'Setting nonnegative maxLength should not throw exception');
}
checkTextArea(textArea);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.