mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 535043 - Support maxlength on textarea. r=smaug, sr=jst
This commit is contained in:
parent
7fcd25c7bf
commit
86317086bb
@ -373,6 +373,7 @@ nsHTMLTextAreaElement::IsHTMLFocusable(PRBool *aIsFocusable, PRInt32 *aTabIndex)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLTextAreaElement, AccessKey, accesskey)
|
||||
NS_IMPL_INT_ATTR(nsHTMLTextAreaElement, Cols, cols)
|
||||
NS_IMPL_BOOL_ATTR(nsHTMLTextAreaElement, Disabled, disabled)
|
||||
NS_IMPL_INT_ATTR(nsHTMLTextAreaElement, MaxLength, maxlength)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLTextAreaElement, Name, name)
|
||||
NS_IMPL_BOOL_ATTR(nsHTMLTextAreaElement, ReadOnly, readonly)
|
||||
NS_IMPL_INT_ATTR(nsHTMLTextAreaElement, Rows, rows)
|
||||
@ -523,6 +524,9 @@ nsHTMLTextAreaElement::ParseAttribute(PRInt32 aNamespaceID,
|
||||
nsAttrValue& aResult)
|
||||
{
|
||||
if (aNamespaceID == kNameSpaceID_None) {
|
||||
if (aAttribute == nsGkAtoms::maxlength) {
|
||||
return aResult.ParseIntWithBounds(aValue, 0);
|
||||
}
|
||||
if (aAttribute == nsGkAtoms::cols) {
|
||||
return aResult.ParseIntWithBounds(aValue, 0);
|
||||
}
|
||||
|
@ -144,6 +144,7 @@ _TEST_FILES = test_bug589.html \
|
||||
form_submit_server.sjs \
|
||||
test_bug529819.html \
|
||||
test_bug529859.html \
|
||||
test_bug535043.html \
|
||||
$(NULL)
|
||||
|
||||
libs:: $(_TEST_FILES)
|
||||
|
87
content/html/content/test/test_bug535043.html
Normal file
87
content/html/content/test/test_bug535043.html
Normal file
@ -0,0 +1,87 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=535043
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 535043</title>
|
||||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/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=535043">Mozilla Bug 535043</a>
|
||||
<p id="display"></p>
|
||||
<div id="content">
|
||||
<textarea></textarea>
|
||||
<textarea maxlength="-1"></textarea>
|
||||
<textarea maxlength="0"></textarea>
|
||||
<textarea maxlength="2"></textarea>
|
||||
<textarea maxlength="257"></textarea>
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="text/javascript">
|
||||
|
||||
/** Test for Bug 535043 **/
|
||||
function checkTextArea(textArea) {
|
||||
textArea.value = '';
|
||||
textArea.focus();
|
||||
for (var j = 0; j < 259; j++) {
|
||||
synthesizeKey('x', {});
|
||||
}
|
||||
var htmlMaxLength = textArea.getAttribute('maxlength');
|
||||
var domMaxLength = textArea.maxLength;
|
||||
if (htmlMaxLength == null) {
|
||||
is(domMaxLength, -1,
|
||||
'maxlength is unset but maxLength DOM attribute is not -1');
|
||||
} else if (htmlMaxLength < 0) {
|
||||
// Per the HTML5 spec, out-of-range values are supposed to translate to -1,
|
||||
// not 0, but they don't?
|
||||
todo_is(domMaxLength, -1,
|
||||
'maxlength is out of range but maxLength DOM attribute is not -1');
|
||||
} else {
|
||||
is(domMaxLength, parseInt(htmlMaxLength),
|
||||
'maxlength in DOM does not match provided value');
|
||||
}
|
||||
if (textArea.maxLength == -1) {
|
||||
is(textArea.value.length, 259,
|
||||
'textarea with maxLength -1 should have no length limit');
|
||||
} else {
|
||||
is(textArea.value.length, textArea.maxLength, 'textarea has maxLength ' +
|
||||
textArea.maxLength + ' but length ' + textArea.value.length );
|
||||
}
|
||||
}
|
||||
|
||||
SimpleTest.waitForFocus(function() {
|
||||
var textAreas = document.getElementsByTagName('textarea');
|
||||
for (var i = 0; i < textAreas.length; i++) {
|
||||
checkTextArea(textAreas[i]);
|
||||
}
|
||||
|
||||
textArea = textAreas[0];
|
||||
testNums = [-42, -1, 0, 2, 257];
|
||||
for (var i = 0; i < testNums.length; i++) {
|
||||
textArea.removeAttribute('maxlength');
|
||||
|
||||
var caught = false;
|
||||
try {
|
||||
textArea.maxLength = testNums[i];
|
||||
} catch (e) {
|
||||
caught = true;
|
||||
}
|
||||
if (testNums[i] < 0) {
|
||||
todo(caught, 'Setting negative maxLength should throw exception');
|
||||
} else {
|
||||
ok(!caught, 'Setting nonnegative maxLength should not throw exception');
|
||||
}
|
||||
checkTextArea(textArea);
|
||||
|
||||
textArea.setAttribute('maxlength', testNums[i]);
|
||||
checkTextArea(textArea);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -42,7 +42,7 @@
|
||||
interface nsIControllers;
|
||||
|
||||
|
||||
[scriptable, uuid(ca066b44-9ddf-11d3-bccc-0060b0fc76bd)]
|
||||
[scriptable, uuid(7a5e4bfb-0530-4c35-a7f9-7859b472ef8d)]
|
||||
interface nsIDOMNSHTMLTextAreaElement : nsISupports
|
||||
{
|
||||
readonly attribute nsIControllers controllers;
|
||||
@ -50,6 +50,7 @@ interface nsIDOMNSHTMLTextAreaElement : nsISupports
|
||||
readonly attribute long textLength;
|
||||
attribute long selectionStart;
|
||||
attribute long selectionEnd;
|
||||
attribute long maxLength;
|
||||
|
||||
void setSelectionRange(in long selectionStart,
|
||||
in long selectionEnd);
|
||||
|
Loading…
Reference in New Issue
Block a user