Changeset 191940 in webkit


Ignore:
Timestamp:
Nov 2, 2015 11:21:41 PM (9 years ago)
Author:
commit-queue@webkit.org
Message:

input[type=number] does not increment/decrement integers with trailing decimal characters
https://bugs.webkit.org/show_bug.cgi?id=148867
rdar://problem/22589693

Patch by Keith Rollin <Keith Rollin> on 2015-11-02
Reviewed by Chris Dumez.

Source/WebCore:

Support input[type=number].value attributes of the form "###." (that
is, leading digits with a decimal but no trailing digits). This form
was supported in the setting of the attribute, but not when changing
it through stepUp/Down.

Testing turned up similarly incorrect processing of -.###, so
addressed that, too.

Test: fast/forms/range/input-appearance-range-decimals.html

Updated the following tests:

  • fast/forms/number/number-stepup-stepdown-from-renderer.html
  • fast/forms/number/number-stepup-stepdown.html
  • fast/forms/range/range-stepup-stepdown-from-renderer.html
  • fast/forms/range/range-stepup-stepdown.html
  • html/InputType.cpp:

(WebCore::InputType::stepUpFromRenderer):

  • platform/Decimal.cpp:

(WebCore::Decimal::fromString):

LayoutTests:

New tests for input[type=number].skipUp/Down when .value ends in a
decimal point (with no additional trailing digits). Also some coverage
for input[type=range] which shares some same code.

  • 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:
  • fast/forms/range/range-stepup-stepdown-expected.txt:
  • fast/forms/range/range-stepup-stepdown-from-renderer-expected.txt:
  • fast/forms/range/range-stepup-stepdown-from-renderer.html:
  • fast/forms/range/range-stepup-stepdown.html:
  • fast/forms/range/input-appearance-range-decimals-expected.html: Added
  • fast/forms/range/input-appearance-range-decimals.html: Added
