Modified: trunk/LayoutTests/ChangeLog (93389 => 93390)
--- trunk/LayoutTests/ChangeLog 2011-08-19 08:42:03 UTC (rev 93389)
+++ trunk/LayoutTests/ChangeLog 2011-08-19 08:46:47 UTC (rev 93390)
@@ -1,3 +1,17 @@
+2011-08-19 Shinya Kawanaka <[email protected]>
+
+ input[maxlength=0] should ignore text input.
+ https://bugs.webkit.org/show_bug.cgi?id=65497
+
+ Reviewed by Kent Tamura.
+
+ * fast/forms/input-text-paste-maxlength-expected.txt:
+ Added a case that maxlength=0
+ * fast/forms/input-text-paste-maxlength.html: ditto.
+ * fast/forms/script-tests/textarea-maxlength.js: ditto.
+ (createFocusedTextAreaWithMaxLength):
+ * fast/forms/textarea-maxlength-expected.txt: ditto.
+
2011-08-19 Ilya Tikhonovsky <[email protected]>
Web Inspector: backend js api: an ability to skip optional arguments in the middle of the argument list is required.
Modified: trunk/LayoutTests/fast/forms/input-text-paste-maxlength-expected.txt (93389 => 93390)
--- trunk/LayoutTests/fast/forms/input-text-paste-maxlength-expected.txt 2011-08-19 08:42:03 UTC (rev 93389)
+++ trunk/LayoutTests/fast/forms/input-text-paste-maxlength-expected.txt 2011-08-19 08:46:47 UTC (rev 93390)
@@ -25,7 +25,10 @@
pasting too much text
PASS domValueOf('k') is '12' + fancyX + '4'
PASS visibleValueOf('k') is '12' + fancyX + '4'
+pasting too much text with maxlength=0
+PASS domValueOf('l') is ''
+PASS visibleValueOf('l') is ''
PASS successfullyParsed is true
TEST COMPLETE
-
+
Modified: trunk/LayoutTests/fast/forms/input-text-paste-maxlength.html (93389 => 93390)
--- trunk/LayoutTests/fast/forms/input-text-paste-maxlength.html 2011-08-19 08:42:03 UTC (rev 93389)
+++ trunk/LayoutTests/fast/forms/input-text-paste-maxlength.html 2011-08-19 08:46:47 UTC (rev 93390)
@@ -17,6 +17,7 @@
<input type="text" id="h" size="5">
<input type="text" id="g" size="5">
<input type="text" id="k" size="5" maxlength="4">
+<input type="text" id="l" size="5" maxlength="0">
<script>
function domValueOf(id) {
@@ -93,6 +94,12 @@
shouldBe("domValueOf('k')", "'12' + fancyX + '4'");
shouldBe("visibleValueOf('k')", "'12' + fancyX + '4'");
+debug("pasting too much text with maxlength=0");
+document.getElementById("l").focus();
+document.execCommand("InsertHTML", false, "12x̲̅45");
+shouldBe("domValueOf('l')", "''");
+shouldBe("visibleValueOf('l')", "''");
+
var successfullyParsed = true;
</script>
<script src=""
Modified: trunk/LayoutTests/fast/forms/script-tests/textarea-maxlength.js (93389 => 93390)
--- trunk/LayoutTests/fast/forms/script-tests/textarea-maxlength.js 2011-08-19 08:42:03 UTC (rev 93389)
+++ trunk/LayoutTests/fast/forms/script-tests/textarea-maxlength.js 2011-08-19 08:46:47 UTC (rev 93390)
@@ -42,60 +42,60 @@
shouldBe('textArea.value', '"abcde"');
// Set up for user-input tests
-function createFocusedTextAreaWithMaxLength3() {
+function createFocusedTextAreaWithMaxLength(maxLength) {
if (textArea)
document.body.removeChild(textArea);
textArea = document.createElement('textarea');
- textArea.setAttribute('maxlength', '3');
+ textArea.setAttribute('maxlength', maxLength);
document.body.appendChild(textArea);
textArea.focus();
}
// Insert text of which length is maxLength.
-createFocusedTextAreaWithMaxLength3();
+createFocusedTextAreaWithMaxLength(3);
document.execCommand('insertText', false, 'abc');
shouldBe('textArea.value', '"abc"');
// Try to add characters to maxLength characters.
-createFocusedTextAreaWithMaxLength3();
+createFocusedTextAreaWithMaxLength(3);
textArea.value = 'abc';
document.execCommand('insertText', false, 'def');
shouldBe('textArea.value', '"abc"');
// Replace text
-createFocusedTextAreaWithMaxLength3();
+createFocusedTextAreaWithMaxLength(3);
textArea.value = 'abc';
document.execCommand('selectAll');
document.execCommand('insertText', false, 'def');
shouldBe('textArea.value', '"def"');
// Existing value is longer than maxLength. We can't add text.
-createFocusedTextAreaWithMaxLength3();
+createFocusedTextAreaWithMaxLength(3);
textArea.value = 'abcdef';
document.execCommand('insertText', false, 'ghi');
shouldBe('textArea.value', '"abcdef"');
// We can delete a character in the longer value.
-createFocusedTextAreaWithMaxLength3();
+createFocusedTextAreaWithMaxLength(3);
textArea.value = 'abcdef';
document.execCommand('delete');
shouldBe('textArea.value', '"abcde"');
// A linebreak is 1 character.
-createFocusedTextAreaWithMaxLength3();
+createFocusedTextAreaWithMaxLength(3);
document.execCommand('insertText', false, 'A');
document.execCommand('insertLineBreak');
document.execCommand('insertText', false, 'B');
shouldBe('textArea.value', '"A\\nB"');
// Confirms correct count for close linebreaks inputs.
-createFocusedTextAreaWithMaxLength3();
+createFocusedTextAreaWithMaxLength(3);
textArea.innerHTML = 'a\n\n';
document.execCommand('insertLineBreak');
shouldBe('textArea.value', '"a\\n\\n"');
// Confirms correct count for open consecutive linebreaks inputs.
-createFocusedTextAreaWithMaxLength3();
+createFocusedTextAreaWithMaxLength(3);
document.execCommand('insertLineBreak');
document.execCommand('insertLineBreak');
document.execCommand('insertLineBreak');
@@ -111,27 +111,33 @@
var u10000 = "\ud800\udc00";
// Inserts 5 code-points in UTF-16
-createFocusedTextAreaWithMaxLength3();
+createFocusedTextAreaWithMaxLength(3);
document.execCommand('insertText', false, 'AB' + fancyX);
shouldBe('textArea.value', '"AB" + fancyX');
shouldBe('textArea.value.length', '5');
-createFocusedTextAreaWithMaxLength3();
+createFocusedTextAreaWithMaxLength(3);
textArea.value = 'AB' + fancyX;
textArea.setSelectionRange(2, 5); // Select fancyX
document.execCommand('insertText', false, 'CDE');
shouldBe('textArea.value', '"ABC"');
// Inserts 4 code-points in UTF-16
-createFocusedTextAreaWithMaxLength3();
+createFocusedTextAreaWithMaxLength(3);
document.execCommand('insertText', false, 'AB' + u10000);
shouldBe('textArea.value', '"AB" + u10000');
shouldBe('textArea.value.length', '4');
-createFocusedTextAreaWithMaxLength3();
+createFocusedTextAreaWithMaxLength(3);
textArea.value = 'AB' + u10000;
textArea.setSelectionRange(2, 4); // Select u10000
document.execCommand('insertText', false, 'CDE');
shouldBe('textArea.value', '"ABC"');
+// In the case maxlength=0
+createFocusedTextAreaWithMaxLength(0);
+textArea.value = '';
+document.execCommand('insertText', false, 'ABC');
+shouldBe('textArea.value', '""');
+
var successfullyParsed = true;
Modified: trunk/LayoutTests/fast/forms/textarea-maxlength-expected.txt (93389 => 93390)
--- trunk/LayoutTests/fast/forms/textarea-maxlength-expected.txt 2011-08-19 08:42:03 UTC (rev 93389)
+++ trunk/LayoutTests/fast/forms/textarea-maxlength-expected.txt 2011-08-19 08:46:47 UTC (rev 93390)
@@ -29,6 +29,7 @@
PASS textArea.value is "AB" + u10000
PASS textArea.value.length is 4
PASS textArea.value is "ABC"
+PASS textArea.value is ""
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/Source/WebCore/ChangeLog (93389 => 93390)
--- trunk/Source/WebCore/ChangeLog 2011-08-19 08:42:03 UTC (rev 93389)
+++ trunk/Source/WebCore/ChangeLog 2011-08-19 08:46:47 UTC (rev 93390)
@@ -1,3 +1,16 @@
+2011-08-19 Shinya Kawanaka <[email protected]>
+
+ input[maxlength=0] should ignore text input.
+ https://bugs.webkit.org/show_bug.cgi?id=65497
+
+ Reviewed by Kent Tamura.
+
+ Changed the valid range of maxlength.
+
+ * html/HTMLInputElement.cpp:
+ (WebCore::HTMLInputElement::parseMaxLengthAttribute):
+ Changed maxlength check condition.
+
2011-08-19 Ilya Tikhonovsky <[email protected]>
Web Inspector: backend js api: an ability to skip optional arguments in the middle of the argument list is required.
Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (93389 => 93390)
--- trunk/Source/WebCore/html/HTMLInputElement.cpp 2011-08-19 08:42:03 UTC (rev 93389)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp 2011-08-19 08:46:47 UTC (rev 93390)
@@ -1922,7 +1922,7 @@
void HTMLInputElement::parseMaxLengthAttribute(Attribute* attribute)
{
int maxLength = attribute->isNull() ? maximumLength : attribute->value().toInt();
- if (maxLength <= 0 || maxLength > maximumLength)
+ if (maxLength < 0 || maxLength > maximumLength)
maxLength = maximumLength;
int oldMaxLength = m_maxLength;
m_maxLength = maxLength;