function checkNegativeMinMaxLength(element)
{
for(let type of ["min", "max"]) {
/* value is set to -2 initially in the document, see above */
is(element[type + "Length"], -1, "negative " + type + "Length should be considered invalid and represented as -1");
// changing the property to an negative value should throw (see bug 536895).
for(let value of [-15, -2147483648]) { // PR_INT32_MIN
let threw = false;
try {
element[type + "Length"] = value;
} catch(e) {
threw = true;
}
is(threw, true, "setting " + type + "Length property to " + value + " should throw");
}
element[type + "Length"] = "non-numerical value";
is(element[type + "Length"], 0, "setting " + type + "Length property to a non-numerical value should set it to zero");
element.setAttribute(type + 'Length', -15);
is(element[type + "Length"], -1, "negative " + type + "Length is not processed correctly when set dynamically");
is(element.getAttribute(type + 'Length'), "-15", type + "Length attribute doesn't return the correct value");
element.setAttribute(type + 'Length', 0);
is(element[type + "Length"], 0, "zero " + type + "Length is not processed correctly");
element.setAttribute(type + 'Length', 2147483647); // PR_INT32_MAX
is(element[type + "Length"], 2147483647, "negative " + type + "Length is not processed correctly");
element.setAttribute(type + 'Length', -2147483648); // PR_INT32_MIN
is(element[type + "Length"], -1, "negative " + type + "Length is not processed correctly");
element.setAttribute(type + 'Length', 'non-numerical-value');
is(element[type + "Length"], -1, "non-numerical value should be considered invalid and represented as -1");
}
}
/* TODO: correct behavior may be checked for email, telephone, url and search input types */
checkNegativeMinMaxLength(document.getElementById('t'));
checkNegativeMinMaxLength(document.getElementById('i'));
checkNegativeMinMaxLength(document.getElementById('p'));
</script>
</pre>
</body>
</html>
Messung V0.5
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet)
¤
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.