Changeset 93390 in webkit


Ignore:
Timestamp:
Aug 19, 2011 1:46:47 AM (13 years ago)
Author:
commit-queue@webkit.org
Message:

input[maxlength=0] should ignore text input.
https://bugs.webkit.org/show_bug.cgi?id=65497

Patch by Shinya Kawanaka <shinyak@google.com> on 2011-08-19
Reviewed by Kent Tamura.

Source/WebCore:

Changed the valid range of maxlength.

  • html/HTMLInputElement.cpp:

(WebCore::HTMLInputElement::parseMaxLengthAttribute):

Changed maxlength check condition.

LayoutTests:

  • 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.
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r93389 r93390  
     12011-08-19  Shinya Kawanaka  <shinyak@google.com>
     2
     3        input[maxlength=0] should ignore text input.
     4        https://bugs.webkit.org/show_bug.cgi?id=65497
     5
     6        Reviewed by Kent Tamura.
     7
     8        * fast/forms/input-text-paste-maxlength-expected.txt:
     9          Added a case that maxlength=0
     10        * fast/forms/input-text-paste-maxlength.html: ditto.
     11        * fast/forms/script-tests/textarea-maxlength.js: ditto.
     12        (createFocusedTextAreaWithMaxLength):
     13        * fast/forms/textarea-maxlength-expected.txt: ditto.
     14
    1152011-08-19  Ilya Tikhonovsky  <loislo@chromium.org>
    216
  • trunk/LayoutTests/fast/forms/input-text-paste-maxlength-expected.txt

    r48449 r93390  
    2626PASS domValueOf('k') is '12' + fancyX + '4'
    2727PASS visibleValueOf('k') is '12' + fancyX + '4'
     28pasting too much text with maxlength=0
     29PASS domValueOf('l') is ''
     30PASS visibleValueOf('l') is ''
    2831PASS successfullyParsed is true
    2932
    3033TEST COMPLETE
    31        
     34         
  • trunk/LayoutTests/fast/forms/input-text-paste-maxlength.html

    r48449 r93390  
    1818<input type="text" id="g" size="5">
    1919<input type="text" id="k" size="5" maxlength="4">
     20<input type="text" id="l" size="5" maxlength="0">
    2021
    2122<script>
     
    9495shouldBe("visibleValueOf('k')", "'12' + fancyX + '4'");
    9596
     97debug("pasting too much text with maxlength=0");
     98document.getElementById("l").focus();
     99document.execCommand("InsertHTML", false, "12x&#x305;&#x332;45");
     100shouldBe("domValueOf('l')", "''");
     101shouldBe("visibleValueOf('l')", "''");
     102
    96103var successfullyParsed = true;
    97104</script>
  • trunk/LayoutTests/fast/forms/script-tests/textarea-maxlength.js

    r81328 r93390  
    4343
    4444// Set up for user-input tests
    45 function createFocusedTextAreaWithMaxLength3() {
     45function createFocusedTextAreaWithMaxLength(maxLength) {
    4646    if (textArea)
    4747        document.body.removeChild(textArea);
    4848    textArea = document.createElement('textarea');
    49     textArea.setAttribute('maxlength', '3');
     49    textArea.setAttribute('maxlength', maxLength);
    5050    document.body.appendChild(textArea);
    5151    textArea.focus();
     
    5353
    5454// Insert text of which length is maxLength.
    55 createFocusedTextAreaWithMaxLength3();
     55createFocusedTextAreaWithMaxLength(3);
    5656document.execCommand('insertText', false, 'abc');
    5757shouldBe('textArea.value', '"abc"');
    5858
    5959// Try to add characters to maxLength characters.
    60 createFocusedTextAreaWithMaxLength3();
     60createFocusedTextAreaWithMaxLength(3);
    6161textArea.value = 'abc';
    6262document.execCommand('insertText', false, 'def');
     
    6464
    6565// Replace text
    66 createFocusedTextAreaWithMaxLength3();
     66createFocusedTextAreaWithMaxLength(3);
    6767textArea.value = 'abc';
    6868document.execCommand('selectAll');
     
    7171
    7272// Existing value is longer than maxLength.  We can't add text.
    73 createFocusedTextAreaWithMaxLength3();
     73createFocusedTextAreaWithMaxLength(3);
    7474textArea.value = 'abcdef';
    7575document.execCommand('insertText', false, 'ghi');
     
    7777
    7878// We can delete a character in the longer value.
    79 createFocusedTextAreaWithMaxLength3();
     79createFocusedTextAreaWithMaxLength(3);
    8080textArea.value = 'abcdef';
    8181document.execCommand('delete');
     
    8383
    8484// A linebreak is 1 character.
    85 createFocusedTextAreaWithMaxLength3();
     85createFocusedTextAreaWithMaxLength(3);
    8686document.execCommand('insertText', false, 'A');
    8787document.execCommand('insertLineBreak');
     
    9090
    9191// Confirms correct count for close linebreaks inputs.
    92 createFocusedTextAreaWithMaxLength3();
     92createFocusedTextAreaWithMaxLength(3);
    9393textArea.innerHTML = 'a\n\n';
    9494document.execCommand('insertLineBreak');
     
    9696
    9797// Confirms correct count for open consecutive linebreaks inputs.
    98 createFocusedTextAreaWithMaxLength3();
     98createFocusedTextAreaWithMaxLength(3);
    9999document.execCommand('insertLineBreak');
    100100document.execCommand('insertLineBreak');
     
    112112
    113113// Inserts 5 code-points in UTF-16
    114 createFocusedTextAreaWithMaxLength3();
     114createFocusedTextAreaWithMaxLength(3);
    115115document.execCommand('insertText', false, 'AB' + fancyX);
    116116shouldBe('textArea.value', '"AB" + fancyX');
    117117shouldBe('textArea.value.length', '5');
    118118
    119 createFocusedTextAreaWithMaxLength3();
     119createFocusedTextAreaWithMaxLength(3);
    120120textArea.value = 'AB' + fancyX;
    121121textArea.setSelectionRange(2, 5);  // Select fancyX
     
    124124
    125125// Inserts 4 code-points in UTF-16
    126 createFocusedTextAreaWithMaxLength3();
     126createFocusedTextAreaWithMaxLength(3);
    127127document.execCommand('insertText', false, 'AB' + u10000);
    128128shouldBe('textArea.value', '"AB" + u10000');
    129129shouldBe('textArea.value.length', '4');
    130130
    131 createFocusedTextAreaWithMaxLength3();
     131createFocusedTextAreaWithMaxLength(3);
    132132textArea.value = 'AB' + u10000;
    133133textArea.setSelectionRange(2, 4);  // Select u10000
     
    135135shouldBe('textArea.value', '"ABC"');
    136136
     137// In the case maxlength=0
     138createFocusedTextAreaWithMaxLength(0);
     139textArea.value = '';
     140document.execCommand('insertText', false, 'ABC');
     141shouldBe('textArea.value', '""');
     142
    137143var successfullyParsed = true;
  • trunk/LayoutTests/fast/forms/textarea-maxlength-expected.txt

    r81328 r93390  
    3030PASS textArea.value.length is 4
    3131PASS textArea.value is "ABC"
     32PASS textArea.value is ""
    3233PASS successfullyParsed is true
    3334
  • trunk/Source/WebCore/ChangeLog

    r93389 r93390  
     12011-08-19  Shinya Kawanaka  <shinyak@google.com>
     2
     3        input[maxlength=0] should ignore text input.
     4        https://bugs.webkit.org/show_bug.cgi?id=65497
     5
     6        Reviewed by Kent Tamura.
     7
     8        Changed the valid range of maxlength.
     9
     10        * html/HTMLInputElement.cpp:
     11        (WebCore::HTMLInputElement::parseMaxLengthAttribute):
     12          Changed maxlength check condition.
     13
    1142011-08-19  Ilya Tikhonovsky  <loislo@chromium.org>
    215
  • trunk/Source/WebCore/html/HTMLInputElement.cpp

    r92592 r93390  
    19231923{
    19241924    int maxLength = attribute->isNull() ? maximumLength : attribute->value().toInt();
    1925     if (maxLength <= 0 || maxLength > maximumLength)
     1925    if (maxLength < 0 || maxLength > maximumLength)
    19261926        maxLength = maximumLength;
    19271927    int oldMaxLength = m_maxLength;
Note: See TracChangeset for help on using the changeset viewer.