Bug 597519 - Attempting to add characters to a textarea filled to its maxlength with a trailing newline results in the caret to jump to the previous line; r=roc a=blocking-final+

This commit is contained in:
Ehsan Akhgari 2010-09-24 15:10:53 -04:00
parent c05196072c
commit 133d6d5182
5 changed files with 39 additions and 2 deletions

View File

@ -658,8 +658,14 @@ nsTextEditRules::WillInsertText(PRInt32 aAction,
// handle docs with a max length
// NOTE, this function copies inString into outString for us.
nsresult res = TruncateInsertionIfNeeded(aSelection, inString, outString, aMaxLength, nsnull);
PRBool truncated = PR_FALSE;
nsresult res = TruncateInsertionIfNeeded(aSelection, inString, outString,
aMaxLength, &truncated);
NS_ENSURE_SUCCESS(res, res);
if (truncated) {
*aCancel = PR_TRUE;
return NS_OK;
}
PRUint32 start = 0;
PRUint32 end = 0;

View File

@ -104,6 +104,8 @@ _TEST_FILES = \
bug512295-2-ref.html \
bug585922.html \
bug585922-ref.html \
bug597519-1.html \
bug597519-1-ref.html \
test_bug514127.html \
test_bug518777.html \
test_bug548545.xhtml \

View File

@ -0,0 +1,11 @@
<!DOCTYPE HTML><html><head>
</head>
<body>
<textarea>ab
</textarea>
<script>
var t = document.querySelector("textarea");
t.focus();
</script>
</body>
</html>

View File

@ -0,0 +1,17 @@
<!DOCTYPE HTML><html><head>
<script type="text/javascript" src="/MochiKit/packed.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
</head>
<body>
<textarea maxlength="3"></textarea>
<script>
var t = document.querySelector("textarea");
t.focus();
synthesizeKey("a", {});
synthesizeKey("b", {});
synthesizeKey("VK_ENTER", {});
synthesizeKey("c", {});
</script>
</body>
</html>

View File

@ -93,7 +93,8 @@ var tests = [
[ 'bug482484.html' , 'bug482484-ref.html' ] ,
[ 'bug512295-1.html' , 'bug512295-1-ref.html' ] ,
[ 'bug512295-2.html' , 'bug512295-2-ref.html' ] ,
[ 'bug585922.html' , 'bug585922-ref.html' ]
[ 'bug585922.html' , 'bug585922-ref.html' ] ,
[ 'bug597519-1.html' , 'bug597519-1-ref.html' ]
];
var testIndex = 0;