2016-08-06 15:59:08 +00:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=613019
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<title>Test for Bug 613019</title>
|
2019-04-16 03:53:28 +00:00
|
|
|
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<script src="/tests/SimpleTest/EventUtils.js"></script>
|
2016-08-06 15:59:08 +00:00
|
|
|
<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=613019">Mozilla Bug 613019</a>
|
|
|
|
<div id="content">
|
|
|
|
<input type="text" maxlength="2" style="width:200px" value="Test">
|
|
|
|
<textarea maxlength="2" style="width:200px">Test</textarea>
|
2016-08-17 04:11:24 +00:00
|
|
|
<input type="text" minlength="6" style="width:200px" value="Test">
|
|
|
|
<textarea minlength="6" style="width:200px">Test</textarea>
|
2016-08-06 15:59:08 +00:00
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
|
|
|
|
/** Test for Bug 613019 **/
|
|
|
|
|
2016-08-17 04:11:24 +00:00
|
|
|
function testInteractivityOfMaxLength(elem) {
|
2016-08-06 15:59:08 +00:00
|
|
|
// 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.");
|
|
|
|
|
2017-03-01 13:35:08 +00:00
|
|
|
elem.setSelectionRange(elem.value.length, elem.value.length)
|
2016-08-06 15:59:08 +00:00
|
|
|
elem.focus();
|
|
|
|
|
2018-02-14 19:15:39 +00:00
|
|
|
synthesizeKey("KEY_Backspace");
|
2016-08-06 15:59:08 +00:00
|
|
|
is(elem.value, "Tes", "Element value was not changed correctly.");
|
|
|
|
is(elem.validity.tooLong, true, "Element should still be tooLong.");
|
|
|
|
|
2018-02-14 19:15:39 +00:00
|
|
|
synthesizeKey("KEY_Backspace");
|
2016-08-06 15:59:08 +00:00
|
|
|
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.");
|
|
|
|
}
|
|
|
|
|
2016-08-17 04:11:24 +00:00
|
|
|
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.");
|
|
|
|
|
2017-03-01 13:35:08 +00:00
|
|
|
elem.setSelectionRange(elem.value.length, elem.value.length)
|
2016-08-17 04:11:24 +00:00
|
|
|
elem.focus();
|
|
|
|
|
2018-02-14 19:15:39 +00:00
|
|
|
sendString("e");
|
2016-08-17 04:11:24 +00:00
|
|
|
is(elem.value, "Teste", "Element value was not changed correctly.");
|
|
|
|
is(elem.validity.tooShort, true, "Element should still be tooShort.");
|
|
|
|
|
2018-02-14 19:15:39 +00:00
|
|
|
sendString("d");
|
2016-08-17 04:11:24 +00:00
|
|
|
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.");
|
|
|
|
}
|
|
|
|
|
2016-08-06 15:59:08 +00:00
|
|
|
function test() {
|
|
|
|
window.getSelection().removeAllRanges();
|
2016-08-17 04:11:24 +00:00
|
|
|
testInteractivityOfMaxLength(document.querySelector("input[type=text][maxlength]"));
|
|
|
|
testInteractivityOfMaxLength(document.querySelector("textarea[maxlength]"));
|
|
|
|
testInteractivityOfMinLength(document.querySelector("input[type=text][minlength]"));
|
|
|
|
testInteractivityOfMinLength(document.querySelector("textarea[minlength]"));
|
2016-08-06 15:59:08 +00:00
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
window.onload = function() {
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
setTimeout(test, 0);
|
|
|
|
};
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|