Location:
trunk
Files:
2 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r191939 r191940  
     12015-11-02  Keith Rollin  <krollin@apple.com>
     2
     3        input[type=number] does not increment/decrement integers with trailing decimal characters
     4        https://bugs.webkit.org/show_bug.cgi?id=148867
     5        rdar://problem/22589693
     6
     7        Reviewed by Chris Dumez.
     8
     9        New tests for input[type=number].skipUp/Down when .value ends in a
     10        decimal point (with no additional trailing digits). Also some coverage
     11        for input[type=range] which shares some same code.
     12
     13        * fast/forms/number/number-stepup-stepdown-expected.txt:
     14        * fast/forms/number/number-stepup-stepdown-from-renderer-expected.txt:
     15        * fast/forms/number/number-stepup-stepdown-from-renderer.html:
     16        * fast/forms/number/number-stepup-stepdown.html:
     17        * fast/forms/range/range-stepup-stepdown-expected.txt:
     18        * fast/forms/range/range-stepup-stepdown-from-renderer-expected.txt:
     19        * fast/forms/range/range-stepup-stepdown-from-renderer.html:
     20        * fast/forms/range/range-stepup-stepdown.html:
     21        * fast/forms/range/input-appearance-range-decimals-expected.html: Added
     22        * fast/forms/range/input-appearance-range-decimals.html: Added
     23
    1242015-11-02  Myles C. Maxfield  <mmaxfield@apple.com>
    225
  • trunk/LayoutTests/fast/forms/number/number-stepup-stepdown-expected.txt

    r134648 r191940  
    55
    66Number type
     7
    78Invalid value
    89PASS stepUp("", null, null) threw exception Error: InvalidStateError: DOM Exception 11.
    910PASS stepDown("", null, null) threw exception Error: InvalidStateError: DOM Exception 11.
     11
    1012Non-number arguments
    1113PASS stepUp("0", null, null, "0") is "0"
     
    1517PASS stepUp("0", null, null, null) is "0"
    1618PASS stepDown("0", null, null, null) is "0"
     19
    1720Normal cases
    1821PASS stepUp("0", null, null) is "1"
     
    2225PASS stepDown("1", null, null, 2) is "-1"
    2326PASS stepDown("-1", null, null, -1) is "0"
     27
     28Fractional cases
     29PASS stepUp("0.1", 1, null) is "1.1"
     30PASS stepUp("0.2", 1, null) is "1.2"
     31PASS stepUp("1.0", 1, null) is "2"
     32PASS stepUp("1.1", 1, null) is "2.1"
     33PASS stepUp("1.2", 1, null) is "2.2"
     34PASS stepUp("2.0", 1, null) is "3"
     35
     36PASS stepUp("-0.1", 1, null) is "0.9"
     37PASS stepUp("-0.2", 1, null) is "0.8"
     38PASS stepUp("-1.0", 1, null) is "0"
     39PASS stepUp("-1.1", 1, null) is "-0.1"
     40PASS stepUp("-1.2", 1, null) is "-0.2"
     41PASS stepUp("-2.0", 1, null) is "-1"
     42
     43PASS stepDown("0.1", 1, null) is "-0.9"
     44PASS stepDown("0.2", 1, null) is "-0.8"
     45PASS stepDown("1.0", 1, null) is "0"
     46PASS stepDown("1.1", 1, null) is "0.1"
     47PASS stepDown("1.2", 1, null) is "0.2"
     48PASS stepDown("2.0", 1, null) is "1"
     49
     50PASS stepDown("-0.1", 1, null) is "-1.1"
     51PASS stepDown("-0.2", 1, null) is "-1.2"
     52PASS stepDown("-1.0", 1, null) is "-2"
     53PASS stepDown("-1.1", 1, null) is "-2.1"
     54PASS stepDown("-1.2", 1, null) is "-2.2"
     55PASS stepDown("-2.0", 1, null) is "-3"
     56
     57PASS stepUp(".1", 1, null) is "1.1"
     58PASS stepUp(".2", 1, null) is "1.2"
     59PASS stepUp("1.", 1, null) is "2"
     60PASS stepUp("2.", 1, null) is "3"
     61
     62PASS stepUp("-.1", 1, null) is "0.9"
     63PASS stepUp("-.2", 1, null) is "0.8"
     64PASS stepUp("-1.", 1, null) is "0"
     65PASS stepUp("-2.", 1, null) is "-1"
     66
     67PASS stepDown(".1", 1, null) is "-0.9"
     68PASS stepDown(".2", 1, null) is "-0.8"
     69PASS stepDown("1.", 1, null) is "0"
     70PASS stepDown("2.", 1, null) is "1"
     71
     72PASS stepDown("-.1", 1, null) is "-1.1"
     73PASS stepDown("-.2", 1, null) is "-1.2"
     74PASS stepDown("-1.", 1, null) is "-2"
     75PASS stepDown("-2.", 1, null) is "-3"
     76
     77PASS stepUp("0.1", .1, null) is "0.2"
     78PASS stepUp("0.2", .1, null) is "0.3"
     79PASS stepUp("1.0", .1, null) is "1.1"
     80PASS stepUp("1.1", .1, null) is "1.2"
     81PASS stepUp("1.2", .1, null) is "1.3"
     82PASS stepUp("2.0", .1, null) is "2.1"
     83
     84PASS stepUp("-0.1", .1, null) is "0"
     85PASS stepUp("-0.2", .1, null) is "-0.1"
     86PASS stepUp("-1.0", .1, null) is "-0.9"
     87PASS stepUp("-1.1", .1, null) is "-1"
     88PASS stepUp("-1.2", .1, null) is "-1.1"
     89PASS stepUp("-2.0", .1, null) is "-1.9"
     90
     91PASS stepDown("0.1", .1, null) is "0"
     92PASS stepDown("0.2", .1, null) is "0.1"
     93PASS stepDown("1.0", .1, null) is "0.9"
     94PASS stepDown("1.1", .1, null) is "1"
     95PASS stepDown("1.2", .1, null) is "1.1"
     96PASS stepDown("2.0", .1, null) is "1.9"
     97
     98PASS stepDown("-0.1", .1, null) is "-0.2"
     99PASS stepDown("-0.2", .1, null) is "-0.3"
     100PASS stepDown("-1.0", .1, null) is "-1.1"
     101PASS stepDown("-1.1", .1, null) is "-1.2"
     102PASS stepDown("-1.2", .1, null) is "-1.3"
     103PASS stepDown("-2.0", .1, null) is "-2.1"
     104
     105PASS stepUp(".1", .1, null) is "0.2"
     106PASS stepUp(".2", .1, null) is "0.3"
     107PASS stepUp("1.", .1, null) is "1.1"
     108PASS stepUp("2.", .1, null) is "2.1"
     109
     110PASS stepUp("-.1", .1, null) is "0"
     111PASS stepUp("-.2", .1, null) is "-0.1"
     112PASS stepUp("-1.", .1, null) is "-0.9"
     113PASS stepUp("-2.", .1, null) is "-1.9"
     114
     115PASS stepDown(".1", .1, null) is "0"
     116PASS stepDown(".2", .1, null) is "0.1"
     117PASS stepDown("1.", .1, null) is "0.9"
     118PASS stepDown("2.", .1, null) is "1.9"
     119
     120PASS stepDown("-.1", .1, null) is "-0.2"
     121PASS stepDown("-.2", .1, null) is "-0.3"
     122PASS stepDown("-1.", .1, null) is "-1.1"
     123PASS stepDown("-2.", .1, null) is "-2.1"
     124
    24125Extra arguments
    25126PASS input.value = "0"; input.min = null; input.step = null; input.stepUp(1, 2); input.value is "1"
    26127PASS input.value = "1"; input.stepDown(1, 3); input.value is "0"
     128
    27129Invalid step value
    28130PASS stepUp("0", "foo", null) is "1"
    29131PASS stepUp("1", "0", null) is "2"
    30132PASS stepUp("2", "-1", null) is "3"
     133
    31134Step=any
    32135PASS stepUp("0", "any", null) threw exception Error: InvalidStateError: DOM Exception 11.
    33136PASS stepDown("0", "any", null) threw exception Error: InvalidStateError: DOM Exception 11.
     137
    34138Step=any corner case
    35139PASS stepUpExplicitBounds("0", "100", "any", "1.5", "1") threw exception Error: InvalidStateError: DOM Exception 11.
    36140PASS stepDownExplicitBounds("0", "100", "any", "1.5", "1") threw exception Error: InvalidStateError: DOM Exception 11.
     141
    37142Overflow/underflow
    38143PASS stepDown("1", "1", "0") is "0"
     
    46151PASS input.value is "-1"
    47152PASS stepUp("1", "3.40282346e+38", "", 2) threw exception Error: InvalidStateError: DOM Exception 11.
     153
    48154stepDown()/stepUp() for stepMismatch values
    49155PASS stepUp("1", "2", "") is "3"
     
    52158PASS stepDown("19", "10", "0") is "9"
    53159PASS stepUp("89", "10", "99") is "99"
     160
    54161Huge value and small step
    55162PASS input.min = ""; stepUp("1e+38", "1", "", 999999) is "1e+38"
    56163PASS input.max = ""; stepDown("1e+38", "1", "", 999999) is "1e+38"
     164
    57165Fractional numbers
    58166PASS input.min = ""; stepUp("0", "0.33333333333333333", "", 3) is "1"
     
    61169PASS input.min = "0"; stepUp("0", "0.003921568627450980", "1", 255) is "1"
    62170PASS for (var i = 0; i < 255; i++) { input.stepDown(); }; input.value is "0"
     171
    63172Rounding
    64173PASS stepUp("5.005", "0.005", "", 2) is "5.015"
     
    68177PASS stepUpExplicitBounds("4", "9", "0.005", "5.005", 11) is "5.06"
    69178PASS stepUpExplicitBounds("4", "9", "0.005", "5.005", 12) is "5.065"
     179
    70180PASS successfullyParsed is true
    71181
  • trunk/LayoutTests/fast/forms/number/number-stepup-stepdown-from-renderer-expected.txt

    r122552 r191940  
    66Number type
    77Function arguments are (value, step, {min or max}, [stepCount]).
     8
    89Invalid value
    910PASS stepUp("", null, null) is "1"
     
    1920PASS stepUp("foo", "foo", null) is "1"
    2021PASS stepDown("foo", "foo", null) is "-1"
     22
    2123Normal cases
    2224PASS stepUp("0", null, null) is "1"
     
    2628PASS stepDown("1", null, null, 2) is "-1"
    2729PASS stepDown("-1", null, null, -1) is "0"
     30
     31Fractional cases
     32PASS stepUp("0.1", 1, null) is "1"
     33PASS stepUp("0.2", 1, null) is "1"
     34PASS stepUp("1.0", 1, null) is "2"
     35PASS stepUp("1.1", 1, null) is "2"
     36PASS stepUp("1.2", 1, null) is "2"
     37PASS stepUp("2.0", 1, null) is "3"
     38
     39PASS stepUp("-0.1", 1, null) is "0"
     40PASS stepUp("-0.2", 1, null) is "0"
     41PASS stepUp("-1.0", 1, null) is "0"
     42PASS stepUp("-1.1", 1, null) is "-1"
     43PASS stepUp("-1.2", 1, null) is "-1"
     44PASS stepUp("-2.0", 1, null) is "-1"
     45
     46PASS stepDown("0.1", 1, null) is "0"
     47PASS stepDown("0.2", 1, null) is "0"
     48PASS stepDown("1.0", 1, null) is "0"
     49PASS stepDown("1.1", 1, null) is "1"
     50PASS stepDown("1.2", 1, null) is "1"
     51PASS stepDown("2.0", 1, null) is "1"
     52
     53PASS stepDown("-0.1", 1, null) is "-1"
     54PASS stepDown("-0.2", 1, null) is "-1"
     55PASS stepDown("-1.0", 1, null) is "-2"
     56PASS stepDown("-1.1", 1, null) is "-2"
     57PASS stepDown("-1.2", 1, null) is "-2"
     58PASS stepDown("-2.0", 1, null) is "-3"
     59
     60PASS stepUp(".1", 1, null) is "1"
     61PASS stepUp(".2", 1, null) is "1"
     62PASS stepUp("1.", 1, null) is "2"
     63PASS stepUp("2.", 1, null) is "3"
     64
     65PASS stepUp("-.1", 1, null) is "0"
     66PASS stepUp("-.2", 1, null) is "0"
     67PASS stepUp("-1.", 1, null) is "0"
     68PASS stepUp("-2.", 1, null) is "-1"
     69
     70PASS stepDown(".1", 1, null) is "0"
     71PASS stepDown(".2", 1, null) is "0"
     72PASS stepDown("1.", 1, null) is "0"
     73PASS stepDown("2.", 1, null) is "1"
     74
     75PASS stepDown("-.1", 1, null) is "-1"
     76PASS stepDown("-.2", 1, null) is "-1"
     77PASS stepDown("-1.", 1, null) is "-2"
     78PASS stepDown("-2.", 1, null) is "-3"
     79
     80PASS stepUp("0.1", .1, null) is "0.2"
     81PASS stepUp("0.2", .1, null) is "0.3"
     82PASS stepUp("1.0", .1, null) is "1.1"
     83PASS stepUp("1.1", .1, null) is "1.2"
     84PASS stepUp("1.2", .1, null) is "1.3"
     85PASS stepUp("2.0", .1, null) is "2.1"
     86
     87PASS stepUp("-0.1", .1, null) is "0"
     88PASS stepUp("-0.2", .1, null) is "-0.1"
     89PASS stepUp("-1.0", .1, null) is "-0.9"
     90PASS stepUp("-1.1", .1, null) is "-1"
     91PASS stepUp("-1.2", .1, null) is "-1.1"
     92PASS stepUp("-2.0", .1, null) is "-1.9"
     93
     94PASS stepDown("0.1", .1, null) is "0"
     95PASS stepDown("0.2", .1, null) is "0.1"
     96PASS stepDown("1.0", .1, null) is "0.9"
     97PASS stepDown("1.1", .1, null) is "1"
     98PASS stepDown("1.2", .1, null) is "1.1"
     99PASS stepDown("2.0", .1, null) is "1.9"
     100
     101PASS stepDown("-0.1", .1, null) is "-0.2"
     102PASS stepDown("-0.2", .1, null) is "-0.3"
     103PASS stepDown("-1.0", .1, null) is "-1.1"
     104PASS stepDown("-1.1", .1, null) is "-1.2"
     105PASS stepDown("-1.2", .1, null) is "-1.3"
     106PASS stepDown("-2.0", .1, null) is "-2.1"
     107
     108PASS stepUp(".1", .1, null) is "0.2"
     109PASS stepUp(".2", .1, null) is "0.3"
     110PASS stepUp("1.", .1, null) is "1.1"
     111PASS stepUp("2.", .1, null) is "2.1"
     112
     113PASS stepUp("-.1", .1, null) is "0"
     114PASS stepUp("-.2", .1, null) is "-0.1"
     115PASS stepUp("-1.", .1, null) is "-0.9"
     116PASS stepUp("-2.", .1, null) is "-1.9"
     117PASS stepDown(".1", .1, null) is "0"
     118PASS stepDown(".2", .1, null) is "0.1"
     119PASS stepDown("1.", .1, null) is "0.9"
     120PASS stepDown("2.", .1, null) is "1.9"
     121
     122PASS stepDown("-.1", .1, null) is "-0.2"
     123PASS stepDown("-.2", .1, null) is "-0.3"
     124PASS stepDown("-1.", .1, null) is "-1.1"
     125PASS stepDown("-2.", .1, null) is "-2.1"
     126
    28127Invalid step value
    29128PASS stepUp("0", "foo", null) is "1"
    30129PASS stepUp("1", "0", null) is "2"
    31130PASS stepUp("2", "-1", null) is "3"
     131
    32132Step=any
    33133PASS stepUp("0", "any", null) is "1"
    34134PASS stepDown("0", "any", null) is "-1"
     135
    35136Step=any corner case
    36137PASS stepUpExplicitBounds("0", "100", "any", "1.5", "1") is "2.5"
    37138PASS stepDownExplicitBounds("0", "100", "any", "1.5", "1") is "0.5"
     139
    38140Overflow/underflow
    39141PASS stepDown("1", "1", "0") is "0"
     
    45147PASS stepUp("-1", "1", "0", 2) is "0"
    46148PASS stepUp("1", "3.40282346e+38", "", 2) is "3.40282346e+38"
     149
    47150stepDown()/stepUp() for stepMismatch values
    48151PASS stepUp("1", "2", "") is "2"
     
    54157PASS stepDown("7", "300", "") is "0"
    55158PASS stepDown("-7", "300", "") is "-300"
     159
    56160Huge value and small step
    57161PASS input.min = ""; stepUp("1e+38", "1", "", 999) is "1e+38"
    58162PASS input.max = ""; stepDown("1e+38", "1", "", 999) is "1e+38"
     163
    59164Fractional numbers
    60165PASS input.min = ""; stepUp("0", "0.33333333333333333", "", 3) is "1"
    61166PASS stepUp("1", "0.1", "", 10) is "2"
    62167PASS input.min = "0"; stepUp("0", "0.003921568627450980", "1", 255) is "1"
     168
    63169Rounding
    64170PASS stepUp("5.005", "0.005", "", 2) is "5.015"
  • trunk/LayoutTests/fast/forms/number/number-stepup-stepdown-from-renderer.html

    r155268 r191940  
    8888input.type = 'number';
    8989debug('Function arguments are (value, step, {min or max}, [stepCount]).');
     90
     91debug('');
    9092debug('Invalid value');
    9193shouldBe('stepUp("", null, null)', '"1"');
     
    101103shouldBe('stepUp("foo", "foo", null)', '"1"');
    102104shouldBe('stepDown("foo", "foo", null)', '"-1"');
     105
     106debug('');
    103107debug('Normal cases');
    104108shouldBe('stepUp("0", null, null)', '"1"');
     
    108112shouldBe('stepDown("1", null, null, 2)', '"-1"');
    109113shouldBe('stepDown("-1", null, null, -1)', '"0"');
     114
     115debug('');
     116debug('Fractional cases')
     117
     118// Note: these tests also appear in number-stepup-stepdown.html. However, the
     119// results here differ from the results there. According to:
     120//
     121//      https://html.spec.whatwg.org/multipage/forms.html#number-state-(type=number)
     122//
     123// The browser is allowed to clamp resulting values to the nearest multiple of
     124// the [step] value:
     125//
     126//      When the element is suffering from a step mismatch, the user agent may
     127//      round the element's value to the nearest number for which the element
     128//      would not suffer from a step mismatch. If there are two such numbers,
     129//      user agents are encouraged to pick the one nearest positive infinity.
     130//
     131// WebKit seesm to perform this clamping when stepping from the UI, but not
     132// from the API.
     133//
     134// See also the function comment for InputType::stepUpFromRenderer.
     135
     136// Base/model/template tests
     137shouldBe('stepUp("0.1", 1, null)', '"1"')       // Is 1.1 in non-render test
     138shouldBe('stepUp("0.2", 1, null)', '"1"');      // Is 1.1 in non-render test
     139shouldBe('stepUp("1.0", 1, null)', '"2"');
     140shouldBe('stepUp("1.1", 1, null)', '"2"');      // Is 2.1 in non-render test
     141shouldBe('stepUp("1.2", 1, null)', '"2"');      // Is 2.2 in non-render test
     142shouldBe('stepUp("2.0", 1, null)', '"3"');
     143
     144debug('');
     145// Same as above, but with negative numbers.
     146shouldBe('stepUp("-0.1", 1, null)', '"0"');     // Is 0.9 in non-render test
     147shouldBe('stepUp("-0.2", 1, null)', '"0"');     // Is 0.8 in non-render test
     148shouldBe('stepUp("-1.0", 1, null)', '"0"');
     149shouldBe('stepUp("-1.1", 1, null)', '"-1"');    // Is -0.1 in non-render test
     150shouldBe('stepUp("-1.2", 1, null)', '"-1"');    // Is -0.2 in non-render test
     151shouldBe('stepUp("-2.0", 1, null)', '"-1"');
     152
     153debug('');
     154// Same as above, but stepping down rather than up.
     155shouldBe('stepDown("0.1", 1, null)', '"0"');    // Is -0.9 in non-render test
     156shouldBe('stepDown("0.2", 1, null)', '"0"');    // Is -0.8 in non-render test
     157shouldBe('stepDown("1.0", 1, null)', '"0"');
     158shouldBe('stepDown("1.1", 1, null)', '"1"');    // Is 0.1 in non-render test
     159shouldBe('stepDown("1.2", 1, null)', '"1"');    // Is 0.2 in non-render test
     160shouldBe('stepDown("2.0", 1, null)', '"1"');
     161
     162debug('');
     163shouldBe('stepDown("-0.1", 1, null)', '"-1"');  // Is -1.1 in non-render test
     164shouldBe('stepDown("-0.2", 1, null)', '"-1"');  // Is -1.2 in non-render test
     165shouldBe('stepDown("-1.0", 1, null)', '"-2"');
     166shouldBe('stepDown("-1.1", 1, null)', '"-2"');  // Is -2.1 in non-render test
     167shouldBe('stepDown("-1.2", 1, null)', '"-2"');  // Is -2.2 in non-render test
     168shouldBe('stepDown("-2.0", 1, null)', '"-3"');
     169
     170// Same as above, but with leading/trailing zeros removed.
     171debug('');
     172shouldBe('stepUp(".1", 1, null)', '"1"');       // Is 1.1 in non-render test
     173shouldBe('stepUp(".2", 1, null)', '"1"');       // Is 1.2 in non-render test
     174shouldBe('stepUp("1.", 1, null)', '"2"');
     175shouldBe('stepUp("2.", 1, null)', '"3"');
     176
     177debug('');
     178shouldBe('stepUp("-.1", 1, null)', '"0"');      // Is 0.9 in non-render test
     179shouldBe('stepUp("-.2", 1, null)', '"0"');      // Is 0.8 in non-render test
     180shouldBe('stepUp("-1.", 1, null)', '"0"');
     181shouldBe('stepUp("-2.", 1, null)', '"-1"');
     182
     183debug('');
     184shouldBe('stepDown(".1", 1, null)', '"0"');     // Is -0.9 in non-render test
     185shouldBe('stepDown(".2", 1, null)', '"0"');     // Is -0.8 in non-render test
     186shouldBe('stepDown("1.", 1, null)', '"0"');
     187shouldBe('stepDown("2.", 1, null)', '"1"');
     188
     189debug('');
     190shouldBe('stepDown("-.1", 1, null)', '"-1"');   // Is -1.1 in non-render test
     191shouldBe('stepDown("-.2", 1, null)', '"-1"');   // Is -1.2 in non-render test
     192shouldBe('stepDown("-1.", 1, null)', '"-2"');
     193shouldBe('stepDown("-2.", 1, null)', '"-3"');
     194
     195// Same as above, but stepping by .1 rather than 1.
     196debug('');
     197shouldBe('stepUp("0.1", .1, null)', '"0.2"');
     198shouldBe('stepUp("0.2", .1, null)', '"0.3"');
     199shouldBe('stepUp("1.0", .1, null)', '"1.1"');
     200shouldBe('stepUp("1.1", .1, null)', '"1.2"');
     201shouldBe('stepUp("1.2", .1, null)', '"1.3"');
     202shouldBe('stepUp("2.0", .1, null)', '"2.1"');
     203
     204debug('');
     205shouldBe('stepUp("-0.1", .1, null)', '"0"');
     206shouldBe('stepUp("-0.2", .1, null)', '"-0.1"');
     207shouldBe('stepUp("-1.0", .1, null)', '"-0.9"');
     208shouldBe('stepUp("-1.1", .1, null)', '"-1"');
     209shouldBe('stepUp("-1.2", .1, null)', '"-1.1"');
     210shouldBe('stepUp("-2.0", .1, null)', '"-1.9"');
     211
     212debug('');
     213shouldBe('stepDown("0.1", .1, null)', '"0"');
     214shouldBe('stepDown("0.2", .1, null)', '"0.1"');
     215shouldBe('stepDown("1.0", .1, null)', '"0.9"');
     216shouldBe('stepDown("1.1", .1, null)', '"1"');
     217shouldBe('stepDown("1.2", .1, null)', '"1.1"');
     218shouldBe('stepDown("2.0", .1, null)', '"1.9"');
     219
     220debug('');
     221shouldBe('stepDown("-0.1", .1, null)', '"-0.2"');
     222shouldBe('stepDown("-0.2", .1, null)', '"-0.3"');
     223shouldBe('stepDown("-1.0", .1, null)', '"-1.1"');
     224shouldBe('stepDown("-1.1", .1, null)', '"-1.2"');
     225shouldBe('stepDown("-1.2", .1, null)', '"-1.3"');
     226shouldBe('stepDown("-2.0", .1, null)', '"-2.1"');
     227
     228debug('');
     229shouldBe('stepUp(".1", .1, null)', '"0.2"');
     230shouldBe('stepUp(".2", .1, null)', '"0.3"');
     231shouldBe('stepUp("1.", .1, null)', '"1.1"');
     232shouldBe('stepUp("2.", .1, null)', '"2.1"');
     233
     234debug('');
     235shouldBe('stepUp("-.1", .1, null)', '"0"');
     236shouldBe('stepUp("-.2", .1, null)', '"-0.1"');
     237shouldBe('stepUp("-1.", .1, null)', '"-0.9"');
     238shouldBe('stepUp("-2.", .1, null)', '"-1.9"');
     239
     240shouldBe('stepDown(".1", .1, null)', '"0"');
     241shouldBe('stepDown(".2", .1, null)', '"0.1"');
     242shouldBe('stepDown("1.", .1, null)', '"0.9"');
     243shouldBe('stepDown("2.", .1, null)', '"1.9"');
     244
     245debug('');
     246shouldBe('stepDown("-.1", .1, null)', '"-0.2"');
     247shouldBe('stepDown("-.2", .1, null)', '"-0.3"');
     248shouldBe('stepDown("-1.", .1, null)', '"-1.1"');
     249shouldBe('stepDown("-2.", .1, null)', '"-2.1"');
     250
     251debug('');
    110252debug('Invalid step value');
    111253shouldBe('stepUp("0", "foo", null)', '"1"');
    112254shouldBe('stepUp("1", "0", null)', '"2"');
    113255shouldBe('stepUp("2", "-1", null)', '"3"');
     256
     257debug('');
    114258debug('Step=any');
    115259shouldBe('stepUp("0", "any", null)', '"1"');
    116260shouldBe('stepDown("0", "any", null)', '"-1"');
     261
     262debug('');
    117263debug('Step=any corner case');
    118264shouldBe('stepUpExplicitBounds("0", "100", "any", "1.5", "1")', '"2.5"');
    119265shouldBe('stepDownExplicitBounds("0", "100", "any", "1.5", "1")', '"0.5"');
     266
     267debug('');
    120268debug('Overflow/underflow');
    121269shouldBe('stepDown("1", "1", "0")', '"0"');
     
    127275shouldBe('stepUp("-1", "1", "0", 2)', '"0"');
    128276shouldBe('stepUp("1", "3.40282346e+38", "", 2)', '"3.40282346e+38"');
     277
     278debug('');
    129279debug('stepDown()/stepUp() for stepMismatch values');
    130280shouldBe('stepUp("1", "2", "")', '"2"');
     
    136286shouldBe('stepDown("7", "300", "")', '"0"');
    137287shouldBe('stepDown("-7", "300", "")', '"-300"');
     288
     289debug('');
    138290debug('Huge value and small step');
    139291shouldBe('input.min = ""; stepUp("1e+38", "1", "", 999)', '"1e+38"');
    140292shouldBe('input.max = ""; stepDown("1e+38", "1", "", 999)', '"1e+38"');
     293
     294debug('');
    141295debug('Fractional numbers');
    142296shouldBe('input.min = ""; stepUp("0", "0.33333333333333333", "", 3)', '"1"');
    143297shouldBe('stepUp("1", "0.1", "", 10)', '"2"');
    144298shouldBe('input.min = "0"; stepUp("0", "0.003921568627450980", "1", 255)', '"1"');
     299
     300debug('');
    145301debug('Rounding');
    146302shouldBe('stepUp("5.005", "0.005", "", 2)', '"5.015"');
  • trunk/LayoutTests/fast/forms/number/number-stepup-stepdown.html

    r155268 r191940  
    5656debug('Number type');
    5757input.type = 'number';
     58
     59debug('');
    5860debug('Invalid value');
    5961shouldThrow('stepUp("", null, null)', invalidStateErr);
    6062shouldThrow('stepDown("", null, null)', invalidStateErr);
     63
     64debug('');
    6165debug('Non-number arguments');
    6266shouldBe('stepUp("0", null, null, "0")', '"0"');
     
    6670shouldBe('stepUp("0", null, null, null)', '"0"');
    6771shouldBe('stepDown("0", null, null, null)', '"0"');
     72
     73debug('');
    6874debug('Normal cases');
    6975shouldBe('stepUp("0", null, null)', '"1"');
     
    7379shouldBe('stepDown("1", null, null, 2)', '"-1"');
    7480shouldBe('stepDown("-1", null, null, -1)', '"0"');
     81
     82debug('');
     83debug('Fractional cases')
     84// Base/model/template tests
     85shouldBe('stepUp("0.1", 1, null)', '"1.1"');
     86shouldBe('stepUp("0.2", 1, null)', '"1.2"');
     87shouldBe('stepUp("1.0", 1, null)', '"2"');
     88shouldBe('stepUp("1.1", 1, null)', '"2.1"');
     89shouldBe('stepUp("1.2", 1, null)', '"2.2"');
     90shouldBe('stepUp("2.0", 1, null)', '"3"');
     91
     92// Same as above, but with negative numbers.
     93debug('');
     94shouldBe('stepUp("-0.1", 1, null)', '"0.9"');
     95shouldBe('stepUp("-0.2", 1, null)', '"0.8"');
     96shouldBe('stepUp("-1.0", 1, null)', '"0"');
     97shouldBe('stepUp("-1.1", 1, null)', '"-0.1"');
     98shouldBe('stepUp("-1.2", 1, null)', '"-0.2"');
     99shouldBe('stepUp("-2.0", 1, null)', '"-1"');
     100
     101// Same as above, but stepping down rather than up.
     102debug('');
     103shouldBe('stepDown("0.1", 1, null)', '"-0.9"');
     104shouldBe('stepDown("0.2", 1, null)', '"-0.8"');
     105shouldBe('stepDown("1.0", 1, null)', '"0"');
     106shouldBe('stepDown("1.1", 1, null)', '"0.1"');
     107shouldBe('stepDown("1.2", 1, null)', '"0.2"');
     108shouldBe('stepDown("2.0", 1, null)', '"1"');
     109
     110debug('');
     111shouldBe('stepDown("-0.1", 1, null)', '"-1.1"');
     112shouldBe('stepDown("-0.2", 1, null)', '"-1.2"');
     113shouldBe('stepDown("-1.0", 1, null)', '"-2"');
     114shouldBe('stepDown("-1.1", 1, null)', '"-2.1"');
     115shouldBe('stepDown("-1.2", 1, null)', '"-2.2"');
     116shouldBe('stepDown("-2.0", 1, null)', '"-3"');
     117
     118// Same as above, but with leading/trailing zeros removed.
     119debug('');
     120shouldBe('stepUp(".1", 1, null)', '"1.1"');
     121shouldBe('stepUp(".2", 1, null)', '"1.2"');
     122shouldBe('stepUp("1.", 1, null)', '"2"');
     123shouldBe('stepUp("2.", 1, null)', '"3"');
     124
     125debug('');
     126shouldBe('stepUp("-.1", 1, null)', '"0.9"');
     127shouldBe('stepUp("-.2", 1, null)', '"0.8"');
     128shouldBe('stepUp("-1.", 1, null)', '"0"');
     129shouldBe('stepUp("-2.", 1, null)', '"-1"');
     130
     131debug('');
     132shouldBe('stepDown(".1", 1, null)', '"-0.9"');
     133shouldBe('stepDown(".2", 1, null)', '"-0.8"');
     134shouldBe('stepDown("1.", 1, null)', '"0"');
     135shouldBe('stepDown("2.", 1, null)', '"1"');
     136
     137debug('');
     138shouldBe('stepDown("-.1", 1, null)', '"-1.1"');
     139shouldBe('stepDown("-.2", 1, null)', '"-1.2"');
     140shouldBe('stepDown("-1.", 1, null)', '"-2"');
     141shouldBe('stepDown("-2.", 1, null)', '"-3"');
     142
     143// Same as above, but stepping by .1 rather than 1.
     144debug('');
     145shouldBe('stepUp("0.1", .1, null)', '"0.2"');
     146shouldBe('stepUp("0.2", .1, null)', '"0.3"');
     147shouldBe('stepUp("1.0", .1, null)', '"1.1"');
     148shouldBe('stepUp("1.1", .1, null)', '"1.2"');
     149shouldBe('stepUp("1.2", .1, null)', '"1.3"');
     150shouldBe('stepUp("2.0", .1, null)', '"2.1"');
     151
     152debug('');
     153shouldBe('stepUp("-0.1", .1, null)', '"0"');
     154shouldBe('stepUp("-0.2", .1, null)', '"-0.1"');
     155shouldBe('stepUp("-1.0", .1, null)', '"-0.9"');
     156shouldBe('stepUp("-1.1", .1, null)', '"-1"');
     157shouldBe('stepUp("-1.2", .1, null)', '"-1.1"');
     158shouldBe('stepUp("-2.0", .1, null)', '"-1.9"');
     159
     160debug('');
     161shouldBe('stepDown("0.1", .1, null)', '"0"');
     162shouldBe('stepDown("0.2", .1, null)', '"0.1"');
     163shouldBe('stepDown("1.0", .1, null)', '"0.9"');
     164shouldBe('stepDown("1.1", .1, null)', '"1"');
     165shouldBe('stepDown("1.2", .1, null)', '"1.1"');
     166shouldBe('stepDown("2.0", .1, null)', '"1.9"');
     167
     168debug('');
     169shouldBe('stepDown("-0.1", .1, null)', '"-0.2"');
     170shouldBe('stepDown("-0.2", .1, null)', '"-0.3"');
     171shouldBe('stepDown("-1.0", .1, null)', '"-1.1"');
     172shouldBe('stepDown("-1.1", .1, null)', '"-1.2"');
     173shouldBe('stepDown("-1.2", .1, null)', '"-1.3"');
     174shouldBe('stepDown("-2.0", .1, null)', '"-2.1"');
     175
     176debug('');
     177shouldBe('stepUp(".1", .1, null)', '"0.2"');
     178shouldBe('stepUp(".2", .1, null)', '"0.3"');
     179shouldBe('stepUp("1.", .1, null)', '"1.1"');
     180shouldBe('stepUp("2.", .1, null)', '"2.1"');
     181
     182debug('');
     183shouldBe('stepUp("-.1", .1, null)', '"0"');
     184shouldBe('stepUp("-.2", .1, null)', '"-0.1"');
     185shouldBe('stepUp("-1.", .1, null)', '"-0.9"');
     186shouldBe('stepUp("-2.", .1, null)', '"-1.9"');
     187
     188debug('');
     189shouldBe('stepDown(".1", .1, null)', '"0"');
     190shouldBe('stepDown(".2", .1, null)', '"0.1"');
     191shouldBe('stepDown("1.", .1, null)', '"0.9"');
     192shouldBe('stepDown("2.", .1, null)', '"1.9"');
     193
     194debug('');
     195shouldBe('stepDown("-.1", .1, null)', '"-0.2"');
     196shouldBe('stepDown("-.2", .1, null)', '"-0.3"');
     197shouldBe('stepDown("-1.", .1, null)', '"-1.1"');
     198shouldBe('stepDown("-2.", .1, null)', '"-2.1"');
     199
     200debug('');
    75201debug('Extra arguments');
    76202shouldBe('input.value = "0"; input.min = null; input.step = null; input.stepUp(1, 2); input.value', '"1"');
    77203shouldBe('input.value = "1"; input.stepDown(1, 3); input.value', '"0"');
     204
     205debug('');
    78206debug('Invalid step value');
    79207shouldBe('stepUp("0", "foo", null)', '"1"');
    80208shouldBe('stepUp("1", "0", null)', '"2"');
    81209shouldBe('stepUp("2", "-1", null)', '"3"');
     210
     211debug('');
    82212debug('Step=any');
    83213shouldThrow('stepUp("0", "any", null)', invalidStateErr);
    84214shouldThrow('stepDown("0", "any", null)', invalidStateErr);
     215
     216debug('');
    85217debug('Step=any corner case');
    86218shouldThrow('stepUpExplicitBounds("0", "100", "any", "1.5", "1")', invalidStateErr);
    87219shouldThrow('stepDownExplicitBounds("0", "100", "any", "1.5", "1")', invalidStateErr);
     220
     221debug('');
    88222debug('Overflow/underflow');
    89223shouldBe('stepDown("1", "1", "0")', '"0"');
     
    97231shouldBe('input.value', '"-1"');
    98232shouldThrow('stepUp("1", "3.40282346e+38", "", 2)', invalidStateErr);
     233
     234debug('');
    99235debug('stepDown()/stepUp() for stepMismatch values');
    100236shouldBe('stepUp("1", "2", "")', '"3"');
     
    103239shouldBe('stepDown("19", "10", "0")', '"9"');
    104240shouldBe('stepUp("89", "10", "99")', '"99"');
     241
     242debug('');
    105243debug('Huge value and small step');
    106244shouldBe('input.min = ""; stepUp("1e+38", "1", "", 999999)', '"1e+38"');
    107245shouldBe('input.max = ""; stepDown("1e+38", "1", "", 999999)', '"1e+38"');
     246
     247debug('');
    108248debug('Fractional numbers');
    109249shouldBe('input.min = ""; stepUp("0", "0.33333333333333333", "", 3)', '"1"');
     
    112252shouldBe('input.min = "0"; stepUp("0", "0.003921568627450980", "1", 255)', '"1"');
    113253shouldBe('for (var i = 0; i < 255; i++) { input.stepDown(); }; input.value', '"0"');
     254
     255debug('');
    114256debug('Rounding');
    115257shouldBe('stepUp("5.005", "0.005", "", 2)', '"5.015"');
     
    119261shouldBe('stepUpExplicitBounds("4", "9", "0.005", "5.005", 11)', '"5.06"');
    120262shouldBe('stepUpExplicitBounds("4", "9", "0.005", "5.005", 12)', '"5.065"');
     263
     264debug('');
    121265</script>
    122266<script src="../../../resources/js-test-post.js"></script>
  • trunk/LayoutTests/fast/forms/range/range-stepup-stepdown-expected.txt

    r134648 r191940  
    88PASS stepUpExplicitBounds(null, null, null, "") is "51"
    99PASS stepDownExplicitBounds(null, null, null, "") is "49"
     10
    1011Non-number arguments (stepCount)
    1112PASS stepUpExplicitBounds(null, null, null, "0", "0") is "0"
     
    1516PASS stepUpExplicitBounds(null, null, null, "0", null) is "0"
    1617PASS stepDownExplicitBounds(null, null, null, "0", null) is "0"
     18
    1719Normal cases
    1820PASS stepUpExplicitBounds(null, null, null, "0") is "1"
     
    2224PASS stepDownExplicitBounds("-100", null, null, "1", 2) is "-1"
    2325PASS stepDownExplicitBounds("-100", null, null, "-1", -1) is "0"
     26
     27Fractional cases
     28PASS stepUpExplicitBounds(-10, 10, 1, "0.1") is "1"
     29PASS stepUpExplicitBounds(-10, 10, 1, "0.2") is "1"
     30PASS stepUpExplicitBounds(-10, 10, 1, "1.0") is "2"
     31PASS stepUpExplicitBounds(-10, 10, 1, "1.1") is "2"
     32PASS stepUpExplicitBounds(-10, 10, 1, "1.2") is "2"
     33PASS stepUpExplicitBounds(-10, 10, 1, "2.0") is "3"
     34
     35PASS stepUpExplicitBounds(-10, 10, 1, "-0.1") is "1"
     36PASS stepUpExplicitBounds(-10, 10, 1, "-0.2") is "1"
     37PASS stepUpExplicitBounds(-10, 10, 1, "-1.0") is "0"
     38PASS stepUpExplicitBounds(-10, 10, 1, "-1.1") is "0"
     39PASS stepUpExplicitBounds(-10, 10, 1, "-1.2") is "0"
     40PASS stepUpExplicitBounds(-10, 10, 1, "-2.0") is "-1"
     41
     42PASS stepDownExplicitBounds(-10, 10, 1, "0.1") is "-1"
     43PASS stepDownExplicitBounds(-10, 10, 1, "0.2") is "-1"
     44PASS stepDownExplicitBounds(-10, 10, 1, "1.0") is "0"
     45PASS stepDownExplicitBounds(-10, 10, 1, "1.1") is "0"
     46PASS stepDownExplicitBounds(-10, 10, 1, "1.2") is "0"
     47PASS stepDownExplicitBounds(-10, 10, 1, "2.0") is "1"
     48
     49PASS stepDownExplicitBounds(-10, 10, 1, "-0.1") is "-1"
     50PASS stepDownExplicitBounds(-10, 10, 1, "-0.2") is "-1"
     51PASS stepDownExplicitBounds(-10, 10, 1, "-1.0") is "-2"
     52PASS stepDownExplicitBounds(-10, 10, 1, "-1.1") is "-2"
     53PASS stepDownExplicitBounds(-10, 10, 1, "-1.2") is "-2"
     54PASS stepDownExplicitBounds(-10, 10, 1, "-2.0") is "-3"
     55
     56PASS stepUpExplicitBounds(-10, 10, 1, ".1") is "1"
     57PASS stepUpExplicitBounds(-10, 10, 1, ".2") is "1"
     58PASS stepUpExplicitBounds(-10, 10, 1, "1.") is "2"
     59PASS stepUpExplicitBounds(-10, 10, 1, "2.") is "3"
     60
     61PASS stepUpExplicitBounds(-10, 10, 1, "-.1") is "1"
     62PASS stepUpExplicitBounds(-10, 10, 1, "-.2") is "1"
     63PASS stepUpExplicitBounds(-10, 10, 1, "-1.") is "0"
     64PASS stepUpExplicitBounds(-10, 10, 1, "-2.") is "-1"
     65
     66PASS stepDownExplicitBounds(-10, 10, 1, ".1") is "-1"
     67PASS stepDownExplicitBounds(-10, 10, 1, ".2") is "-1"
     68PASS stepDownExplicitBounds(-10, 10, 1, "1.") is "0"
     69PASS stepDownExplicitBounds(-10, 10, 1, "2.") is "1"
     70
     71PASS stepDownExplicitBounds(-10, 10, 1, "-.1") is "-1"
     72PASS stepDownExplicitBounds(-10, 10, 1, "-.2") is "-1"
     73PASS stepDownExplicitBounds(-10, 10, 1, "-1.") is "-2"
     74PASS stepDownExplicitBounds(-10, 10, 1, "-2.") is "-3"
     75
     76PASS stepUpExplicitBounds(-10, 10, .1, "0.1") is "0.2"
     77PASS stepUpExplicitBounds(-10, 10, .1, "0.2") is "0.3"
     78PASS stepUpExplicitBounds(-10, 10, .1, "1.0") is "1.1"
     79PASS stepUpExplicitBounds(-10, 10, .1, "1.1") is "1.2"
     80PASS stepUpExplicitBounds(-10, 10, .1, "1.2") is "1.3"
     81PASS stepUpExplicitBounds(-10, 10, .1, "2.0") is "2.1"
     82
     83PASS stepUpExplicitBounds(-10, 10, .1, "-0.1") is "0"
     84PASS stepUpExplicitBounds(-10, 10, .1, "-0.2") is "-0.1"
     85PASS stepUpExplicitBounds(-10, 10, .1, "-1.0") is "-0.9"
     86PASS stepUpExplicitBounds(-10, 10, .1, "-1.1") is "-1"
     87PASS stepUpExplicitBounds(-10, 10, .1, "-1.2") is "-1.1"
     88PASS stepUpExplicitBounds(-10, 10, .1, "-2.0") is "-1.9"
     89
     90PASS stepDownExplicitBounds(-10, 10, .1, "0.1") is "0"
     91PASS stepDownExplicitBounds(-10, 10, .1, "0.2") is "0.1"
     92PASS stepDownExplicitBounds(-10, 10, .1, "1.0") is "0.9"
     93PASS stepDownExplicitBounds(-10, 10, .1, "1.1") is "1"
     94PASS stepDownExplicitBounds(-10, 10, .1, "1.2") is "1.1"
     95PASS stepDownExplicitBounds(-10, 10, .1, "2.0") is "1.9"
     96
     97PASS stepDownExplicitBounds(-10, 10, .1, "-0.1") is "-0.2"
     98PASS stepDownExplicitBounds(-10, 10, .1, "-0.2") is "-0.3"
     99PASS stepDownExplicitBounds(-10, 10, .1, "-1.0") is "-1.1"
     100PASS stepDownExplicitBounds(-10, 10, .1, "-1.1") is "-1.2"
     101PASS stepDownExplicitBounds(-10, 10, .1, "-1.2") is "-1.3"
     102PASS stepDownExplicitBounds(-10, 10, .1, "-2.0") is "-2.1"
     103
     104PASS stepUpExplicitBounds(-10, 10, .1, ".1") is "0.2"
     105PASS stepUpExplicitBounds(-10, 10, .1, ".2") is "0.3"
     106PASS stepUpExplicitBounds(-10, 10, .1, "1.") is "1.1"
     107PASS stepUpExplicitBounds(-10, 10, .1, "2.") is "2.1"
     108
     109PASS stepUpExplicitBounds(-10, 10, .1, "-.1") is "0"
     110PASS stepUpExplicitBounds(-10, 10, .1, "-.2") is "-0.1"
     111PASS stepUpExplicitBounds(-10, 10, .1, "-1.") is "-0.9"
     112PASS stepUpExplicitBounds(-10, 10, .1, "-2.") is "-1.9"
     113
     114PASS stepDownExplicitBounds(-10, 10, .1, ".1") is "0"
     115PASS stepDownExplicitBounds(-10, 10, .1, ".2") is "0.1"
     116PASS stepDownExplicitBounds(-10, 10, .1, "1.") is "0.9"
     117PASS stepDownExplicitBounds(-10, 10, .1, "2.") is "1.9"
     118
     119PASS stepDownExplicitBounds(-10, 10, .1, "-.1") is "-0.2"
     120PASS stepDownExplicitBounds(-10, 10, .1, "-.2") is "-0.3"
     121PASS stepDownExplicitBounds(-10, 10, .1, "-1.") is "-1.1"
     122PASS stepDownExplicitBounds(-10, 10, .1, "-2.") is "-2.1"
     123
    24124Extra arguments
    25125PASS setInputAttributes(null, null, null, "0"); input.stepUp(1,2); input.value is "1"
    26126PASS setInputAttributes(null, null, null, "1"); input.stepDown(1,3); input.value is "0"
     127
    27128Invalid step value
    28129PASS stepUpExplicitBounds(null, null, "foo", "0") is "1"
     
    32133PASS stepDownExplicitBounds(null, null, "0", "2") is "1"
    33134PASS stepDownExplicitBounds(null, null, "-1", "3") is "2"
     135
    34136Step=any
    35137PASS stepUpExplicitBounds(null, null, "any", "1") threw exception Error: InvalidStateError: DOM Exception 11.
    36138PASS stepDownExplicitBounds(null, null, "any", "1") threw exception Error: InvalidStateError: DOM Exception 11.
     139
    37140Overflow/underflow
    38141PASS stepUpExplicitBounds(null, "100", "1", "99") is "100"
     
    52155PASS input.value is "-1"
    53156PASS stepUpExplicitBounds(null, null, "3.40282346e+38", "1", "2") threw exception Error: InvalidStateError: DOM Exception 11.
     157
    54158stepDown()/stepUp() for stepMismatch values
    55159PASS stepUpExplicitBounds(null, null, 2, 1) is "4"
     
    57161PASS stepUpExplicitBounds(0, null, 10, 9, 9) is "100"
    58162PASS stepDownExplicitBounds(0, null, 10, 19) is "10"
     163
    59164value + step is <= max, but rounded result would be > max.
    60165PASS stepUpExplicitBounds(null, 99, 10, 89) threw exception Error: InvalidStateError: DOM Exception 11.
     166
    61167Huge value and small step
    62168PASS stepUpExplicitBounds(0, 1e38, 1, 1e38, 999999) is "1e+38"
    63169PASS stepDownExplicitBounds(0, 1e38, 1, 1e38, 999999) is "1e+38"
     170
    64171Fractional numbers
    65172PASS stepUpExplicitBounds(null, null, 0.33333333333333333, 0, 3) is "1"
     
    72179PASS stepDownExplicitBounds(null, null, 0.1, 1, 8) is "0.2"
    73180PASS stepDownExplicitBounds(null, null, 0.1, 1) is "0.9"
     181
    74182PASS successfullyParsed is true
    75183
  • trunk/LayoutTests/fast/forms/range/range-stepup-stepdown-from-renderer-expected.txt

    r93593 r191940  
    1818PASS stepUpExplicitBounds(null, null, "foo", "foo") is "51"
    1919PASS stepDownExplicitBounds(null, null, "foo", "foo") is "49"
     20
    2021Normal cases
    2122PASS stepUpExplicitBounds(null, null, null, "0") is "1"
     
    2526PASS stepDownExplicitBounds("-100", null, null, "1", 2) is "-1"
    2627PASS stepDownExplicitBounds("-100", null, null, "-1", -1) is "0"
     28
     29Fractional cases
     30PASS stepUpExplicitBounds(-10, 10, 1, "0.1") is "1"
     31PASS stepUpExplicitBounds(-10, 10, 1, "0.2") is "1"
     32PASS stepUpExplicitBounds(-10, 10, 1, "1.0") is "2"
     33PASS stepUpExplicitBounds(-10, 10, 1, "1.1") is "2"
     34PASS stepUpExplicitBounds(-10, 10, 1, "1.2") is "2"
     35PASS stepUpExplicitBounds(-10, 10, 1, "2.0") is "3"
     36
     37PASS stepUpExplicitBounds(-10, 10, 1, "-0.1") is "1"
     38PASS stepUpExplicitBounds(-10, 10, 1, "-0.2") is "1"
     39PASS stepUpExplicitBounds(-10, 10, 1, "-1.0") is "0"
     40PASS stepUpExplicitBounds(-10, 10, 1, "-1.1") is "0"
     41PASS stepUpExplicitBounds(-10, 10, 1, "-1.2") is "0"
     42PASS stepUpExplicitBounds(-10, 10, 1, "-2.0") is "-1"
     43
     44PASS stepDownExplicitBounds(-10, 10, 1, "0.1") is "-1"
     45PASS stepDownExplicitBounds(-10, 10, 1, "0.2") is "-1"
     46PASS stepDownExplicitBounds(-10, 10, 1, "1.0") is "0"
     47PASS stepDownExplicitBounds(-10, 10, 1, "1.1") is "0"
     48PASS stepDownExplicitBounds(-10, 10, 1, "1.2") is "0"
     49PASS stepDownExplicitBounds(-10, 10, 1, "2.0") is "1"
     50
     51PASS stepDownExplicitBounds(-10, 10, 1, "-0.1") is "-1"
     52PASS stepDownExplicitBounds(-10, 10, 1, "-0.2") is "-1"
     53PASS stepDownExplicitBounds(-10, 10, 1, "-1.0") is "-2"
     54PASS stepDownExplicitBounds(-10, 10, 1, "-1.1") is "-2"
     55PASS stepDownExplicitBounds(-10, 10, 1, "-1.2") is "-2"
     56PASS stepDownExplicitBounds(-10, 10, 1, "-2.0") is "-3"
     57
     58PASS stepUpExplicitBounds(-10, 10, 1, ".1") is "1"
     59PASS stepUpExplicitBounds(-10, 10, 1, ".2") is "1"
     60PASS stepUpExplicitBounds(-10, 10, 1, "1.") is "2"
     61PASS stepUpExplicitBounds(-10, 10, 1, "2.") is "3"
     62
     63PASS stepUpExplicitBounds(-10, 10, 1, "-.1") is "1"
     64PASS stepUpExplicitBounds(-10, 10, 1, "-.2") is "1"
     65PASS stepUpExplicitBounds(-10, 10, 1, "-1.") is "0"
     66PASS stepUpExplicitBounds(-10, 10, 1, "-2.") is "-1"
     67
     68PASS stepDownExplicitBounds(-10, 10, 1, ".1") is "-1"
     69PASS stepDownExplicitBounds(-10, 10, 1, ".2") is "-1"
     70PASS stepDownExplicitBounds(-10, 10, 1, "1.") is "0"
     71PASS stepDownExplicitBounds(-10, 10, 1, "2.") is "1"
     72
     73PASS stepDownExplicitBounds(-10, 10, 1, "-.1") is "-1"
     74PASS stepDownExplicitBounds(-10, 10, 1, "-.2") is "-1"
     75PASS stepDownExplicitBounds(-10, 10, 1, "-1.") is "-2"
     76PASS stepDownExplicitBounds(-10, 10, 1, "-2.") is "-3"
     77
     78PASS stepUpExplicitBounds(-10, 10, .1, "0.1") is "0.2"
     79PASS stepUpExplicitBounds(-10, 10, .1, "0.2") is "0.3"
     80PASS stepUpExplicitBounds(-10, 10, .1, "1.0") is "1.1"
     81PASS stepUpExplicitBounds(-10, 10, .1, "1.1") is "1.2"
     82PASS stepUpExplicitBounds(-10, 10, .1, "1.2") is "1.3"
     83PASS stepUpExplicitBounds(-10, 10, .1, "2.0") is "2.1"
     84
     85PASS stepUpExplicitBounds(-10, 10, .1, "-0.1") is "0"
     86PASS stepUpExplicitBounds(-10, 10, .1, "-0.2") is "-0.1"
     87PASS stepUpExplicitBounds(-10, 10, .1, "-1.0") is "-0.9"
     88PASS stepUpExplicitBounds(-10, 10, .1, "-1.1") is "-1"
     89PASS stepUpExplicitBounds(-10, 10, .1, "-1.2") is "-1.1"
     90PASS stepUpExplicitBounds(-10, 10, .1, "-2.0") is "-1.9"
     91
     92PASS stepDownExplicitBounds(-10, 10, .1, "0.1") is "0"
     93PASS stepDownExplicitBounds(-10, 10, .1, "0.2") is "0.1"
     94PASS stepDownExplicitBounds(-10, 10, .1, "1.0") is "0.9"
     95PASS stepDownExplicitBounds(-10, 10, .1, "1.1") is "1"
     96PASS stepDownExplicitBounds(-10, 10, .1, "1.2") is "1.1"
     97PASS stepDownExplicitBounds(-10, 10, .1, "2.0") is "1.9"
     98
     99PASS stepDownExplicitBounds(-10, 10, .1, "-0.1") is "-0.2"
     100PASS stepDownExplicitBounds(-10, 10, .1, "-0.2") is "-0.3"
     101PASS stepDownExplicitBounds(-10, 10, .1, "-1.0") is "-1.1"
     102PASS stepDownExplicitBounds(-10, 10, .1, "-1.1") is "-1.2"
     103PASS stepDownExplicitBounds(-10, 10, .1, "-1.2") is "-1.3"
     104PASS stepDownExplicitBounds(-10, 10, .1, "-2.0") is "-2.1"
     105
     106PASS stepUpExplicitBounds(-10, 10, .1, ".1") is "0.2"
     107PASS stepUpExplicitBounds(-10, 10, .1, ".2") is "0.3"
     108PASS stepUpExplicitBounds(-10, 10, .1, "1.") is "1.1"
     109PASS stepUpExplicitBounds(-10, 10, .1, "2.") is "2.1"
     110
     111PASS stepUpExplicitBounds(-10, 10, .1, "-.1") is "0"
     112PASS stepUpExplicitBounds(-10, 10, .1, "-.2") is "-0.1"
     113PASS stepUpExplicitBounds(-10, 10, .1, "-1.") is "-0.9"
     114PASS stepUpExplicitBounds(-10, 10, .1, "-2.") is "-1.9"
     115PASS stepDownExplicitBounds(-10, 10, .1, ".1") is "0"
     116PASS stepDownExplicitBounds(-10, 10, .1, ".2") is "0.1"
     117PASS stepDownExplicitBounds(-10, 10, .1, "1.") is "0.9"
     118PASS stepDownExplicitBounds(-10, 10, .1, "2.") is "1.9"
     119
     120PASS stepDownExplicitBounds(-10, 10, .1, "-.1") is "-0.2"
     121PASS stepDownExplicitBounds(-10, 10, .1, "-.2") is "-0.3"
     122PASS stepDownExplicitBounds(-10, 10, .1, "-1.") is "-1.1"
     123PASS stepDownExplicitBounds(-10, 10, .1, "-2.") is "-2.1"
     124
    27125Invalid step value
    28126PASS stepUpExplicitBounds(null, null, "foo", "0") is "1"
     
    32130PASS stepDownExplicitBounds(null, null, "0", "2") is "1"
    33131PASS stepDownExplicitBounds(null, null, "-1", "3") is "2"
     132
    34133Step=any
    35134PASS stepUpExplicitBounds(null, null, "any", "1") is "2"
    36135PASS stepDownExplicitBounds(null, null, "any", "1") is "0"
     136
    37137Overflow/underflow
    38138PASS stepUpExplicitBounds(null, "100", "1", "99") is "100"
     
    47147PASS stepUpExplicitBounds(-100, 0, 1, -1, 2) is "0"
    48148PASS stepUpExplicitBounds(null, null, "3.40282346e+38", "1", 2) is "0"
     149
    49150stepDown()/stepUp() for stepMismatch values
    50151PASS stepUpExplicitBounds(null, null, 2, 1) is "4"
    51152PASS stepUpExplicitBounds(0, null, 10, 9, 9) is "100"
    52153PASS stepDownExplicitBounds(0, null, 10, 19) is "10"
     154
    53155value + step is <= max, but rounded result would be > max.
    54156PASS stepUpExplicitBounds(null, 99, 10, 89) is "90"
     157
    55158Huge value and small step
    56159PASS stepUpExplicitBounds(0, 1e38, 1, 1e38, 999) is "1e+38"
    57160PASS stepDownExplicitBounds(0, 1e38, 1, 1e38, 999) is "1e+38"
     161
    58162Fractional numbers
    59163PASS stepUpExplicitBounds(null, null, 0.33333333333333333, 0, 3) is "1"
  • trunk/LayoutTests/fast/forms/range/range-stepup-stepdown-from-renderer.html

    r155268 r191940  
    102102shouldBe('stepUpExplicitBounds(null, null, "foo", "foo")', '"51"');
    103103shouldBe('stepDownExplicitBounds(null, null, "foo", "foo")', '"49"');
     104
     105debug('');
    104106debug('Normal cases');
    105107shouldBe('stepUpExplicitBounds(null, null, null, "0")', '"1"');
     
    109111shouldBe('stepDownExplicitBounds("-100", null, null, "1", 2)', '"-1"');
    110112shouldBe('stepDownExplicitBounds("-100", null, null, "-1", -1)', '"0"');
     113
     114
     115debug('');
     116debug('Fractional cases')
     117// "When the element is suffering from a step mismatch, the user agent must
     118// round the element's value to the nearest number for which the element would
     119// not suffer from a step mismatch, and which is greater than or equal to the
     120// minimum, and, if the maximum is not less than the minimum, which is less
     121// than or equal to the maximum, if there is a number that matches these
     122// constraints. If two numbers match these constraints, then user agents must
     123// use the one nearest to positive infinity.""
     124
     125// Base/model/template tests
     126shouldBe('stepUpExplicitBounds(-10, 10, 1, "0.1")', '"1"');
     127shouldBe('stepUpExplicitBounds(-10, 10, 1, "0.2")', '"1"');
     128shouldBe('stepUpExplicitBounds(-10, 10, 1, "1.0")', '"2"');
     129shouldBe('stepUpExplicitBounds(-10, 10, 1, "1.1")', '"2"');
     130shouldBe('stepUpExplicitBounds(-10, 10, 1, "1.2")', '"2"');
     131shouldBe('stepUpExplicitBounds(-10, 10, 1, "2.0")', '"3"');
     132
     133// Same as above, but with negative numbers.
     134debug('');
     135shouldBe('stepUpExplicitBounds(-10, 10, 1, "-0.1")', '"1"');
     136shouldBe('stepUpExplicitBounds(-10, 10, 1, "-0.2")', '"1"');
     137shouldBe('stepUpExplicitBounds(-10, 10, 1, "-1.0")', '"0"');
     138shouldBe('stepUpExplicitBounds(-10, 10, 1, "-1.1")', '"0"');
     139shouldBe('stepUpExplicitBounds(-10, 10, 1, "-1.2")', '"0"');
     140shouldBe('stepUpExplicitBounds(-10, 10, 1, "-2.0")', '"-1"');
     141
     142// Same as above, but stepping down rather than up.
     143debug('');
     144shouldBe('stepDownExplicitBounds(-10, 10, 1, "0.1")', '"-1"');
     145shouldBe('stepDownExplicitBounds(-10, 10, 1, "0.2")', '"-1"');
     146shouldBe('stepDownExplicitBounds(-10, 10, 1, "1.0")', '"0"');
     147shouldBe('stepDownExplicitBounds(-10, 10, 1, "1.1")', '"0"');
     148shouldBe('stepDownExplicitBounds(-10, 10, 1, "1.2")', '"0"');
     149shouldBe('stepDownExplicitBounds(-10, 10, 1, "2.0")', '"1"');
     150
     151debug('');
     152shouldBe('stepDownExplicitBounds(-10, 10, 1, "-0.1")', '"-1"');
     153shouldBe('stepDownExplicitBounds(-10, 10, 1, "-0.2")', '"-1"');
     154shouldBe('stepDownExplicitBounds(-10, 10, 1, "-1.0")', '"-2"');
     155shouldBe('stepDownExplicitBounds(-10, 10, 1, "-1.1")', '"-2"');
     156shouldBe('stepDownExplicitBounds(-10, 10, 1, "-1.2")', '"-2"');
     157shouldBe('stepDownExplicitBounds(-10, 10, 1, "-2.0")', '"-3"');
     158
     159// Same as above, but with leading/trailing zeros removed.
     160debug('');
     161shouldBe('stepUpExplicitBounds(-10, 10, 1, ".1")', '"1"');
     162shouldBe('stepUpExplicitBounds(-10, 10, 1, ".2")', '"1"');
     163shouldBe('stepUpExplicitBounds(-10, 10, 1, "1.")', '"2"');
     164shouldBe('stepUpExplicitBounds(-10, 10, 1, "2.")', '"3"');
     165
     166debug('');
     167shouldBe('stepUpExplicitBounds(-10, 10, 1, "-.1")', '"1"');
     168shouldBe('stepUpExplicitBounds(-10, 10, 1, "-.2")', '"1"');
     169shouldBe('stepUpExplicitBounds(-10, 10, 1, "-1.")', '"0"');
     170shouldBe('stepUpExplicitBounds(-10, 10, 1, "-2.")', '"-1"');
     171
     172debug('');
     173shouldBe('stepDownExplicitBounds(-10, 10, 1, ".1")', '"-1"');
     174shouldBe('stepDownExplicitBounds(-10, 10, 1, ".2")', '"-1"');
     175shouldBe('stepDownExplicitBounds(-10, 10, 1, "1.")', '"0"');
     176shouldBe('stepDownExplicitBounds(-10, 10, 1, "2.")', '"1"');
     177
     178debug('');
     179shouldBe('stepDownExplicitBounds(-10, 10, 1, "-.1")', '"-1"');
     180shouldBe('stepDownExplicitBounds(-10, 10, 1, "-.2")', '"-1"');
     181shouldBe('stepDownExplicitBounds(-10, 10, 1, "-1.")', '"-2"');
     182shouldBe('stepDownExplicitBounds(-10, 10, 1, "-2.")', '"-3"');
     183
     184// Same as above, but stepping by .1 rather than 1.
     185debug('');
     186shouldBe('stepUpExplicitBounds(-10, 10, .1, "0.1")', '"0.2"');
     187shouldBe('stepUpExplicitBounds(-10, 10, .1, "0.2")', '"0.3"');
     188shouldBe('stepUpExplicitBounds(-10, 10, .1, "1.0")', '"1.1"');
     189shouldBe('stepUpExplicitBounds(-10, 10, .1, "1.1")', '"1.2"');
     190shouldBe('stepUpExplicitBounds(-10, 10, .1, "1.2")', '"1.3"');
     191shouldBe('stepUpExplicitBounds(-10, 10, .1, "2.0")', '"2.1"');
     192
     193debug('');
     194shouldBe('stepUpExplicitBounds(-10, 10, .1, "-0.1")', '"0"');
     195shouldBe('stepUpExplicitBounds(-10, 10, .1, "-0.2")', '"-0.1"');
     196shouldBe('stepUpExplicitBounds(-10, 10, .1, "-1.0")', '"-0.9"');
     197shouldBe('stepUpExplicitBounds(-10, 10, .1, "-1.1")', '"-1"');
     198shouldBe('stepUpExplicitBounds(-10, 10, .1, "-1.2")', '"-1.1"');
     199shouldBe('stepUpExplicitBounds(-10, 10, .1, "-2.0")', '"-1.9"');
     200
     201debug('');
     202shouldBe('stepDownExplicitBounds(-10, 10, .1, "0.1")', '"0"');
     203shouldBe('stepDownExplicitBounds(-10, 10, .1, "0.2")', '"0.1"');
     204shouldBe('stepDownExplicitBounds(-10, 10, .1, "1.0")', '"0.9"');
     205shouldBe('stepDownExplicitBounds(-10, 10, .1, "1.1")', '"1"');
     206shouldBe('stepDownExplicitBounds(-10, 10, .1, "1.2")', '"1.1"');
     207shouldBe('stepDownExplicitBounds(-10, 10, .1, "2.0")', '"1.9"');
     208
     209debug('');
     210shouldBe('stepDownExplicitBounds(-10, 10, .1, "-0.1")', '"-0.2"');
     211shouldBe('stepDownExplicitBounds(-10, 10, .1, "-0.2")', '"-0.3"');
     212shouldBe('stepDownExplicitBounds(-10, 10, .1, "-1.0")', '"-1.1"');
     213shouldBe('stepDownExplicitBounds(-10, 10, .1, "-1.1")', '"-1.2"');
     214shouldBe('stepDownExplicitBounds(-10, 10, .1, "-1.2")', '"-1.3"');
     215shouldBe('stepDownExplicitBounds(-10, 10, .1, "-2.0")', '"-2.1"');
     216
     217debug('');
     218shouldBe('stepUpExplicitBounds(-10, 10, .1, ".1")', '"0.2"');
     219shouldBe('stepUpExplicitBounds(-10, 10, .1, ".2")', '"0.3"');
     220shouldBe('stepUpExplicitBounds(-10, 10, .1, "1.")', '"1.1"');
     221shouldBe('stepUpExplicitBounds(-10, 10, .1, "2.")', '"2.1"');
     222
     223debug('');
     224shouldBe('stepUpExplicitBounds(-10, 10, .1, "-.1")', '"0"');
     225shouldBe('stepUpExplicitBounds(-10, 10, .1, "-.2")', '"-0.1"');
     226shouldBe('stepUpExplicitBounds(-10, 10, .1, "-1.")', '"-0.9"');
     227shouldBe('stepUpExplicitBounds(-10, 10, .1, "-2.")', '"-1.9"');
     228
     229shouldBe('stepDownExplicitBounds(-10, 10, .1, ".1")', '"0"');
     230shouldBe('stepDownExplicitBounds(-10, 10, .1, ".2")', '"0.1"');
     231shouldBe('stepDownExplicitBounds(-10, 10, .1, "1.")', '"0.9"');
     232shouldBe('stepDownExplicitBounds(-10, 10, .1, "2.")', '"1.9"');
     233
     234debug('');
     235shouldBe('stepDownExplicitBounds(-10, 10, .1, "-.1")', '"-0.2"');
     236shouldBe('stepDownExplicitBounds(-10, 10, .1, "-.2")', '"-0.3"');
     237shouldBe('stepDownExplicitBounds(-10, 10, .1, "-1.")', '"-1.1"');
     238shouldBe('stepDownExplicitBounds(-10, 10, .1, "-2.")', '"-2.1"');
     239
     240debug('');
    111241debug('Invalid step value');
    112242shouldBe('stepUpExplicitBounds(null, null, "foo", "0")', '"1"');
     
    116246shouldBe('stepDownExplicitBounds(null, null, "0", "2")', '"1"');
    117247shouldBe('stepDownExplicitBounds(null, null, "-1", "3")', '"2"');
     248
     249debug('');
    118250debug('Step=any');
    119251shouldBe('stepUpExplicitBounds(null, null, "any", "1")', '"2"');
    120252shouldBe('stepDownExplicitBounds(null, null, "any", "1")', '"0"');
     253
     254debug('');
    121255debug('Overflow/underflow');
    122256shouldBe('stepUpExplicitBounds(null, "100", "1", "99")', '"100"');
     
    131265shouldBe('stepUpExplicitBounds(-100, 0, 1, -1, 2)', '"0"');
    132266shouldBe('stepUpExplicitBounds(null, null, "3.40282346e+38", "1", 2)', '"0"');
     267
     268debug('');
    133269debug('stepDown()/stepUp() for stepMismatch values');
    134270shouldBe('stepUpExplicitBounds(null, null, 2, 1)', '"4"');
    135271shouldBe('stepUpExplicitBounds(0, null, 10, 9, 9)', '"100"');
    136272shouldBe('stepDownExplicitBounds(0, null, 10, 19)', '"10"');
     273
     274debug('');
    137275debug('value + step is <= max, but rounded result would be > max.');
    138276shouldBe('stepUpExplicitBounds(null, 99, 10, 89)', '"90"');
     277
     278debug('');
    139279debug('Huge value and small step');
    140280shouldBe('stepUpExplicitBounds(0, 1e38, 1, 1e38, 999)', '"1e+38"');
    141281shouldBe('stepDownExplicitBounds(0, 1e38, 1, 1e38, 999)', '"1e+38"');
     282
     283debug('');
    142284debug('Fractional numbers');
    143285shouldBe('stepUpExplicitBounds(null, null, 0.33333333333333333, 0, 3)', '"1"');
  • trunk/LayoutTests/fast/forms/range/range-stepup-stepdown.html

    r155268 r191940  
    6464shouldBe('stepUpExplicitBounds(null, null, null, "")', '"51"');
    6565shouldBe('stepDownExplicitBounds(null, null, null, "")', '"49"');
     66
     67debug('');
    6668debug('Non-number arguments (stepCount)');
    6769shouldBe('stepUpExplicitBounds(null, null, null, "0", "0")', '"0"');
     
    7173shouldBe('stepUpExplicitBounds(null, null, null, "0", null)', '"0"');
    7274shouldBe('stepDownExplicitBounds(null, null, null, "0", null)', '"0"');
     75
     76debug('');
    7377debug('Normal cases');
    7478shouldBe('stepUpExplicitBounds(null, null, null, "0")', '"1"');
     
    7882shouldBe('stepDownExplicitBounds("-100", null, null, "1", 2)', '"-1"');
    7983shouldBe('stepDownExplicitBounds("-100", null, null, "-1", -1)', '"0"');
     84
     85debug('');
     86debug('Fractional cases')
     87// "When the element is suffering from a step mismatch, the user agent must
     88// round the element's value to the nearest number for which the element would
     89// not suffer from a step mismatch, and which is greater than or equal to the
     90// minimum, and, if the maximum is not less than the minimum, which is less
     91// than or equal to the maximum, if there is a number that matches these
     92// constraints. If two numbers match these constraints, then user agents must
     93// use the one nearest to positive infinity.""
     94
     95// Base/model/template tests
     96shouldBe('stepUpExplicitBounds(-10, 10, 1, "0.1")', '"1"');
     97shouldBe('stepUpExplicitBounds(-10, 10, 1, "0.2")', '"1"');
     98shouldBe('stepUpExplicitBounds(-10, 10, 1, "1.0")', '"2"');
     99shouldBe('stepUpExplicitBounds(-10, 10, 1, "1.1")', '"2"');
     100shouldBe('stepUpExplicitBounds(-10, 10, 1, "1.2")', '"2"');
     101shouldBe('stepUpExplicitBounds(-10, 10, 1, "2.0")', '"3"');
     102
     103// Same as above, but with negative numbers.
     104debug('');
     105shouldBe('stepUpExplicitBounds(-10, 10, 1, "-0.1")', '"1"');
     106shouldBe('stepUpExplicitBounds(-10, 10, 1, "-0.2")', '"1"');
     107shouldBe('stepUpExplicitBounds(-10, 10, 1, "-1.0")', '"0"');
     108shouldBe('stepUpExplicitBounds(-10, 10, 1, "-1.1")', '"0"');
     109shouldBe('stepUpExplicitBounds(-10, 10, 1, "-1.2")', '"0"');
     110shouldBe('stepUpExplicitBounds(-10, 10, 1, "-2.0")', '"-1"');
     111
     112// Same as above, but stepping down rather than up.
     113debug('');
     114shouldBe('stepDownExplicitBounds(-10, 10, 1, "0.1")', '"-1"');
     115shouldBe('stepDownExplicitBounds(-10, 10, 1, "0.2")', '"-1"');
     116shouldBe('stepDownExplicitBounds(-10, 10, 1, "1.0")', '"0"');
     117shouldBe('stepDownExplicitBounds(-10, 10, 1, "1.1")', '"0"');
     118shouldBe('stepDownExplicitBounds(-10, 10, 1, "1.2")', '"0"');
     119shouldBe('stepDownExplicitBounds(-10, 10, 1, "2.0")', '"1"');
     120
     121debug('');
     122shouldBe('stepDownExplicitBounds(-10, 10, 1, "-0.1")', '"-1"');
     123shouldBe('stepDownExplicitBounds(-10, 10, 1, "-0.2")', '"-1"');
     124shouldBe('stepDownExplicitBounds(-10, 10, 1, "-1.0")', '"-2"');
     125shouldBe('stepDownExplicitBounds(-10, 10, 1, "-1.1")', '"-2"');
     126shouldBe('stepDownExplicitBounds(-10, 10, 1, "-1.2")', '"-2"');
     127shouldBe('stepDownExplicitBounds(-10, 10, 1, "-2.0")', '"-3"');
     128
     129// Same as above, but with leading/trailing zeros removed.
     130debug('');
     131shouldBe('stepUpExplicitBounds(-10, 10, 1, ".1")', '"1"');
     132shouldBe('stepUpExplicitBounds(-10, 10, 1, ".2")', '"1"');
     133shouldBe('stepUpExplicitBounds(-10, 10, 1, "1.")', '"2"');
     134shouldBe('stepUpExplicitBounds(-10, 10, 1, "2.")', '"3"');
     135
     136debug('');
     137shouldBe('stepUpExplicitBounds(-10, 10, 1, "-.1")', '"1"');
     138shouldBe('stepUpExplicitBounds(-10, 10, 1, "-.2")', '"1"');
     139shouldBe('stepUpExplicitBounds(-10, 10, 1, "-1.")', '"0"');
     140shouldBe('stepUpExplicitBounds(-10, 10, 1, "-2.")', '"-1"');
     141
     142debug('');
     143shouldBe('stepDownExplicitBounds(-10, 10, 1, ".1")', '"-1"');
     144shouldBe('stepDownExplicitBounds(-10, 10, 1, ".2")', '"-1"');
     145shouldBe('stepDownExplicitBounds(-10, 10, 1, "1.")', '"0"');
     146shouldBe('stepDownExplicitBounds(-10, 10, 1, "2.")', '"1"');
     147
     148debug('');
     149shouldBe('stepDownExplicitBounds(-10, 10, 1, "-.1")', '"-1"');
     150shouldBe('stepDownExplicitBounds(-10, 10, 1, "-.2")', '"-1"');
     151shouldBe('stepDownExplicitBounds(-10, 10, 1, "-1.")', '"-2"');
     152shouldBe('stepDownExplicitBounds(-10, 10, 1, "-2.")', '"-3"');
     153
     154// Same as above, but stepping by .1 rather than 1.
     155debug('');
     156shouldBe('stepUpExplicitBounds(-10, 10, .1, "0.1")', '"0.2"');
     157shouldBe('stepUpExplicitBounds(-10, 10, .1, "0.2")', '"0.3"');
     158shouldBe('stepUpExplicitBounds(-10, 10, .1, "1.0")', '"1.1"');
     159shouldBe('stepUpExplicitBounds(-10, 10, .1, "1.1")', '"1.2"');
     160shouldBe('stepUpExplicitBounds(-10, 10, .1, "1.2")', '"1.3"');
     161shouldBe('stepUpExplicitBounds(-10, 10, .1, "2.0")', '"2.1"');
     162
     163debug('');
     164shouldBe('stepUpExplicitBounds(-10, 10, .1, "-0.1")', '"0"');
     165shouldBe('stepUpExplicitBounds(-10, 10, .1, "-0.2")', '"-0.1"');
     166shouldBe('stepUpExplicitBounds(-10, 10, .1, "-1.0")', '"-0.9"');
     167shouldBe('stepUpExplicitBounds(-10, 10, .1, "-1.1")', '"-1"');
     168shouldBe('stepUpExplicitBounds(-10, 10, .1, "-1.2")', '"-1.1"');
     169shouldBe('stepUpExplicitBounds(-10, 10, .1, "-2.0")', '"-1.9"');
     170
     171debug('');
     172shouldBe('stepDownExplicitBounds(-10, 10, .1, "0.1")', '"0"');
     173shouldBe('stepDownExplicitBounds(-10, 10, .1, "0.2")', '"0.1"');
     174shouldBe('stepDownExplicitBounds(-10, 10, .1, "1.0")', '"0.9"');
     175shouldBe('stepDownExplicitBounds(-10, 10, .1, "1.1")', '"1"');
     176shouldBe('stepDownExplicitBounds(-10, 10, .1, "1.2")', '"1.1"');
     177shouldBe('stepDownExplicitBounds(-10, 10, .1, "2.0")', '"1.9"');
     178
     179debug('');
     180shouldBe('stepDownExplicitBounds(-10, 10, .1, "-0.1")', '"-0.2"');
     181shouldBe('stepDownExplicitBounds(-10, 10, .1, "-0.2")', '"-0.3"');
     182shouldBe('stepDownExplicitBounds(-10, 10, .1, "-1.0")', '"-1.1"');
     183shouldBe('stepDownExplicitBounds(-10, 10, .1, "-1.1")', '"-1.2"');
     184shouldBe('stepDownExplicitBounds(-10, 10, .1, "-1.2")', '"-1.3"');
     185shouldBe('stepDownExplicitBounds(-10, 10, .1, "-2.0")', '"-2.1"');
     186
     187debug('');
     188shouldBe('stepUpExplicitBounds(-10, 10, .1, ".1")', '"0.2"');
     189shouldBe('stepUpExplicitBounds(-10, 10, .1, ".2")', '"0.3"');
     190shouldBe('stepUpExplicitBounds(-10, 10, .1, "1.")', '"1.1"');
     191shouldBe('stepUpExplicitBounds(-10, 10, .1, "2.")', '"2.1"');
     192
     193debug('');
     194shouldBe('stepUpExplicitBounds(-10, 10, .1, "-.1")', '"0"');
     195shouldBe('stepUpExplicitBounds(-10, 10, .1, "-.2")', '"-0.1"');
     196shouldBe('stepUpExplicitBounds(-10, 10, .1, "-1.")', '"-0.9"');
     197shouldBe('stepUpExplicitBounds(-10, 10, .1, "-2.")', '"-1.9"');
     198
     199debug('');
     200shouldBe('stepDownExplicitBounds(-10, 10, .1, ".1")', '"0"');
     201shouldBe('stepDownExplicitBounds(-10, 10, .1, ".2")', '"0.1"');
     202shouldBe('stepDownExplicitBounds(-10, 10, .1, "1.")', '"0.9"');
     203shouldBe('stepDownExplicitBounds(-10, 10, .1, "2.")', '"1.9"');
     204
     205debug('');
     206shouldBe('stepDownExplicitBounds(-10, 10, .1, "-.1")', '"-0.2"');
     207shouldBe('stepDownExplicitBounds(-10, 10, .1, "-.2")', '"-0.3"');
     208shouldBe('stepDownExplicitBounds(-10, 10, .1, "-1.")', '"-1.1"');
     209shouldBe('stepDownExplicitBounds(-10, 10, .1, "-2.")', '"-2.1"');
     210
     211debug('');
    80212debug('Extra arguments');
    81213shouldBe('setInputAttributes(null, null, null, "0"); input.stepUp(1,2); input.value', '"1"');
    82214shouldBe('setInputAttributes(null, null, null, "1"); input.stepDown(1,3); input.value', '"0"');
     215
     216debug('');
    83217debug('Invalid step value');
    84218shouldBe('stepUpExplicitBounds(null, null, "foo", "0")', '"1"');
     
    88222shouldBe('stepDownExplicitBounds(null, null, "0", "2")', '"1"');
    89223shouldBe('stepDownExplicitBounds(null, null, "-1", "3")', '"2"');
     224
     225debug('');
    90226debug('Step=any');
    91227shouldThrow('stepUpExplicitBounds(null, null, "any", "1")', invalidStateErr);
    92228shouldThrow('stepDownExplicitBounds(null, null, "any", "1")', invalidStateErr);
     229
     230debug('');
    93231debug('Overflow/underflow');
    94232shouldBe('stepUpExplicitBounds(null, "100", "1", "99")', '"100"');
     
    108246shouldBe('input.value', '"-1"');
    109247shouldThrow('stepUpExplicitBounds(null, null, "3.40282346e+38", "1", "2")', invalidStateErr);
     248
     249debug('');
    110250debug('stepDown()/stepUp() for stepMismatch values');
    111251shouldBe('stepUpExplicitBounds(null, null, 2, 1)', '"4"');
     
    113253shouldBe('stepUpExplicitBounds(0, null, 10, 9, 9)', '"100"');
    114254shouldBe('stepDownExplicitBounds(0, null, 10, 19)', '"10"');
     255
     256debug('');
    115257debug('value + step is <= max, but rounded result would be > max.');
    116258shouldThrow('stepUpExplicitBounds(null, 99, 10, 89)', invalidStateErr);
     259
     260debug('');
    117261debug('Huge value and small step');
    118262shouldBe('stepUpExplicitBounds(0, 1e38, 1, 1e38, 999999)', '"1e+38"');
    119263shouldBe('stepDownExplicitBounds(0, 1e38, 1, 1e38, 999999)', '"1e+38"');
     264
     265debug('');
    120266debug('Fractional numbers');
    121267shouldBe('stepUpExplicitBounds(null, null, 0.33333333333333333, 0, 3)', '"1"');
     
    128274shouldBe('stepDownExplicitBounds(null, null, 0.1, 1, 8)', '"0.2"');
    129275shouldBe('stepDownExplicitBounds(null, null, 0.1, 1)', '"0.9"');
     276
     277debug('');
    130278</script>
    131279<script src="../../../resources/js-test-post.js"></script>
  • trunk/Source/WebCore/ChangeLog

    r191938 r191940  
     12015-11-02  Keith Rollin  <krollin@apple.com>
     2
     3        input[type=number] does not increment/decrement integers with trailing decimal characters
     4        https://bugs.webkit.org/show_bug.cgi?id=148867
     5        rdar://problem/22589693
     6
     7        Reviewed by Chris Dumez.
     8
     9        Support input[type=number].value attributes of the form "###." (that
     10        is, leading digits with a decimal but no trailing digits). This form
     11        was supported in the setting of the attribute, but not when changing
     12        it through stepUp/Down.
     13
     14        Testing turned up similarly incorrect processing of -.###, so
     15        addressed that, too.
     16
     17        Test: fast/forms/range/input-appearance-range-decimals.html
     18
     19        Updated the following tests:
     20        - fast/forms/number/number-stepup-stepdown-from-renderer.html
     21        - fast/forms/number/number-stepup-stepdown.html
     22        - fast/forms/range/range-stepup-stepdown-from-renderer.html
     23        - fast/forms/range/range-stepup-stepdown.html
     24
     25        * html/InputType.cpp:
     26        (WebCore::InputType::stepUpFromRenderer):
     27        * platform/Decimal.cpp:
     28        (WebCore::Decimal::fromString):
     29
    1302015-11-02  Jiewen Tan  <jiewen_tan@apple.com>
    231
  • trunk/Source/WebCore/html/InputType.cpp

    r191876 r191940  
    10631063    //     - The value should be the larger matched value nearest to 0 if n > 0
    10641064    //       e.g. <input type=number min=-100 step=3> -> 2
    1065     //     - The value should be the smaler matched value nearest to 0 if n < 0
     1065    //     - The value should be the smaller matched value nearest to 0 if n < 0
    10661066    //       e.g. <input type=number min=-100 step=3> -> -1
    10671067    //   As for date/datetime-local/month/time/week types, the current value is assumed as "the current local date/time".
     
    10781078    // - The value should be the larger matched value nearest to 0 if n > 0
    10791079    //   e.g. <input type=number value=3 min=-100 step=3> -> 5
    1080     // - The value should be the smaler matched value nearest to 0 if n < 0
     1080    // - The value should be the smaller matched value nearest to 0 if n < 0
    10811081    //   e.g. <input type=number value=3 min=-100 step=3> -> 2
    10821082    //
  • trunk/Source/WebCore/platform/Decimal.cpp

    r162907 r191940  
    825825
    826826            HandleCharAndBreak('0', StateZero);
     827            HandleCharAndBreak('.', StateDot);
    827828            return nan();
    828829
     
    875876        return zero(sign);
    876877
    877     if (state == StateDigit || state == StateEDigit || state == StateDotDigit) {
     878    if (state == StateDigit || state == StateDot || state == StateDotDigit || state == StateEDigit) {
    878879        int resultExponent = exponent * (exponentSign == Negative ? -1 : 1) - numberOfDigitsAfterDot + numberOfExtraDigits;
    879880        if (resultExponent < ExponentMin)
Note: See TracChangeset for help on using the changeset viewer.