mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-03 18:47:53 +00:00
72a41b4a70
Fix of bug 1320229 allowed to paste longer text than `maxlength` attribute of `<input>` and `<textarea>` because it was thought that the longer text causes "too long" invalidate state, makes users notified and prevent to submit form data. However, according to Bug 1636855 comment 7 (*1), it breaks a major enterprise web app, SAP, at least because it sends form data without checking validity of each form data and discards invalid data on server side silently. According to bug 1636855 comment 24 (*2), one of new behavior's fault is on Gecko side too. The style of `<input>` element or `<textarea>` element which has too long text after pasting is changed when it loses focus. Therefore, users can post the data before they know pasted data is too long if sending the form data with `Enter` key or something immediately after pasting (i.e., without moving focus) web apps handle it by themselves. On the other hand, the original bug report, bug 1320229, should be solved in the future especially in password field because users may register password which is cut by `maxlength` silently and they don't use builtin password manager, only the pasted password is saved, and then, they won't be able to login as the account. This is really long standing issue of the web forms. An article (*3) warned this to web developers in 2011. Therefore, we should keep going advance for solving this issue at least in Nightly channel to get more feedback from testers and web developers. 1 https://bugzilla.mozilla.org/show_bug.cgi?id=1636855#c7 2 https://bugzilla.mozilla.org/show_bug.cgi?id=1636855#c24 3 https://www.christophermanning.org/writing/dont-use-maxlength-on-password-inputs Differential Revision: https://phabricator.services.mozilla.com/D78613
54 lines
1.5 KiB
HTML
54 lines
1.5 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<!--
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=603556
|
|
-->
|
|
<head>
|
|
<title>Test for Bug 603556</title>
|
|
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<script 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});
|
|
if (!SpecialPowers.getBoolPref("editor.truncate_user_pastes")) {
|
|
is(i.value, src.textContent,
|
|
"Pasting should paste the clipboard contents regardless of maxlength");
|
|
} else {
|
|
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>
|