mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-08 04:27:37 +00:00
f1fc41b0e5
This is more likely to be correct, and a necessary step in case we ever want to move to Object.is. This keeps ise as an alias for is, and introduces is_loosely for the old behaviour.
54 lines
2.1 KiB
HTML
54 lines
2.1 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<!--
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=536891
|
|
-->
|
|
<head>
|
|
<title>Test for Bug 536891</title>
|
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
</head>
|
|
<body>
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=536891">Mozilla Bug 536891</a>
|
|
<p id="display"></p>
|
|
<div id="content" style="display: none">
|
|
<textarea id="t" maxlength="-2"></textarea>
|
|
<input id="i" type="text" maxlength="-2">
|
|
<input id="p" type="password" maxlength="-2">
|
|
</div>
|
|
<pre id="test">
|
|
<script type="application/javascript">
|
|
|
|
/** Test for Bug 536891 **/
|
|
|
|
function checkNegativeMaxLength(element)
|
|
{
|
|
/* maxLength is set to -2 initially in the document, see above */
|
|
is(element.maxLength, -1, "negative maxLength should be considered invalid and represented as -1");
|
|
|
|
element.setAttribute('maxLength', -15);
|
|
is(element.maxLength, -1, "negative maxLength is not processed correctly when set dynamically");
|
|
is(element.getAttribute('maxLength'), "-15", "maxLength attribute doesn't return the correct value");
|
|
|
|
element.setAttribute('maxLength', 0);
|
|
is(element.maxLength, 0, "negative maxLength is not processed correctly");
|
|
element.setAttribute('maxLength', 2147483647); /* PR_INT32_MAX */
|
|
is(element.maxLength, 2147483647, "negative maxLength is not processed correctly");
|
|
element.setAttribute('maxLength', -2147483648); /* PR_INT32_MIN */
|
|
is(element.maxLength, -1, "negative maxLength is not processed correctly");
|
|
element.setAttribute('maxLength', 'non-numerical-value');
|
|
is(element.maxLength, -1, "non-numerical value should be considered invalid and represented as -1");
|
|
|
|
/* we do not check when changing the value from the DOM because it is throwing an exception, see bug 536895 */
|
|
}
|
|
|
|
/* TODO: correct behavior may be checked for email, telephone, url and search input types */
|
|
checkNegativeMaxLength(document.getElementById('t'));
|
|
checkNegativeMaxLength(document.getElementById('i'));
|
|
checkNegativeMaxLength(document.getElementById('p'));
|
|
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|