function testInteractivityOfMaxLength(elem) {
// verify that user interactivity is necessary for validity state to apply.
is(elem.value, "Test", "Element has incorrect starting value.");
is(elem.validity.tooLong, false, "Element should not be tooLong.");
synthesizeKey("KEY_Backspace");
is(elem.value, "Tes", "Element value was not changed correctly.");
is(elem.validity.tooLong, true, "Element should still be tooLong.");
synthesizeKey("KEY_Backspace");
is(elem.value, "Te", "Element value was not changed correctly.");
is(elem.validity.tooLong, false, "Element should no longer be tooLong.");
elem.value = "Test";
is(elem.validity.tooLong, false, "Element should not be tooLong after non-interactive value change.");
}
function testInteractivityOfMinLength(elem) {
// verify that user interactivity is necessary for validity state to apply.
is(elem.value, "Test", "Element has incorrect starting value.");
is(elem.validity.tooLong, false, "Element should not be tooShort.");
sendString("e");
is(elem.value, "Teste", "Element value was not changed correctly.");
is(elem.validity.tooShort, true, "Element should still be tooShort.");
sendString("d");
is(elem.value, "Tested", "Element value was not changed correctly.");
is(elem.validity.tooShort, false, "Element should no longer be tooShort.");
elem.value = "Test";
is(elem.validity.tooShort, false, "Element should not be tooShort after non-interactive value change.");
}
function test() {
window.getSelection().removeAllRanges();
testInteractivityOfMaxLength(document.querySelector("input[type=text][maxlength]"));
testInteractivityOfMaxLength(document.querySelector("textarea[maxlength]"));
testInteractivityOfMinLength(document.querySelector("input[type=text][minlength]"));
testInteractivityOfMinLength(document.querySelector("textarea[minlength]"));
SimpleTest.finish();
}
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.