Right now it tries to predict what the complete input value will be after the keypress, and either allow or prevent that event.
However this is very unrealiable. For example if the limit is reached and you select all and begin typing, you can't because it will do (this.value + tobeinsertedkey) as prediction, and that's too long.
The solution is to watch *after* the key is pressed and then correct it. Because we can't simulate all possible ways of insertion:
- copy/pasting
- drag/drop
- select>type
- autocomplete
- javascript-powered input methods
Initial attempt: I9ace3ab79 | https://gerrit.wikimedia.org/r/12713.
Reverted in: I1fe6a6c6 | https://gerrit.wikimedia.org/r/14175
because it caused the browser to limit the input field to 0 due to a browser bug (could be the kind of bug that is actually documented in the specification). So we'll have to do this another way.
Upstream: https://code.google.com/p/chromium/issues/detail?id=136004
Reproduced: http://jsfiddle.net/Ea48y/
See also: bug 38158
Version: 1.18.x
Severity: normal