Changeset 290124 in webkit


Ignore:
Timestamp:
Feb 18, 2022 7:39:39 AM (5 months ago)
Author:
Ziran Sun
Message:

[InputElement] Return empty string for an invalid floating-point number that ends with "."
https://bugs.webkit.org/show_bug.cgi?id=236700

Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

  • web-platform-tests/html/semantics/forms/the-input-element/number-expected.txt:

Source/WebCore:

As per specs https://html.spec.whatwg.org/multipage/input.html#number-state-(type%3Dnumber),
"If the value of the element is not a valid floating-point number, then set it to the empty
string instead".

  • html/parser/HTMLParserIdioms.cpp:

(WebCore::parseToDoubleForNumberType):

LayoutTests:

  • fast/forms/number/number-stepup-stepdown-expected.txt:
  • fast/forms/number/number-stepup-stepdown-from-renderer-expected.txt:
  • fast/forms/number/number-stepup-stepdown-from-renderer.html:
  • fast/forms/number/number-stepup-stepdown.html:
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r290123 r290124  
     12022-02-18  Ziran Sun  <zsun@igalia.com>
     2
     3        [InputElement] Return empty string for an invalid floating-point number that ends with "."
     4        https://bugs.webkit.org/show_bug.cgi?id=236700
     5
     6        Reviewed by Chris Dumez.
     7
     8        * fast/forms/number/number-stepup-stepdown-expected.txt:
     9        * fast/forms/number/number-stepup-stepdown-from-renderer-expected.txt:
     10        * fast/forms/number/number-stepup-stepdown-from-renderer.html:
     11        * fast/forms/number/number-stepup-stepdown.html:
     12
    1132022-02-18  Antoine Quint  <graouts@webkit.org>
    214
  • trunk/LayoutTests/fast/forms/number/number-stepup-stepdown-expected.txt

    r289465 r290124  
    5757PASS stepUp(".1", 1, null) is "1.1"
    5858PASS stepUp(".2", 1, null) is "1.2"
    59 PASS stepUp("1.", 1, null) is "2"
    60 PASS stepUp("2.", 1, null) is "3"
     59PASS stepUp("1.", 1, null) is "1"
     60PASS stepUp("2.", 1, null) is "1"
    6161
    6262PASS stepUp("-.1", 1, null) is "0.9"
    6363PASS stepUp("-.2", 1, null) is "0.8"
    64 PASS stepUp("-1.", 1, null) is "0"
    65 PASS stepUp("-2.", 1, null) is "-1"
     64PASS stepUp("-1.", 1, null) is "1"
     65PASS stepUp("-2.", 1, null) is "1"
    6666
    6767PASS stepDown(".1", 1, null) is "-0.9"
    6868PASS stepDown(".2", 1, null) is "-0.8"
    69 PASS stepDown("1.", 1, null) is "0"
    70 PASS stepDown("2.", 1, null) is "1"
     69PASS stepDown("1.", 1, null) is "-1"
     70PASS stepDown("2.", 1, null) is "-1"
    7171
    7272PASS stepDown("-.1", 1, null) is "-1.1"
    7373PASS stepDown("-.2", 1, null) is "-1.2"
    74 PASS stepDown("-1.", 1, null) is "-2"
    75 PASS stepDown("-2.", 1, null) is "-3"
     74PASS stepDown("-1.", 1, null) is "-1"
     75PASS stepDown("-2.", 1, null) is "-1"
    7676
    7777PASS stepUp("0.1", .1, null) is "0.2"
     
    105105PASS stepUp(".1", .1, null) is "0.2"
    106106PASS stepUp(".2", .1, null) is "0.3"
    107 PASS stepUp("1.", .1, null) is "1.1"
    108 PASS stepUp("2.", .1, null) is "2.1"
     107PASS stepUp("1.", .1, null) is "0.1"
     108PASS stepUp("2.", .1, null) is "0.1"
    109109
    110110PASS stepUp("-.1", .1, null) is "0"
    111111PASS stepUp("-.2", .1, null) is "-0.1"
    112 PASS stepUp("-1.", .1, null) is "-0.9"
    113 PASS stepUp("-2.", .1, null) is "-1.9"
     112PASS stepUp("-1.", .1, null) is "0.1"
     113PASS stepUp("-2.", .1, null) is "0.1"
    114114
    115115PASS stepDown(".1", .1, null) is "0"
    116116PASS stepDown(".2", .1, null) is "0.1"
    117 PASS stepDown("1.", .1, null) is "0.9"
    118 PASS stepDown("2.", .1, null) is "1.9"
     117PASS stepDown("1.", .1, null) is "-0.1"
     118PASS stepDown("2.", .1, null) is "-0.1"
    119119
    120120PASS stepDown("-.1", .1, null) is "-0.2"
    121121PASS stepDown("-.2", .1, null) is "-0.3"
    122 PASS stepDown("-1.", .1, null) is "-1.1"
    123 PASS stepDown("-2.", .1, null) is "-2.1"
     122PASS stepDown("-1.", .1, null) is "-0.1"
     123PASS stepDown("-2.", .1, null) is "-0.1"
    124124
    125125Extra arguments
  • trunk/LayoutTests/fast/forms/number/number-stepup-stepdown-from-renderer-expected.txt

    r191940 r290124  
    6060PASS stepUp(".1", 1, null) is "1"
    6161PASS stepUp(".2", 1, null) is "1"
    62 PASS stepUp("1.", 1, null) is "2"
    63 PASS stepUp("2.", 1, null) is "3"
     62PASS stepUp("1.", 1, null) is "1"
     63PASS stepUp("2.", 1, null) is "1"
    6464
    6565PASS stepUp("-.1", 1, null) is "0"
    6666PASS stepUp("-.2", 1, null) is "0"
    67 PASS stepUp("-1.", 1, null) is "0"
    68 PASS stepUp("-2.", 1, null) is "-1"
     67PASS stepUp("-1.", 1, null) is "1"
     68PASS stepUp("-2.", 1, null) is "1"
    6969
    7070PASS stepDown(".1", 1, null) is "0"
    7171PASS stepDown(".2", 1, null) is "0"
    72 PASS stepDown("1.", 1, null) is "0"
    73 PASS stepDown("2.", 1, null) is "1"
     72PASS stepDown("1.", 1, null) is "-1"
     73PASS stepDown("2.", 1, null) is "-1"
    7474
    7575PASS stepDown("-.1", 1, null) is "-1"
    7676PASS stepDown("-.2", 1, null) is "-1"
    77 PASS stepDown("-1.", 1, null) is "-2"
    78 PASS stepDown("-2.", 1, null) is "-3"
     77PASS stepDown("-1.", 1, null) is "-1"
     78PASS stepDown("-2.", 1, null) is "-1"
    7979
    8080PASS stepUp("0.1", .1, null) is "0.2"
     
    108108PASS stepUp(".1", .1, null) is "0.2"
    109109PASS stepUp(".2", .1, null) is "0.3"
    110 PASS stepUp("1.", .1, null) is "1.1"
    111 PASS stepUp("2.", .1, null) is "2.1"
     110PASS stepUp("1.", .1, null) is "0.1"
     111PASS stepUp("2.", .1, null) is "0.1"
    112112
    113113PASS stepUp("-.1", .1, null) is "0"
    114114PASS stepUp("-.2", .1, null) is "-0.1"
    115 PASS stepUp("-1.", .1, null) is "-0.9"
    116 PASS stepUp("-2.", .1, null) is "-1.9"
     115PASS stepUp("-1.", .1, null) is "0.1"
     116PASS stepUp("-2.", .1, null) is "0.1"
    117117PASS stepDown(".1", .1, null) is "0"
    118118PASS stepDown(".2", .1, null) is "0.1"
    119 PASS stepDown("1.", .1, null) is "0.9"
    120 PASS stepDown("2.", .1, null) is "1.9"
     119PASS stepDown("1.", .1, null) is "-0.1"
     120PASS stepDown("2.", .1, null) is "-0.1"
    121121
    122122PASS stepDown("-.1", .1, null) is "-0.2"
    123123PASS stepDown("-.2", .1, null) is "-0.3"
    124 PASS stepDown("-1.", .1, null) is "-1.1"
    125 PASS stepDown("-2.", .1, null) is "-2.1"
     124PASS stepDown("-1.", .1, null) is "-0.1"
     125PASS stepDown("-2.", .1, null) is "-0.1"
    126126
    127127Invalid step value
  • trunk/LayoutTests/fast/forms/number/number-stepup-stepdown-from-renderer.html

    r203333 r290124  
    172172shouldBe('stepUp(".1", 1, null)', '"1"');       // Is 1.1 in non-render test
    173173shouldBe('stepUp(".2", 1, null)', '"1"');       // Is 1.2 in non-render test
    174 shouldBe('stepUp("1.", 1, null)', '"2"');
    175 shouldBe('stepUp("2.", 1, null)', '"3"');
     174shouldBe('stepUp("1.", 1, null)', '"1"');
     175shouldBe('stepUp("2.", 1, null)', '"1"');
    176176
    177177debug('');
    178178shouldBe('stepUp("-.1", 1, null)', '"0"');      // Is 0.9 in non-render test
    179179shouldBe('stepUp("-.2", 1, null)', '"0"');      // Is 0.8 in non-render test
    180 shouldBe('stepUp("-1.", 1, null)', '"0"');
    181 shouldBe('stepUp("-2.", 1, null)', '"-1"');
     180shouldBe('stepUp("-1.", 1, null)', '"1"');
     181shouldBe('stepUp("-2.", 1, null)', '"1"');
    182182
    183183debug('');
    184184shouldBe('stepDown(".1", 1, null)', '"0"');     // Is -0.9 in non-render test
    185185shouldBe('stepDown(".2", 1, null)', '"0"');     // Is -0.8 in non-render test
    186 shouldBe('stepDown("1.", 1, null)', '"0"');
    187 shouldBe('stepDown("2.", 1, null)', '"1"');
     186shouldBe('stepDown("1.", 1, null)', '"-1"');
     187shouldBe('stepDown("2.", 1, null)', '"-1"');
    188188
    189189debug('');
    190190shouldBe('stepDown("-.1", 1, null)', '"-1"');   // Is -1.1 in non-render test
    191191shouldBe('stepDown("-.2", 1, null)', '"-1"');   // Is -1.2 in non-render test
    192 shouldBe('stepDown("-1.", 1, null)', '"-2"');
    193 shouldBe('stepDown("-2.", 1, null)', '"-3"');
     192shouldBe('stepDown("-1.", 1, null)', '"-1"');
     193shouldBe('stepDown("-2.", 1, null)', '"-1"');
    194194
    195195// Same as above, but stepping by .1 rather than 1.
     
    229229shouldBe('stepUp(".1", .1, null)', '"0.2"');
    230230shouldBe('stepUp(".2", .1, null)', '"0.3"');
    231 shouldBe('stepUp("1.", .1, null)', '"1.1"');
    232 shouldBe('stepUp("2.", .1, null)', '"2.1"');
     231shouldBe('stepUp("1.", .1, null)', '"0.1"');
     232shouldBe('stepUp("2.", .1, null)', '"0.1"');
    233233
    234234debug('');
    235235shouldBe('stepUp("-.1", .1, null)', '"0"');
    236236shouldBe('stepUp("-.2", .1, null)', '"-0.1"');
    237 shouldBe('stepUp("-1.", .1, null)', '"-0.9"');
    238 shouldBe('stepUp("-2.", .1, null)', '"-1.9"');
     237shouldBe('stepUp("-1.", .1, null)', '"0.1"');
     238shouldBe('stepUp("-2.", .1, null)', '"0.1"');
    239239
    240240shouldBe('stepDown(".1", .1, null)', '"0"');
    241241shouldBe('stepDown(".2", .1, null)', '"0.1"');
    242 shouldBe('stepDown("1.", .1, null)', '"0.9"');
    243 shouldBe('stepDown("2.", .1, null)', '"1.9"');
     242shouldBe('stepDown("1.", .1, null)', '"-0.1"');
     243shouldBe('stepDown("2.", .1, null)', '"-0.1"');
    244244
    245245debug('');
    246246shouldBe('stepDown("-.1", .1, null)', '"-0.2"');
    247247shouldBe('stepDown("-.2", .1, null)', '"-0.3"');
    248 shouldBe('stepDown("-1.", .1, null)', '"-1.1"');
    249 shouldBe('stepDown("-2.", .1, null)', '"-2.1"');
     248shouldBe('stepDown("-1.", .1, null)', '"-0.1"');
     249shouldBe('stepDown("-2.", .1, null)', '"-0.1"');
    250250
    251251debug('');
  • trunk/LayoutTests/fast/forms/number/number-stepup-stepdown.html

    r289465 r290124  
    119119shouldBe('stepUp(".1", 1, null)', '"1.1"');
    120120shouldBe('stepUp(".2", 1, null)', '"1.2"');
    121 shouldBe('stepUp("1.", 1, null)', '"2"');
    122 shouldBe('stepUp("2.", 1, null)', '"3"');
     121shouldBe('stepUp("1.", 1, null)', '"1"');
     122shouldBe('stepUp("2.", 1, null)', '"1"');
    123123
    124124debug('');
    125125shouldBe('stepUp("-.1", 1, null)', '"0.9"');
    126126shouldBe('stepUp("-.2", 1, null)', '"0.8"');
    127 shouldBe('stepUp("-1.", 1, null)', '"0"');
    128 shouldBe('stepUp("-2.", 1, null)', '"-1"');
     127shouldBe('stepUp("-1.", 1, null)', '"1"');
     128shouldBe('stepUp("-2.", 1, null)', '"1"');
    129129
    130130debug('');
    131131shouldBe('stepDown(".1", 1, null)', '"-0.9"');
    132132shouldBe('stepDown(".2", 1, null)', '"-0.8"');
    133 shouldBe('stepDown("1.", 1, null)', '"0"');
    134 shouldBe('stepDown("2.", 1, null)', '"1"');
     133shouldBe('stepDown("1.", 1, null)', '"-1"');
     134shouldBe('stepDown("2.", 1, null)', '"-1"');
    135135
    136136debug('');
    137137shouldBe('stepDown("-.1", 1, null)', '"-1.1"');
    138138shouldBe('stepDown("-.2", 1, null)', '"-1.2"');
    139 shouldBe('stepDown("-1.", 1, null)', '"-2"');
    140 shouldBe('stepDown("-2.", 1, null)', '"-3"');
     139shouldBe('stepDown("-1.", 1, null)', '"-1"');
     140shouldBe('stepDown("-2.", 1, null)', '"-1"');
    141141
    142142// Same as above, but stepping by .1 rather than 1.
     
    176176shouldBe('stepUp(".1", .1, null)', '"0.2"');
    177177shouldBe('stepUp(".2", .1, null)', '"0.3"');
    178 shouldBe('stepUp("1.", .1, null)', '"1.1"');
    179 shouldBe('stepUp("2.", .1, null)', '"2.1"');
     178shouldBe('stepUp("1.", .1, null)', '"0.1"');
     179shouldBe('stepUp("2.", .1, null)', '"0.1"');
    180180
    181181debug('');
    182182shouldBe('stepUp("-.1", .1, null)', '"0"');
    183183shouldBe('stepUp("-.2", .1, null)', '"-0.1"');
    184 shouldBe('stepUp("-1.", .1, null)', '"-0.9"');
    185 shouldBe('stepUp("-2.", .1, null)', '"-1.9"');
     184shouldBe('stepUp("-1.", .1, null)', '"0.1"');
     185shouldBe('stepUp("-2.", .1, null)', '"0.1"');
    186186
    187187debug('');
    188188shouldBe('stepDown(".1", .1, null)', '"0"');
    189189shouldBe('stepDown(".2", .1, null)', '"0.1"');
    190 shouldBe('stepDown("1.", .1, null)', '"0.9"');
    191 shouldBe('stepDown("2.", .1, null)', '"1.9"');
     190shouldBe('stepDown("1.", .1, null)', '"-0.1"');
     191shouldBe('stepDown("2.", .1, null)', '"-0.1"');
    192192
    193193debug('');
    194194shouldBe('stepDown("-.1", .1, null)', '"-0.2"');
    195195shouldBe('stepDown("-.2", .1, null)', '"-0.3"');
    196 shouldBe('stepDown("-1.", .1, null)', '"-1.1"');
    197 shouldBe('stepDown("-2.", .1, null)', '"-2.1"');
     196shouldBe('stepDown("-1.", .1, null)', '"-0.1"');
     197shouldBe('stepDown("-2.", .1, null)', '"-0.1"');
    198198
    199199debug('');
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r290120 r290124  
     12022-02-18  Ziran Sun  <zsun@igalia.com>
     2
     3        [InputElement] Return empty string for an invalid floating-point number that ends with "."
     4        https://bugs.webkit.org/show_bug.cgi?id=236700
     5
     6        Reviewed by Chris Dumez.
     7
     8        * web-platform-tests/html/semantics/forms/the-input-element/number-expected.txt:
     9
    1102022-02-18  Jon Lee  <jonlee@apple.com>
    211
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/number-expected.txt

    r267646 r290124  
    1616PASS Value > max attribute
    1717PASS value with a leading '.'
    18 FAIL value ending with '.' assert_equals: expected "" but got "1."
     18PASS value ending with '.'
    1919PASS value = -0
    2020PASS  value = Infinity
  • trunk/Source/WebCore/ChangeLog

    r290123 r290124  
     12022-02-18  Ziran Sun  <zsun@igalia.com>
     2
     3        [InputElement] Return empty string for an invalid floating-point number that ends with "."
     4        https://bugs.webkit.org/show_bug.cgi?id=236700
     5
     6        Reviewed by Chris Dumez.
     7
     8        As per specs https://html.spec.whatwg.org/multipage/input.html#number-state-(type%3Dnumber),   
     9        "If the value of the element is not a valid floating-point number, then set it to the empty
     10        string instead".
     11
     12        * html/parser/HTMLParserIdioms.cpp:
     13        (WebCore::parseToDoubleForNumberType):
     14
    1152022-02-18  Antoine Quint  <graouts@webkit.org>
    216
  • trunk/Source/WebCore/html/parser/HTMLParserIdioms.cpp

    r282242 r290124  
    131131        return fallbackValue;
    132132
     133    if (string.endsWith('.'))
     134        return fallbackValue;
     135
    133136    bool valid = false;
    134137    double value = string.toDouble(&valid);
Note: See TracChangeset for help on using the changeset viewer.