Bug 603556 - pasting into text that is longer than maxlength of text control fails; r=roc a=blocking-final+

This commit is contained in:
Ehsan Akhgari 2010-10-12 18:30:41 -04:00
parent 1e1451b22d
commit b15b1bb4b3
3 changed files with 51 additions and 1 deletions

View File

@ -662,7 +662,7 @@ nsTextEditRules::WillInsertText(PRInt32 aAction,
nsresult res = TruncateInsertionIfNeeded(aSelection, inString, outString,
aMaxLength, &truncated);
NS_ENSURE_SUCCESS(res, res);
if (truncated) {
if (truncated && outString->IsEmpty()) {
*aCancel = PR_TRUE;
return NS_OK;
}

View File

@ -53,6 +53,7 @@ _TEST_FILES = \
test_bug596506.html \
test_bug597331.html \
test_bug600570.html \
test_bug603556.html \
$(NULL)
# disables the key handling test on gtk2 because gtk2 overrides some key events

View File

@ -0,0 +1,49 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=603556
-->
<head>
<title>Test for Bug 603556</title>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.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=603556">Mozilla Bug 603556</a>
<p id="display"></p>
<div id="content">
<div id="src">testing</div>
<input maxlength="4">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 603556 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var i = document.querySelector("input");
var src = document.getElementById("src");
SimpleTest.waitForClipboard(src.textContent,
function() {
getSelection().selectAllChildren(src);
synthesizeKey("C", {accelKey: true});
},
function() {
i.focus();
synthesizeKey("V", {accelKey: true});
is(i.value, src.textContent.substr(0, i.maxLength),
"Pasting should paste maxlength chars worth of the clipboard contents");
SimpleTest.finish();
},
function() {
SimpleTest.finish();
}
);
});
</script>
</pre>
</body>
</html>