Changeset 191940 in webkit
- Timestamp:
- Nov 2, 2015 11:21:41 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r191939 r191940 1 2015-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 1 24 2015-11-02 Myles C. Maxfield <mmaxfield@apple.com> 2 25 -
trunk/LayoutTests/fast/forms/number/number-stepup-stepdown-expected.txt
r134648 r191940 5 5 6 6 Number type 7 7 8 Invalid value 8 9 PASS stepUp("", null, null) threw exception Error: InvalidStateError: DOM Exception 11. 9 10 PASS stepDown("", null, null) threw exception Error: InvalidStateError: DOM Exception 11. 11 10 12 Non-number arguments 11 13 PASS stepUp("0", null, null, "0") is "0" … … 15 17 PASS stepUp("0", null, null, null) is "0" 16 18 PASS stepDown("0", null, null, null) is "0" 19 17 20 Normal cases 18 21 PASS stepUp("0", null, null) is "1" … … 22 25 PASS stepDown("1", null, null, 2) is "-1" 23 26 PASS stepDown("-1", null, null, -1) is "0" 27 28 Fractional cases 29 PASS stepUp("0.1", 1, null) is "1.1" 30 PASS stepUp("0.2", 1, null) is "1.2" 31 PASS stepUp("1.0", 1, null) is "2" 32 PASS stepUp("1.1", 1, null) is "2.1" 33 PASS stepUp("1.2", 1, null) is "2.2" 34 PASS stepUp("2.0", 1, null) is "3" 35 36 PASS stepUp("-0.1", 1, null) is "0.9" 37 PASS stepUp("-0.2", 1, null) is "0.8" 38 PASS stepUp("-1.0", 1, null) is "0" 39 PASS stepUp("-1.1", 1, null) is "-0.1" 40 PASS stepUp("-1.2", 1, null) is "-0.2" 41 PASS stepUp("-2.0", 1, null) is "-1" 42 43 PASS stepDown("0.1", 1, null) is "-0.9" 44 PASS stepDown("0.2", 1, null) is "-0.8" 45 PASS stepDown("1.0", 1, null) is "0" 46 PASS stepDown("1.1", 1, null) is "0.1" 47 PASS stepDown("1.2", 1, null) is "0.2" 48 PASS stepDown("2.0", 1, null) is "1" 49 50 PASS stepDown("-0.1", 1, null) is "-1.1" 51 PASS stepDown("-0.2", 1, null) is "-1.2" 52 PASS stepDown("-1.0", 1, null) is "-2" 53 PASS stepDown("-1.1", 1, null) is "-2.1" 54 PASS stepDown("-1.2", 1, null) is "-2.2" 55 PASS stepDown("-2.0", 1, null) is "-3" 56 57 PASS stepUp(".1", 1, null) is "1.1" 58 PASS stepUp(".2", 1, null) is "1.2" 59 PASS stepUp("1.", 1, null) is "2" 60 PASS stepUp("2.", 1, null) is "3" 61 62 PASS stepUp("-.1", 1, null) is "0.9" 63 PASS stepUp("-.2", 1, null) is "0.8" 64 PASS stepUp("-1.", 1, null) is "0" 65 PASS stepUp("-2.", 1, null) is "-1" 66 67 PASS stepDown(".1", 1, null) is "-0.9" 68 PASS stepDown(".2", 1, null) is "-0.8" 69 PASS stepDown("1.", 1, null) is "0" 70 PASS stepDown("2.", 1, null) is "1" 71 72 PASS stepDown("-.1", 1, null) is "-1.1" 73 PASS stepDown("-.2", 1, null) is "-1.2" 74 PASS stepDown("-1.", 1, null) is "-2" 75 PASS stepDown("-2.", 1, null) is "-3" 76 77 PASS stepUp("0.1", .1, null) is "0.2" 78 PASS stepUp("0.2", .1, null) is "0.3" 79 PASS stepUp("1.0", .1, null) is "1.1" 80 PASS stepUp("1.1", .1, null) is "1.2" 81 PASS stepUp("1.2", .1, null) is "1.3" 82 PASS stepUp("2.0", .1, null) is "2.1" 83 84 PASS stepUp("-0.1", .1, null) is "0" 85 PASS stepUp("-0.2", .1, null) is "-0.1" 86 PASS stepUp("-1.0", .1, null) is "-0.9" 87 PASS stepUp("-1.1", .1, null) is "-1" 88 PASS stepUp("-1.2", .1, null) is "-1.1" 89 PASS stepUp("-2.0", .1, null) is "-1.9" 90 91 PASS stepDown("0.1", .1, null) is "0" 92 PASS stepDown("0.2", .1, null) is "0.1" 93 PASS stepDown("1.0", .1, null) is "0.9" 94 PASS stepDown("1.1", .1, null) is "1" 95 PASS stepDown("1.2", .1, null) is "1.1" 96 PASS stepDown("2.0", .1, null) is "1.9" 97 98 PASS stepDown("-0.1", .1, null) is "-0.2" 99 PASS stepDown("-0.2", .1, null) is "-0.3" 100 PASS stepDown("-1.0", .1, null) is "-1.1" 101 PASS stepDown("-1.1", .1, null) is "-1.2" 102 PASS stepDown("-1.2", .1, null) is "-1.3" 103 PASS stepDown("-2.0", .1, null) is "-2.1" 104 105 PASS stepUp(".1", .1, null) is "0.2" 106 PASS 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" 109 110 PASS stepUp("-.1", .1, null) is "0" 111 PASS 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" 114 115 PASS stepDown(".1", .1, null) is "0" 116 PASS 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" 119 120 PASS stepDown("-.1", .1, null) is "-0.2" 121 PASS 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" 124 24 125 Extra arguments 25 126 PASS input.value = "0"; input.min = null; input.step = null; input.stepUp(1, 2); input.value is "1" 26 127 PASS input.value = "1"; input.stepDown(1, 3); input.value is "0" 128 27 129 Invalid step value 28 130 PASS stepUp("0", "foo", null) is "1" 29 131 PASS stepUp("1", "0", null) is "2" 30 132 PASS stepUp("2", "-1", null) is "3" 133 31 134 Step=any 32 135 PASS stepUp("0", "any", null) threw exception Error: InvalidStateError: DOM Exception 11. 33 136 PASS stepDown("0", "any", null) threw exception Error: InvalidStateError: DOM Exception 11. 137 34 138 Step=any corner case 35 139 PASS stepUpExplicitBounds("0", "100", "any", "1.5", "1") threw exception Error: InvalidStateError: DOM Exception 11. 36 140 PASS stepDownExplicitBounds("0", "100", "any", "1.5", "1") threw exception Error: InvalidStateError: DOM Exception 11. 141 37 142 Overflow/underflow 38 143 PASS stepDown("1", "1", "0") is "0" … … 46 151 PASS input.value is "-1" 47 152 PASS stepUp("1", "3.40282346e+38", "", 2) threw exception Error: InvalidStateError: DOM Exception 11. 153 48 154 stepDown()/stepUp() for stepMismatch values 49 155 PASS stepUp("1", "2", "") is "3" … … 52 158 PASS stepDown("19", "10", "0") is "9" 53 159 PASS stepUp("89", "10", "99") is "99" 160 54 161 Huge value and small step 55 162 PASS input.min = ""; stepUp("1e+38", "1", "", 999999) is "1e+38" 56 163 PASS input.max = ""; stepDown("1e+38", "1", "", 999999) is "1e+38" 164 57 165 Fractional numbers 58 166 PASS input.min = ""; stepUp("0", "0.33333333333333333", "", 3) is "1" … … 61 169 PASS input.min = "0"; stepUp("0", "0.003921568627450980", "1", 255) is "1" 62 170 PASS for (var i = 0; i < 255; i++) { input.stepDown(); }; input.value is "0" 171 63 172 Rounding 64 173 PASS stepUp("5.005", "0.005", "", 2) is "5.015" … … 68 177 PASS stepUpExplicitBounds("4", "9", "0.005", "5.005", 11) is "5.06" 69 178 PASS stepUpExplicitBounds("4", "9", "0.005", "5.005", 12) is "5.065" 179 70 180 PASS successfullyParsed is true 71 181 -
trunk/LayoutTests/fast/forms/number/number-stepup-stepdown-from-renderer-expected.txt
r122552 r191940 6 6 Number type 7 7 Function arguments are (value, step, {min or max}, [stepCount]). 8 8 9 Invalid value 9 10 PASS stepUp("", null, null) is "1" … … 19 20 PASS stepUp("foo", "foo", null) is "1" 20 21 PASS stepDown("foo", "foo", null) is "-1" 22 21 23 Normal cases 22 24 PASS stepUp("0", null, null) is "1" … … 26 28 PASS stepDown("1", null, null, 2) is "-1" 27 29 PASS stepDown("-1", null, null, -1) is "0" 30 31 Fractional cases 32 PASS stepUp("0.1", 1, null) is "1" 33 PASS stepUp("0.2", 1, null) is "1" 34 PASS stepUp("1.0", 1, null) is "2" 35 PASS stepUp("1.1", 1, null) is "2" 36 PASS stepUp("1.2", 1, null) is "2" 37 PASS stepUp("2.0", 1, null) is "3" 38 39 PASS stepUp("-0.1", 1, null) is "0" 40 PASS stepUp("-0.2", 1, null) is "0" 41 PASS stepUp("-1.0", 1, null) is "0" 42 PASS stepUp("-1.1", 1, null) is "-1" 43 PASS stepUp("-1.2", 1, null) is "-1" 44 PASS stepUp("-2.0", 1, null) is "-1" 45 46 PASS stepDown("0.1", 1, null) is "0" 47 PASS stepDown("0.2", 1, null) is "0" 48 PASS stepDown("1.0", 1, null) is "0" 49 PASS stepDown("1.1", 1, null) is "1" 50 PASS stepDown("1.2", 1, null) is "1" 51 PASS stepDown("2.0", 1, null) is "1" 52 53 PASS stepDown("-0.1", 1, null) is "-1" 54 PASS stepDown("-0.2", 1, null) is "-1" 55 PASS stepDown("-1.0", 1, null) is "-2" 56 PASS stepDown("-1.1", 1, null) is "-2" 57 PASS stepDown("-1.2", 1, null) is "-2" 58 PASS stepDown("-2.0", 1, null) is "-3" 59 60 PASS stepUp(".1", 1, null) is "1" 61 PASS stepUp(".2", 1, null) is "1" 62 PASS stepUp("1.", 1, null) is "2" 63 PASS stepUp("2.", 1, null) is "3" 64 65 PASS stepUp("-.1", 1, null) is "0" 66 PASS stepUp("-.2", 1, null) is "0" 67 PASS stepUp("-1.", 1, null) is "0" 68 PASS stepUp("-2.", 1, null) is "-1" 69 70 PASS stepDown(".1", 1, null) is "0" 71 PASS stepDown(".2", 1, null) is "0" 72 PASS stepDown("1.", 1, null) is "0" 73 PASS stepDown("2.", 1, null) is "1" 74 75 PASS stepDown("-.1", 1, null) is "-1" 76 PASS stepDown("-.2", 1, null) is "-1" 77 PASS stepDown("-1.", 1, null) is "-2" 78 PASS stepDown("-2.", 1, null) is "-3" 79 80 PASS stepUp("0.1", .1, null) is "0.2" 81 PASS stepUp("0.2", .1, null) is "0.3" 82 PASS stepUp("1.0", .1, null) is "1.1" 83 PASS stepUp("1.1", .1, null) is "1.2" 84 PASS stepUp("1.2", .1, null) is "1.3" 85 PASS stepUp("2.0", .1, null) is "2.1" 86 87 PASS stepUp("-0.1", .1, null) is "0" 88 PASS stepUp("-0.2", .1, null) is "-0.1" 89 PASS stepUp("-1.0", .1, null) is "-0.9" 90 PASS stepUp("-1.1", .1, null) is "-1" 91 PASS stepUp("-1.2", .1, null) is "-1.1" 92 PASS stepUp("-2.0", .1, null) is "-1.9" 93 94 PASS stepDown("0.1", .1, null) is "0" 95 PASS stepDown("0.2", .1, null) is "0.1" 96 PASS stepDown("1.0", .1, null) is "0.9" 97 PASS stepDown("1.1", .1, null) is "1" 98 PASS stepDown("1.2", .1, null) is "1.1" 99 PASS stepDown("2.0", .1, null) is "1.9" 100 101 PASS stepDown("-0.1", .1, null) is "-0.2" 102 PASS stepDown("-0.2", .1, null) is "-0.3" 103 PASS stepDown("-1.0", .1, null) is "-1.1" 104 PASS stepDown("-1.1", .1, null) is "-1.2" 105 PASS stepDown("-1.2", .1, null) is "-1.3" 106 PASS stepDown("-2.0", .1, null) is "-2.1" 107 108 PASS stepUp(".1", .1, null) is "0.2" 109 PASS 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" 112 113 PASS stepUp("-.1", .1, null) is "0" 114 PASS 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" 117 PASS stepDown(".1", .1, null) is "0" 118 PASS 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" 121 122 PASS stepDown("-.1", .1, null) is "-0.2" 123 PASS 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" 126 28 127 Invalid step value 29 128 PASS stepUp("0", "foo", null) is "1" 30 129 PASS stepUp("1", "0", null) is "2" 31 130 PASS stepUp("2", "-1", null) is "3" 131 32 132 Step=any 33 133 PASS stepUp("0", "any", null) is "1" 34 134 PASS stepDown("0", "any", null) is "-1" 135 35 136 Step=any corner case 36 137 PASS stepUpExplicitBounds("0", "100", "any", "1.5", "1") is "2.5" 37 138 PASS stepDownExplicitBounds("0", "100", "any", "1.5", "1") is "0.5" 139 38 140 Overflow/underflow 39 141 PASS stepDown("1", "1", "0") is "0" … … 45 147 PASS stepUp("-1", "1", "0", 2) is "0" 46 148 PASS stepUp("1", "3.40282346e+38", "", 2) is "3.40282346e+38" 149 47 150 stepDown()/stepUp() for stepMismatch values 48 151 PASS stepUp("1", "2", "") is "2" … … 54 157 PASS stepDown("7", "300", "") is "0" 55 158 PASS stepDown("-7", "300", "") is "-300" 159 56 160 Huge value and small step 57 161 PASS input.min = ""; stepUp("1e+38", "1", "", 999) is "1e+38" 58 162 PASS input.max = ""; stepDown("1e+38", "1", "", 999) is "1e+38" 163 59 164 Fractional numbers 60 165 PASS input.min = ""; stepUp("0", "0.33333333333333333", "", 3) is "1" 61 166 PASS stepUp("1", "0.1", "", 10) is "2" 62 167 PASS input.min = "0"; stepUp("0", "0.003921568627450980", "1", 255) is "1" 168 63 169 Rounding 64 170 PASS stepUp("5.005", "0.005", "", 2) is "5.015" -
trunk/LayoutTests/fast/forms/number/number-stepup-stepdown-from-renderer.html
r155268 r191940 88 88 input.type = 'number'; 89 89 debug('Function arguments are (value, step, {min or max}, [stepCount]).'); 90 91 debug(''); 90 92 debug('Invalid value'); 91 93 shouldBe('stepUp("", null, null)', '"1"'); … … 101 103 shouldBe('stepUp("foo", "foo", null)', '"1"'); 102 104 shouldBe('stepDown("foo", "foo", null)', '"-1"'); 105 106 debug(''); 103 107 debug('Normal cases'); 104 108 shouldBe('stepUp("0", null, null)', '"1"'); … … 108 112 shouldBe('stepDown("1", null, null, 2)', '"-1"'); 109 113 shouldBe('stepDown("-1", null, null, -1)', '"0"'); 114 115 debug(''); 116 debug('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 137 shouldBe('stepUp("0.1", 1, null)', '"1"') // Is 1.1 in non-render test 138 shouldBe('stepUp("0.2", 1, null)', '"1"'); // Is 1.1 in non-render test 139 shouldBe('stepUp("1.0", 1, null)', '"2"'); 140 shouldBe('stepUp("1.1", 1, null)', '"2"'); // Is 2.1 in non-render test 141 shouldBe('stepUp("1.2", 1, null)', '"2"'); // Is 2.2 in non-render test 142 shouldBe('stepUp("2.0", 1, null)', '"3"'); 143 144 debug(''); 145 // Same as above, but with negative numbers. 146 shouldBe('stepUp("-0.1", 1, null)', '"0"'); // Is 0.9 in non-render test 147 shouldBe('stepUp("-0.2", 1, null)', '"0"'); // Is 0.8 in non-render test 148 shouldBe('stepUp("-1.0", 1, null)', '"0"'); 149 shouldBe('stepUp("-1.1", 1, null)', '"-1"'); // Is -0.1 in non-render test 150 shouldBe('stepUp("-1.2", 1, null)', '"-1"'); // Is -0.2 in non-render test 151 shouldBe('stepUp("-2.0", 1, null)', '"-1"'); 152 153 debug(''); 154 // Same as above, but stepping down rather than up. 155 shouldBe('stepDown("0.1", 1, null)', '"0"'); // Is -0.9 in non-render test 156 shouldBe('stepDown("0.2", 1, null)', '"0"'); // Is -0.8 in non-render test 157 shouldBe('stepDown("1.0", 1, null)', '"0"'); 158 shouldBe('stepDown("1.1", 1, null)', '"1"'); // Is 0.1 in non-render test 159 shouldBe('stepDown("1.2", 1, null)', '"1"'); // Is 0.2 in non-render test 160 shouldBe('stepDown("2.0", 1, null)', '"1"'); 161 162 debug(''); 163 shouldBe('stepDown("-0.1", 1, null)', '"-1"'); // Is -1.1 in non-render test 164 shouldBe('stepDown("-0.2", 1, null)', '"-1"'); // Is -1.2 in non-render test 165 shouldBe('stepDown("-1.0", 1, null)', '"-2"'); 166 shouldBe('stepDown("-1.1", 1, null)', '"-2"'); // Is -2.1 in non-render test 167 shouldBe('stepDown("-1.2", 1, null)', '"-2"'); // Is -2.2 in non-render test 168 shouldBe('stepDown("-2.0", 1, null)', '"-3"'); 169 170 // Same as above, but with leading/trailing zeros removed. 171 debug(''); 172 shouldBe('stepUp(".1", 1, null)', '"1"'); // Is 1.1 in non-render test 173 shouldBe('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"'); 176 177 debug(''); 178 shouldBe('stepUp("-.1", 1, null)', '"0"'); // Is 0.9 in non-render test 179 shouldBe('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"'); 182 183 debug(''); 184 shouldBe('stepDown(".1", 1, null)', '"0"'); // Is -0.9 in non-render test 185 shouldBe('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"'); 188 189 debug(''); 190 shouldBe('stepDown("-.1", 1, null)', '"-1"'); // Is -1.1 in non-render test 191 shouldBe('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"'); 194 195 // Same as above, but stepping by .1 rather than 1. 196 debug(''); 197 shouldBe('stepUp("0.1", .1, null)', '"0.2"'); 198 shouldBe('stepUp("0.2", .1, null)', '"0.3"'); 199 shouldBe('stepUp("1.0", .1, null)', '"1.1"'); 200 shouldBe('stepUp("1.1", .1, null)', '"1.2"'); 201 shouldBe('stepUp("1.2", .1, null)', '"1.3"'); 202 shouldBe('stepUp("2.0", .1, null)', '"2.1"'); 203 204 debug(''); 205 shouldBe('stepUp("-0.1", .1, null)', '"0"'); 206 shouldBe('stepUp("-0.2", .1, null)', '"-0.1"'); 207 shouldBe('stepUp("-1.0", .1, null)', '"-0.9"'); 208 shouldBe('stepUp("-1.1", .1, null)', '"-1"'); 209 shouldBe('stepUp("-1.2", .1, null)', '"-1.1"'); 210 shouldBe('stepUp("-2.0", .1, null)', '"-1.9"'); 211 212 debug(''); 213 shouldBe('stepDown("0.1", .1, null)', '"0"'); 214 shouldBe('stepDown("0.2", .1, null)', '"0.1"'); 215 shouldBe('stepDown("1.0", .1, null)', '"0.9"'); 216 shouldBe('stepDown("1.1", .1, null)', '"1"'); 217 shouldBe('stepDown("1.2", .1, null)', '"1.1"'); 218 shouldBe('stepDown("2.0", .1, null)', '"1.9"'); 219 220 debug(''); 221 shouldBe('stepDown("-0.1", .1, null)', '"-0.2"'); 222 shouldBe('stepDown("-0.2", .1, null)', '"-0.3"'); 223 shouldBe('stepDown("-1.0", .1, null)', '"-1.1"'); 224 shouldBe('stepDown("-1.1", .1, null)', '"-1.2"'); 225 shouldBe('stepDown("-1.2", .1, null)', '"-1.3"'); 226 shouldBe('stepDown("-2.0", .1, null)', '"-2.1"'); 227 228 debug(''); 229 shouldBe('stepUp(".1", .1, null)', '"0.2"'); 230 shouldBe('stepUp(".2", .1, null)', '"0.3"'); 231 shouldBe('stepUp("1.", .1, null)', '"1.1"'); 232 shouldBe('stepUp("2.", .1, null)', '"2.1"'); 233 234 debug(''); 235 shouldBe('stepUp("-.1", .1, null)', '"0"'); 236 shouldBe('stepUp("-.2", .1, null)', '"-0.1"'); 237 shouldBe('stepUp("-1.", .1, null)', '"-0.9"'); 238 shouldBe('stepUp("-2.", .1, null)', '"-1.9"'); 239 240 shouldBe('stepDown(".1", .1, null)', '"0"'); 241 shouldBe('stepDown(".2", .1, null)', '"0.1"'); 242 shouldBe('stepDown("1.", .1, null)', '"0.9"'); 243 shouldBe('stepDown("2.", .1, null)', '"1.9"'); 244 245 debug(''); 246 shouldBe('stepDown("-.1", .1, null)', '"-0.2"'); 247 shouldBe('stepDown("-.2", .1, null)', '"-0.3"'); 248 shouldBe('stepDown("-1.", .1, null)', '"-1.1"'); 249 shouldBe('stepDown("-2.", .1, null)', '"-2.1"'); 250 251 debug(''); 110 252 debug('Invalid step value'); 111 253 shouldBe('stepUp("0", "foo", null)', '"1"'); 112 254 shouldBe('stepUp("1", "0", null)', '"2"'); 113 255 shouldBe('stepUp("2", "-1", null)', '"3"'); 256 257 debug(''); 114 258 debug('Step=any'); 115 259 shouldBe('stepUp("0", "any", null)', '"1"'); 116 260 shouldBe('stepDown("0", "any", null)', '"-1"'); 261 262 debug(''); 117 263 debug('Step=any corner case'); 118 264 shouldBe('stepUpExplicitBounds("0", "100", "any", "1.5", "1")', '"2.5"'); 119 265 shouldBe('stepDownExplicitBounds("0", "100", "any", "1.5", "1")', '"0.5"'); 266 267 debug(''); 120 268 debug('Overflow/underflow'); 121 269 shouldBe('stepDown("1", "1", "0")', '"0"'); … … 127 275 shouldBe('stepUp("-1", "1", "0", 2)', '"0"'); 128 276 shouldBe('stepUp("1", "3.40282346e+38", "", 2)', '"3.40282346e+38"'); 277 278 debug(''); 129 279 debug('stepDown()/stepUp() for stepMismatch values'); 130 280 shouldBe('stepUp("1", "2", "")', '"2"'); … … 136 286 shouldBe('stepDown("7", "300", "")', '"0"'); 137 287 shouldBe('stepDown("-7", "300", "")', '"-300"'); 288 289 debug(''); 138 290 debug('Huge value and small step'); 139 291 shouldBe('input.min = ""; stepUp("1e+38", "1", "", 999)', '"1e+38"'); 140 292 shouldBe('input.max = ""; stepDown("1e+38", "1", "", 999)', '"1e+38"'); 293 294 debug(''); 141 295 debug('Fractional numbers'); 142 296 shouldBe('input.min = ""; stepUp("0", "0.33333333333333333", "", 3)', '"1"'); 143 297 shouldBe('stepUp("1", "0.1", "", 10)', '"2"'); 144 298 shouldBe('input.min = "0"; stepUp("0", "0.003921568627450980", "1", 255)', '"1"'); 299 300 debug(''); 145 301 debug('Rounding'); 146 302 shouldBe('stepUp("5.005", "0.005", "", 2)', '"5.015"'); -
trunk/LayoutTests/fast/forms/number/number-stepup-stepdown.html
r155268 r191940 56 56 debug('Number type'); 57 57 input.type = 'number'; 58 59 debug(''); 58 60 debug('Invalid value'); 59 61 shouldThrow('stepUp("", null, null)', invalidStateErr); 60 62 shouldThrow('stepDown("", null, null)', invalidStateErr); 63 64 debug(''); 61 65 debug('Non-number arguments'); 62 66 shouldBe('stepUp("0", null, null, "0")', '"0"'); … … 66 70 shouldBe('stepUp("0", null, null, null)', '"0"'); 67 71 shouldBe('stepDown("0", null, null, null)', '"0"'); 72 73 debug(''); 68 74 debug('Normal cases'); 69 75 shouldBe('stepUp("0", null, null)', '"1"'); … … 73 79 shouldBe('stepDown("1", null, null, 2)', '"-1"'); 74 80 shouldBe('stepDown("-1", null, null, -1)', '"0"'); 81 82 debug(''); 83 debug('Fractional cases') 84 // Base/model/template tests 85 shouldBe('stepUp("0.1", 1, null)', '"1.1"'); 86 shouldBe('stepUp("0.2", 1, null)', '"1.2"'); 87 shouldBe('stepUp("1.0", 1, null)', '"2"'); 88 shouldBe('stepUp("1.1", 1, null)', '"2.1"'); 89 shouldBe('stepUp("1.2", 1, null)', '"2.2"'); 90 shouldBe('stepUp("2.0", 1, null)', '"3"'); 91 92 // Same as above, but with negative numbers. 93 debug(''); 94 shouldBe('stepUp("-0.1", 1, null)', '"0.9"'); 95 shouldBe('stepUp("-0.2", 1, null)', '"0.8"'); 96 shouldBe('stepUp("-1.0", 1, null)', '"0"'); 97 shouldBe('stepUp("-1.1", 1, null)', '"-0.1"'); 98 shouldBe('stepUp("-1.2", 1, null)', '"-0.2"'); 99 shouldBe('stepUp("-2.0", 1, null)', '"-1"'); 100 101 // Same as above, but stepping down rather than up. 102 debug(''); 103 shouldBe('stepDown("0.1", 1, null)', '"-0.9"'); 104 shouldBe('stepDown("0.2", 1, null)', '"-0.8"'); 105 shouldBe('stepDown("1.0", 1, null)', '"0"'); 106 shouldBe('stepDown("1.1", 1, null)', '"0.1"'); 107 shouldBe('stepDown("1.2", 1, null)', '"0.2"'); 108 shouldBe('stepDown("2.0", 1, null)', '"1"'); 109 110 debug(''); 111 shouldBe('stepDown("-0.1", 1, null)', '"-1.1"'); 112 shouldBe('stepDown("-0.2", 1, null)', '"-1.2"'); 113 shouldBe('stepDown("-1.0", 1, null)', '"-2"'); 114 shouldBe('stepDown("-1.1", 1, null)', '"-2.1"'); 115 shouldBe('stepDown("-1.2", 1, null)', '"-2.2"'); 116 shouldBe('stepDown("-2.0", 1, null)', '"-3"'); 117 118 // Same as above, but with leading/trailing zeros removed. 119 debug(''); 120 shouldBe('stepUp(".1", 1, null)', '"1.1"'); 121 shouldBe('stepUp(".2", 1, null)', '"1.2"'); 122 shouldBe('stepUp("1.", 1, null)', '"2"'); 123 shouldBe('stepUp("2.", 1, null)', '"3"'); 124 125 debug(''); 126 shouldBe('stepUp("-.1", 1, null)', '"0.9"'); 127 shouldBe('stepUp("-.2", 1, null)', '"0.8"'); 128 shouldBe('stepUp("-1.", 1, null)', '"0"'); 129 shouldBe('stepUp("-2.", 1, null)', '"-1"'); 130 131 debug(''); 132 shouldBe('stepDown(".1", 1, null)', '"-0.9"'); 133 shouldBe('stepDown(".2", 1, null)', '"-0.8"'); 134 shouldBe('stepDown("1.", 1, null)', '"0"'); 135 shouldBe('stepDown("2.", 1, null)', '"1"'); 136 137 debug(''); 138 shouldBe('stepDown("-.1", 1, null)', '"-1.1"'); 139 shouldBe('stepDown("-.2", 1, null)', '"-1.2"'); 140 shouldBe('stepDown("-1.", 1, null)', '"-2"'); 141 shouldBe('stepDown("-2.", 1, null)', '"-3"'); 142 143 // Same as above, but stepping by .1 rather than 1. 144 debug(''); 145 shouldBe('stepUp("0.1", .1, null)', '"0.2"'); 146 shouldBe('stepUp("0.2", .1, null)', '"0.3"'); 147 shouldBe('stepUp("1.0", .1, null)', '"1.1"'); 148 shouldBe('stepUp("1.1", .1, null)', '"1.2"'); 149 shouldBe('stepUp("1.2", .1, null)', '"1.3"'); 150 shouldBe('stepUp("2.0", .1, null)', '"2.1"'); 151 152 debug(''); 153 shouldBe('stepUp("-0.1", .1, null)', '"0"'); 154 shouldBe('stepUp("-0.2", .1, null)', '"-0.1"'); 155 shouldBe('stepUp("-1.0", .1, null)', '"-0.9"'); 156 shouldBe('stepUp("-1.1", .1, null)', '"-1"'); 157 shouldBe('stepUp("-1.2", .1, null)', '"-1.1"'); 158 shouldBe('stepUp("-2.0", .1, null)', '"-1.9"'); 159 160 debug(''); 161 shouldBe('stepDown("0.1", .1, null)', '"0"'); 162 shouldBe('stepDown("0.2", .1, null)', '"0.1"'); 163 shouldBe('stepDown("1.0", .1, null)', '"0.9"'); 164 shouldBe('stepDown("1.1", .1, null)', '"1"'); 165 shouldBe('stepDown("1.2", .1, null)', '"1.1"'); 166 shouldBe('stepDown("2.0", .1, null)', '"1.9"'); 167 168 debug(''); 169 shouldBe('stepDown("-0.1", .1, null)', '"-0.2"'); 170 shouldBe('stepDown("-0.2", .1, null)', '"-0.3"'); 171 shouldBe('stepDown("-1.0", .1, null)', '"-1.1"'); 172 shouldBe('stepDown("-1.1", .1, null)', '"-1.2"'); 173 shouldBe('stepDown("-1.2", .1, null)', '"-1.3"'); 174 shouldBe('stepDown("-2.0", .1, null)', '"-2.1"'); 175 176 debug(''); 177 shouldBe('stepUp(".1", .1, null)', '"0.2"'); 178 shouldBe('stepUp(".2", .1, null)', '"0.3"'); 179 shouldBe('stepUp("1.", .1, null)', '"1.1"'); 180 shouldBe('stepUp("2.", .1, null)', '"2.1"'); 181 182 debug(''); 183 shouldBe('stepUp("-.1", .1, null)', '"0"'); 184 shouldBe('stepUp("-.2", .1, null)', '"-0.1"'); 185 shouldBe('stepUp("-1.", .1, null)', '"-0.9"'); 186 shouldBe('stepUp("-2.", .1, null)', '"-1.9"'); 187 188 debug(''); 189 shouldBe('stepDown(".1", .1, null)', '"0"'); 190 shouldBe('stepDown(".2", .1, null)', '"0.1"'); 191 shouldBe('stepDown("1.", .1, null)', '"0.9"'); 192 shouldBe('stepDown("2.", .1, null)', '"1.9"'); 193 194 debug(''); 195 shouldBe('stepDown("-.1", .1, null)', '"-0.2"'); 196 shouldBe('stepDown("-.2", .1, null)', '"-0.3"'); 197 shouldBe('stepDown("-1.", .1, null)', '"-1.1"'); 198 shouldBe('stepDown("-2.", .1, null)', '"-2.1"'); 199 200 debug(''); 75 201 debug('Extra arguments'); 76 202 shouldBe('input.value = "0"; input.min = null; input.step = null; input.stepUp(1, 2); input.value', '"1"'); 77 203 shouldBe('input.value = "1"; input.stepDown(1, 3); input.value', '"0"'); 204 205 debug(''); 78 206 debug('Invalid step value'); 79 207 shouldBe('stepUp("0", "foo", null)', '"1"'); 80 208 shouldBe('stepUp("1", "0", null)', '"2"'); 81 209 shouldBe('stepUp("2", "-1", null)', '"3"'); 210 211 debug(''); 82 212 debug('Step=any'); 83 213 shouldThrow('stepUp("0", "any", null)', invalidStateErr); 84 214 shouldThrow('stepDown("0", "any", null)', invalidStateErr); 215 216 debug(''); 85 217 debug('Step=any corner case'); 86 218 shouldThrow('stepUpExplicitBounds("0", "100", "any", "1.5", "1")', invalidStateErr); 87 219 shouldThrow('stepDownExplicitBounds("0", "100", "any", "1.5", "1")', invalidStateErr); 220 221 debug(''); 88 222 debug('Overflow/underflow'); 89 223 shouldBe('stepDown("1", "1", "0")', '"0"'); … … 97 231 shouldBe('input.value', '"-1"'); 98 232 shouldThrow('stepUp("1", "3.40282346e+38", "", 2)', invalidStateErr); 233 234 debug(''); 99 235 debug('stepDown()/stepUp() for stepMismatch values'); 100 236 shouldBe('stepUp("1", "2", "")', '"3"'); … … 103 239 shouldBe('stepDown("19", "10", "0")', '"9"'); 104 240 shouldBe('stepUp("89", "10", "99")', '"99"'); 241 242 debug(''); 105 243 debug('Huge value and small step'); 106 244 shouldBe('input.min = ""; stepUp("1e+38", "1", "", 999999)', '"1e+38"'); 107 245 shouldBe('input.max = ""; stepDown("1e+38", "1", "", 999999)', '"1e+38"'); 246 247 debug(''); 108 248 debug('Fractional numbers'); 109 249 shouldBe('input.min = ""; stepUp("0", "0.33333333333333333", "", 3)', '"1"'); … … 112 252 shouldBe('input.min = "0"; stepUp("0", "0.003921568627450980", "1", 255)', '"1"'); 113 253 shouldBe('for (var i = 0; i < 255; i++) { input.stepDown(); }; input.value', '"0"'); 254 255 debug(''); 114 256 debug('Rounding'); 115 257 shouldBe('stepUp("5.005", "0.005", "", 2)', '"5.015"'); … … 119 261 shouldBe('stepUpExplicitBounds("4", "9", "0.005", "5.005", 11)', '"5.06"'); 120 262 shouldBe('stepUpExplicitBounds("4", "9", "0.005", "5.005", 12)', '"5.065"'); 263 264 debug(''); 121 265 </script> 122 266 <script src="../../../resources/js-test-post.js"></script> -
trunk/LayoutTests/fast/forms/range/range-stepup-stepdown-expected.txt
r134648 r191940 8 8 PASS stepUpExplicitBounds(null, null, null, "") is "51" 9 9 PASS stepDownExplicitBounds(null, null, null, "") is "49" 10 10 11 Non-number arguments (stepCount) 11 12 PASS stepUpExplicitBounds(null, null, null, "0", "0") is "0" … … 15 16 PASS stepUpExplicitBounds(null, null, null, "0", null) is "0" 16 17 PASS stepDownExplicitBounds(null, null, null, "0", null) is "0" 18 17 19 Normal cases 18 20 PASS stepUpExplicitBounds(null, null, null, "0") is "1" … … 22 24 PASS stepDownExplicitBounds("-100", null, null, "1", 2) is "-1" 23 25 PASS stepDownExplicitBounds("-100", null, null, "-1", -1) is "0" 26 27 Fractional cases 28 PASS stepUpExplicitBounds(-10, 10, 1, "0.1") is "1" 29 PASS stepUpExplicitBounds(-10, 10, 1, "0.2") is "1" 30 PASS stepUpExplicitBounds(-10, 10, 1, "1.0") is "2" 31 PASS stepUpExplicitBounds(-10, 10, 1, "1.1") is "2" 32 PASS stepUpExplicitBounds(-10, 10, 1, "1.2") is "2" 33 PASS stepUpExplicitBounds(-10, 10, 1, "2.0") is "3" 34 35 PASS stepUpExplicitBounds(-10, 10, 1, "-0.1") is "1" 36 PASS stepUpExplicitBounds(-10, 10, 1, "-0.2") is "1" 37 PASS stepUpExplicitBounds(-10, 10, 1, "-1.0") is "0" 38 PASS stepUpExplicitBounds(-10, 10, 1, "-1.1") is "0" 39 PASS stepUpExplicitBounds(-10, 10, 1, "-1.2") is "0" 40 PASS stepUpExplicitBounds(-10, 10, 1, "-2.0") is "-1" 41 42 PASS stepDownExplicitBounds(-10, 10, 1, "0.1") is "-1" 43 PASS stepDownExplicitBounds(-10, 10, 1, "0.2") is "-1" 44 PASS stepDownExplicitBounds(-10, 10, 1, "1.0") is "0" 45 PASS stepDownExplicitBounds(-10, 10, 1, "1.1") is "0" 46 PASS stepDownExplicitBounds(-10, 10, 1, "1.2") is "0" 47 PASS stepDownExplicitBounds(-10, 10, 1, "2.0") is "1" 48 49 PASS stepDownExplicitBounds(-10, 10, 1, "-0.1") is "-1" 50 PASS stepDownExplicitBounds(-10, 10, 1, "-0.2") is "-1" 51 PASS stepDownExplicitBounds(-10, 10, 1, "-1.0") is "-2" 52 PASS stepDownExplicitBounds(-10, 10, 1, "-1.1") is "-2" 53 PASS stepDownExplicitBounds(-10, 10, 1, "-1.2") is "-2" 54 PASS stepDownExplicitBounds(-10, 10, 1, "-2.0") is "-3" 55 56 PASS stepUpExplicitBounds(-10, 10, 1, ".1") is "1" 57 PASS stepUpExplicitBounds(-10, 10, 1, ".2") is "1" 58 PASS stepUpExplicitBounds(-10, 10, 1, "1.") is "2" 59 PASS stepUpExplicitBounds(-10, 10, 1, "2.") is "3" 60 61 PASS stepUpExplicitBounds(-10, 10, 1, "-.1") is "1" 62 PASS stepUpExplicitBounds(-10, 10, 1, "-.2") is "1" 63 PASS stepUpExplicitBounds(-10, 10, 1, "-1.") is "0" 64 PASS stepUpExplicitBounds(-10, 10, 1, "-2.") is "-1" 65 66 PASS stepDownExplicitBounds(-10, 10, 1, ".1") is "-1" 67 PASS stepDownExplicitBounds(-10, 10, 1, ".2") is "-1" 68 PASS stepDownExplicitBounds(-10, 10, 1, "1.") is "0" 69 PASS stepDownExplicitBounds(-10, 10, 1, "2.") is "1" 70 71 PASS stepDownExplicitBounds(-10, 10, 1, "-.1") is "-1" 72 PASS stepDownExplicitBounds(-10, 10, 1, "-.2") is "-1" 73 PASS stepDownExplicitBounds(-10, 10, 1, "-1.") is "-2" 74 PASS stepDownExplicitBounds(-10, 10, 1, "-2.") is "-3" 75 76 PASS stepUpExplicitBounds(-10, 10, .1, "0.1") is "0.2" 77 PASS stepUpExplicitBounds(-10, 10, .1, "0.2") is "0.3" 78 PASS stepUpExplicitBounds(-10, 10, .1, "1.0") is "1.1" 79 PASS stepUpExplicitBounds(-10, 10, .1, "1.1") is "1.2" 80 PASS stepUpExplicitBounds(-10, 10, .1, "1.2") is "1.3" 81 PASS stepUpExplicitBounds(-10, 10, .1, "2.0") is "2.1" 82 83 PASS stepUpExplicitBounds(-10, 10, .1, "-0.1") is "0" 84 PASS stepUpExplicitBounds(-10, 10, .1, "-0.2") is "-0.1" 85 PASS stepUpExplicitBounds(-10, 10, .1, "-1.0") is "-0.9" 86 PASS stepUpExplicitBounds(-10, 10, .1, "-1.1") is "-1" 87 PASS stepUpExplicitBounds(-10, 10, .1, "-1.2") is "-1.1" 88 PASS stepUpExplicitBounds(-10, 10, .1, "-2.0") is "-1.9" 89 90 PASS stepDownExplicitBounds(-10, 10, .1, "0.1") is "0" 91 PASS stepDownExplicitBounds(-10, 10, .1, "0.2") is "0.1" 92 PASS stepDownExplicitBounds(-10, 10, .1, "1.0") is "0.9" 93 PASS stepDownExplicitBounds(-10, 10, .1, "1.1") is "1" 94 PASS stepDownExplicitBounds(-10, 10, .1, "1.2") is "1.1" 95 PASS stepDownExplicitBounds(-10, 10, .1, "2.0") is "1.9" 96 97 PASS stepDownExplicitBounds(-10, 10, .1, "-0.1") is "-0.2" 98 PASS stepDownExplicitBounds(-10, 10, .1, "-0.2") is "-0.3" 99 PASS stepDownExplicitBounds(-10, 10, .1, "-1.0") is "-1.1" 100 PASS stepDownExplicitBounds(-10, 10, .1, "-1.1") is "-1.2" 101 PASS stepDownExplicitBounds(-10, 10, .1, "-1.2") is "-1.3" 102 PASS stepDownExplicitBounds(-10, 10, .1, "-2.0") is "-2.1" 103 104 PASS stepUpExplicitBounds(-10, 10, .1, ".1") is "0.2" 105 PASS stepUpExplicitBounds(-10, 10, .1, ".2") is "0.3" 106 PASS stepUpExplicitBounds(-10, 10, .1, "1.") is "1.1" 107 PASS stepUpExplicitBounds(-10, 10, .1, "2.") is "2.1" 108 109 PASS stepUpExplicitBounds(-10, 10, .1, "-.1") is "0" 110 PASS stepUpExplicitBounds(-10, 10, .1, "-.2") is "-0.1" 111 PASS stepUpExplicitBounds(-10, 10, .1, "-1.") is "-0.9" 112 PASS stepUpExplicitBounds(-10, 10, .1, "-2.") is "-1.9" 113 114 PASS stepDownExplicitBounds(-10, 10, .1, ".1") is "0" 115 PASS stepDownExplicitBounds(-10, 10, .1, ".2") is "0.1" 116 PASS stepDownExplicitBounds(-10, 10, .1, "1.") is "0.9" 117 PASS stepDownExplicitBounds(-10, 10, .1, "2.") is "1.9" 118 119 PASS stepDownExplicitBounds(-10, 10, .1, "-.1") is "-0.2" 120 PASS stepDownExplicitBounds(-10, 10, .1, "-.2") is "-0.3" 121 PASS stepDownExplicitBounds(-10, 10, .1, "-1.") is "-1.1" 122 PASS stepDownExplicitBounds(-10, 10, .1, "-2.") is "-2.1" 123 24 124 Extra arguments 25 125 PASS setInputAttributes(null, null, null, "0"); input.stepUp(1,2); input.value is "1" 26 126 PASS setInputAttributes(null, null, null, "1"); input.stepDown(1,3); input.value is "0" 127 27 128 Invalid step value 28 129 PASS stepUpExplicitBounds(null, null, "foo", "0") is "1" … … 32 133 PASS stepDownExplicitBounds(null, null, "0", "2") is "1" 33 134 PASS stepDownExplicitBounds(null, null, "-1", "3") is "2" 135 34 136 Step=any 35 137 PASS stepUpExplicitBounds(null, null, "any", "1") threw exception Error: InvalidStateError: DOM Exception 11. 36 138 PASS stepDownExplicitBounds(null, null, "any", "1") threw exception Error: InvalidStateError: DOM Exception 11. 139 37 140 Overflow/underflow 38 141 PASS stepUpExplicitBounds(null, "100", "1", "99") is "100" … … 52 155 PASS input.value is "-1" 53 156 PASS stepUpExplicitBounds(null, null, "3.40282346e+38", "1", "2") threw exception Error: InvalidStateError: DOM Exception 11. 157 54 158 stepDown()/stepUp() for stepMismatch values 55 159 PASS stepUpExplicitBounds(null, null, 2, 1) is "4" … … 57 161 PASS stepUpExplicitBounds(0, null, 10, 9, 9) is "100" 58 162 PASS stepDownExplicitBounds(0, null, 10, 19) is "10" 163 59 164 value + step is <= max, but rounded result would be > max. 60 165 PASS stepUpExplicitBounds(null, 99, 10, 89) threw exception Error: InvalidStateError: DOM Exception 11. 166 61 167 Huge value and small step 62 168 PASS stepUpExplicitBounds(0, 1e38, 1, 1e38, 999999) is "1e+38" 63 169 PASS stepDownExplicitBounds(0, 1e38, 1, 1e38, 999999) is "1e+38" 170 64 171 Fractional numbers 65 172 PASS stepUpExplicitBounds(null, null, 0.33333333333333333, 0, 3) is "1" … … 72 179 PASS stepDownExplicitBounds(null, null, 0.1, 1, 8) is "0.2" 73 180 PASS stepDownExplicitBounds(null, null, 0.1, 1) is "0.9" 181 74 182 PASS successfullyParsed is true 75 183 -
trunk/LayoutTests/fast/forms/range/range-stepup-stepdown-from-renderer-expected.txt
r93593 r191940 18 18 PASS stepUpExplicitBounds(null, null, "foo", "foo") is "51" 19 19 PASS stepDownExplicitBounds(null, null, "foo", "foo") is "49" 20 20 21 Normal cases 21 22 PASS stepUpExplicitBounds(null, null, null, "0") is "1" … … 25 26 PASS stepDownExplicitBounds("-100", null, null, "1", 2) is "-1" 26 27 PASS stepDownExplicitBounds("-100", null, null, "-1", -1) is "0" 28 29 Fractional cases 30 PASS stepUpExplicitBounds(-10, 10, 1, "0.1") is "1" 31 PASS stepUpExplicitBounds(-10, 10, 1, "0.2") is "1" 32 PASS stepUpExplicitBounds(-10, 10, 1, "1.0") is "2" 33 PASS stepUpExplicitBounds(-10, 10, 1, "1.1") is "2" 34 PASS stepUpExplicitBounds(-10, 10, 1, "1.2") is "2" 35 PASS stepUpExplicitBounds(-10, 10, 1, "2.0") is "3" 36 37 PASS stepUpExplicitBounds(-10, 10, 1, "-0.1") is "1" 38 PASS stepUpExplicitBounds(-10, 10, 1, "-0.2") is "1" 39 PASS stepUpExplicitBounds(-10, 10, 1, "-1.0") is "0" 40 PASS stepUpExplicitBounds(-10, 10, 1, "-1.1") is "0" 41 PASS stepUpExplicitBounds(-10, 10, 1, "-1.2") is "0" 42 PASS stepUpExplicitBounds(-10, 10, 1, "-2.0") is "-1" 43 44 PASS stepDownExplicitBounds(-10, 10, 1, "0.1") is "-1" 45 PASS stepDownExplicitBounds(-10, 10, 1, "0.2") is "-1" 46 PASS stepDownExplicitBounds(-10, 10, 1, "1.0") is "0" 47 PASS stepDownExplicitBounds(-10, 10, 1, "1.1") is "0" 48 PASS stepDownExplicitBounds(-10, 10, 1, "1.2") is "0" 49 PASS stepDownExplicitBounds(-10, 10, 1, "2.0") is "1" 50 51 PASS stepDownExplicitBounds(-10, 10, 1, "-0.1") is "-1" 52 PASS stepDownExplicitBounds(-10, 10, 1, "-0.2") is "-1" 53 PASS stepDownExplicitBounds(-10, 10, 1, "-1.0") is "-2" 54 PASS stepDownExplicitBounds(-10, 10, 1, "-1.1") is "-2" 55 PASS stepDownExplicitBounds(-10, 10, 1, "-1.2") is "-2" 56 PASS stepDownExplicitBounds(-10, 10, 1, "-2.0") is "-3" 57 58 PASS stepUpExplicitBounds(-10, 10, 1, ".1") is "1" 59 PASS stepUpExplicitBounds(-10, 10, 1, ".2") is "1" 60 PASS stepUpExplicitBounds(-10, 10, 1, "1.") is "2" 61 PASS stepUpExplicitBounds(-10, 10, 1, "2.") is "3" 62 63 PASS stepUpExplicitBounds(-10, 10, 1, "-.1") is "1" 64 PASS stepUpExplicitBounds(-10, 10, 1, "-.2") is "1" 65 PASS stepUpExplicitBounds(-10, 10, 1, "-1.") is "0" 66 PASS stepUpExplicitBounds(-10, 10, 1, "-2.") is "-1" 67 68 PASS stepDownExplicitBounds(-10, 10, 1, ".1") is "-1" 69 PASS stepDownExplicitBounds(-10, 10, 1, ".2") is "-1" 70 PASS stepDownExplicitBounds(-10, 10, 1, "1.") is "0" 71 PASS stepDownExplicitBounds(-10, 10, 1, "2.") is "1" 72 73 PASS stepDownExplicitBounds(-10, 10, 1, "-.1") is "-1" 74 PASS stepDownExplicitBounds(-10, 10, 1, "-.2") is "-1" 75 PASS stepDownExplicitBounds(-10, 10, 1, "-1.") is "-2" 76 PASS stepDownExplicitBounds(-10, 10, 1, "-2.") is "-3" 77 78 PASS stepUpExplicitBounds(-10, 10, .1, "0.1") is "0.2" 79 PASS stepUpExplicitBounds(-10, 10, .1, "0.2") is "0.3" 80 PASS stepUpExplicitBounds(-10, 10, .1, "1.0") is "1.1" 81 PASS stepUpExplicitBounds(-10, 10, .1, "1.1") is "1.2" 82 PASS stepUpExplicitBounds(-10, 10, .1, "1.2") is "1.3" 83 PASS stepUpExplicitBounds(-10, 10, .1, "2.0") is "2.1" 84 85 PASS stepUpExplicitBounds(-10, 10, .1, "-0.1") is "0" 86 PASS stepUpExplicitBounds(-10, 10, .1, "-0.2") is "-0.1" 87 PASS stepUpExplicitBounds(-10, 10, .1, "-1.0") is "-0.9" 88 PASS stepUpExplicitBounds(-10, 10, .1, "-1.1") is "-1" 89 PASS stepUpExplicitBounds(-10, 10, .1, "-1.2") is "-1.1" 90 PASS stepUpExplicitBounds(-10, 10, .1, "-2.0") is "-1.9" 91 92 PASS stepDownExplicitBounds(-10, 10, .1, "0.1") is "0" 93 PASS stepDownExplicitBounds(-10, 10, .1, "0.2") is "0.1" 94 PASS stepDownExplicitBounds(-10, 10, .1, "1.0") is "0.9" 95 PASS stepDownExplicitBounds(-10, 10, .1, "1.1") is "1" 96 PASS stepDownExplicitBounds(-10, 10, .1, "1.2") is "1.1" 97 PASS stepDownExplicitBounds(-10, 10, .1, "2.0") is "1.9" 98 99 PASS stepDownExplicitBounds(-10, 10, .1, "-0.1") is "-0.2" 100 PASS stepDownExplicitBounds(-10, 10, .1, "-0.2") is "-0.3" 101 PASS stepDownExplicitBounds(-10, 10, .1, "-1.0") is "-1.1" 102 PASS stepDownExplicitBounds(-10, 10, .1, "-1.1") is "-1.2" 103 PASS stepDownExplicitBounds(-10, 10, .1, "-1.2") is "-1.3" 104 PASS stepDownExplicitBounds(-10, 10, .1, "-2.0") is "-2.1" 105 106 PASS stepUpExplicitBounds(-10, 10, .1, ".1") is "0.2" 107 PASS stepUpExplicitBounds(-10, 10, .1, ".2") is "0.3" 108 PASS stepUpExplicitBounds(-10, 10, .1, "1.") is "1.1" 109 PASS stepUpExplicitBounds(-10, 10, .1, "2.") is "2.1" 110 111 PASS stepUpExplicitBounds(-10, 10, .1, "-.1") is "0" 112 PASS stepUpExplicitBounds(-10, 10, .1, "-.2") is "-0.1" 113 PASS stepUpExplicitBounds(-10, 10, .1, "-1.") is "-0.9" 114 PASS stepUpExplicitBounds(-10, 10, .1, "-2.") is "-1.9" 115 PASS stepDownExplicitBounds(-10, 10, .1, ".1") is "0" 116 PASS stepDownExplicitBounds(-10, 10, .1, ".2") is "0.1" 117 PASS stepDownExplicitBounds(-10, 10, .1, "1.") is "0.9" 118 PASS stepDownExplicitBounds(-10, 10, .1, "2.") is "1.9" 119 120 PASS stepDownExplicitBounds(-10, 10, .1, "-.1") is "-0.2" 121 PASS stepDownExplicitBounds(-10, 10, .1, "-.2") is "-0.3" 122 PASS stepDownExplicitBounds(-10, 10, .1, "-1.") is "-1.1" 123 PASS stepDownExplicitBounds(-10, 10, .1, "-2.") is "-2.1" 124 27 125 Invalid step value 28 126 PASS stepUpExplicitBounds(null, null, "foo", "0") is "1" … … 32 130 PASS stepDownExplicitBounds(null, null, "0", "2") is "1" 33 131 PASS stepDownExplicitBounds(null, null, "-1", "3") is "2" 132 34 133 Step=any 35 134 PASS stepUpExplicitBounds(null, null, "any", "1") is "2" 36 135 PASS stepDownExplicitBounds(null, null, "any", "1") is "0" 136 37 137 Overflow/underflow 38 138 PASS stepUpExplicitBounds(null, "100", "1", "99") is "100" … … 47 147 PASS stepUpExplicitBounds(-100, 0, 1, -1, 2) is "0" 48 148 PASS stepUpExplicitBounds(null, null, "3.40282346e+38", "1", 2) is "0" 149 49 150 stepDown()/stepUp() for stepMismatch values 50 151 PASS stepUpExplicitBounds(null, null, 2, 1) is "4" 51 152 PASS stepUpExplicitBounds(0, null, 10, 9, 9) is "100" 52 153 PASS stepDownExplicitBounds(0, null, 10, 19) is "10" 154 53 155 value + step is <= max, but rounded result would be > max. 54 156 PASS stepUpExplicitBounds(null, 99, 10, 89) is "90" 157 55 158 Huge value and small step 56 159 PASS stepUpExplicitBounds(0, 1e38, 1, 1e38, 999) is "1e+38" 57 160 PASS stepDownExplicitBounds(0, 1e38, 1, 1e38, 999) is "1e+38" 161 58 162 Fractional numbers 59 163 PASS stepUpExplicitBounds(null, null, 0.33333333333333333, 0, 3) is "1" -
trunk/LayoutTests/fast/forms/range/range-stepup-stepdown-from-renderer.html
r155268 r191940 102 102 shouldBe('stepUpExplicitBounds(null, null, "foo", "foo")', '"51"'); 103 103 shouldBe('stepDownExplicitBounds(null, null, "foo", "foo")', '"49"'); 104 105 debug(''); 104 106 debug('Normal cases'); 105 107 shouldBe('stepUpExplicitBounds(null, null, null, "0")', '"1"'); … … 109 111 shouldBe('stepDownExplicitBounds("-100", null, null, "1", 2)', '"-1"'); 110 112 shouldBe('stepDownExplicitBounds("-100", null, null, "-1", -1)', '"0"'); 113 114 115 debug(''); 116 debug('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 126 shouldBe('stepUpExplicitBounds(-10, 10, 1, "0.1")', '"1"'); 127 shouldBe('stepUpExplicitBounds(-10, 10, 1, "0.2")', '"1"'); 128 shouldBe('stepUpExplicitBounds(-10, 10, 1, "1.0")', '"2"'); 129 shouldBe('stepUpExplicitBounds(-10, 10, 1, "1.1")', '"2"'); 130 shouldBe('stepUpExplicitBounds(-10, 10, 1, "1.2")', '"2"'); 131 shouldBe('stepUpExplicitBounds(-10, 10, 1, "2.0")', '"3"'); 132 133 // Same as above, but with negative numbers. 134 debug(''); 135 shouldBe('stepUpExplicitBounds(-10, 10, 1, "-0.1")', '"1"'); 136 shouldBe('stepUpExplicitBounds(-10, 10, 1, "-0.2")', '"1"'); 137 shouldBe('stepUpExplicitBounds(-10, 10, 1, "-1.0")', '"0"'); 138 shouldBe('stepUpExplicitBounds(-10, 10, 1, "-1.1")', '"0"'); 139 shouldBe('stepUpExplicitBounds(-10, 10, 1, "-1.2")', '"0"'); 140 shouldBe('stepUpExplicitBounds(-10, 10, 1, "-2.0")', '"-1"'); 141 142 // Same as above, but stepping down rather than up. 143 debug(''); 144 shouldBe('stepDownExplicitBounds(-10, 10, 1, "0.1")', '"-1"'); 145 shouldBe('stepDownExplicitBounds(-10, 10, 1, "0.2")', '"-1"'); 146 shouldBe('stepDownExplicitBounds(-10, 10, 1, "1.0")', '"0"'); 147 shouldBe('stepDownExplicitBounds(-10, 10, 1, "1.1")', '"0"'); 148 shouldBe('stepDownExplicitBounds(-10, 10, 1, "1.2")', '"0"'); 149 shouldBe('stepDownExplicitBounds(-10, 10, 1, "2.0")', '"1"'); 150 151 debug(''); 152 shouldBe('stepDownExplicitBounds(-10, 10, 1, "-0.1")', '"-1"'); 153 shouldBe('stepDownExplicitBounds(-10, 10, 1, "-0.2")', '"-1"'); 154 shouldBe('stepDownExplicitBounds(-10, 10, 1, "-1.0")', '"-2"'); 155 shouldBe('stepDownExplicitBounds(-10, 10, 1, "-1.1")', '"-2"'); 156 shouldBe('stepDownExplicitBounds(-10, 10, 1, "-1.2")', '"-2"'); 157 shouldBe('stepDownExplicitBounds(-10, 10, 1, "-2.0")', '"-3"'); 158 159 // Same as above, but with leading/trailing zeros removed. 160 debug(''); 161 shouldBe('stepUpExplicitBounds(-10, 10, 1, ".1")', '"1"'); 162 shouldBe('stepUpExplicitBounds(-10, 10, 1, ".2")', '"1"'); 163 shouldBe('stepUpExplicitBounds(-10, 10, 1, "1.")', '"2"'); 164 shouldBe('stepUpExplicitBounds(-10, 10, 1, "2.")', '"3"'); 165 166 debug(''); 167 shouldBe('stepUpExplicitBounds(-10, 10, 1, "-.1")', '"1"'); 168 shouldBe('stepUpExplicitBounds(-10, 10, 1, "-.2")', '"1"'); 169 shouldBe('stepUpExplicitBounds(-10, 10, 1, "-1.")', '"0"'); 170 shouldBe('stepUpExplicitBounds(-10, 10, 1, "-2.")', '"-1"'); 171 172 debug(''); 173 shouldBe('stepDownExplicitBounds(-10, 10, 1, ".1")', '"-1"'); 174 shouldBe('stepDownExplicitBounds(-10, 10, 1, ".2")', '"-1"'); 175 shouldBe('stepDownExplicitBounds(-10, 10, 1, "1.")', '"0"'); 176 shouldBe('stepDownExplicitBounds(-10, 10, 1, "2.")', '"1"'); 177 178 debug(''); 179 shouldBe('stepDownExplicitBounds(-10, 10, 1, "-.1")', '"-1"'); 180 shouldBe('stepDownExplicitBounds(-10, 10, 1, "-.2")', '"-1"'); 181 shouldBe('stepDownExplicitBounds(-10, 10, 1, "-1.")', '"-2"'); 182 shouldBe('stepDownExplicitBounds(-10, 10, 1, "-2.")', '"-3"'); 183 184 // Same as above, but stepping by .1 rather than 1. 185 debug(''); 186 shouldBe('stepUpExplicitBounds(-10, 10, .1, "0.1")', '"0.2"'); 187 shouldBe('stepUpExplicitBounds(-10, 10, .1, "0.2")', '"0.3"'); 188 shouldBe('stepUpExplicitBounds(-10, 10, .1, "1.0")', '"1.1"'); 189 shouldBe('stepUpExplicitBounds(-10, 10, .1, "1.1")', '"1.2"'); 190 shouldBe('stepUpExplicitBounds(-10, 10, .1, "1.2")', '"1.3"'); 191 shouldBe('stepUpExplicitBounds(-10, 10, .1, "2.0")', '"2.1"'); 192 193 debug(''); 194 shouldBe('stepUpExplicitBounds(-10, 10, .1, "-0.1")', '"0"'); 195 shouldBe('stepUpExplicitBounds(-10, 10, .1, "-0.2")', '"-0.1"'); 196 shouldBe('stepUpExplicitBounds(-10, 10, .1, "-1.0")', '"-0.9"'); 197 shouldBe('stepUpExplicitBounds(-10, 10, .1, "-1.1")', '"-1"'); 198 shouldBe('stepUpExplicitBounds(-10, 10, .1, "-1.2")', '"-1.1"'); 199 shouldBe('stepUpExplicitBounds(-10, 10, .1, "-2.0")', '"-1.9"'); 200 201 debug(''); 202 shouldBe('stepDownExplicitBounds(-10, 10, .1, "0.1")', '"0"'); 203 shouldBe('stepDownExplicitBounds(-10, 10, .1, "0.2")', '"0.1"'); 204 shouldBe('stepDownExplicitBounds(-10, 10, .1, "1.0")', '"0.9"'); 205 shouldBe('stepDownExplicitBounds(-10, 10, .1, "1.1")', '"1"'); 206 shouldBe('stepDownExplicitBounds(-10, 10, .1, "1.2")', '"1.1"'); 207 shouldBe('stepDownExplicitBounds(-10, 10, .1, "2.0")', '"1.9"'); 208 209 debug(''); 210 shouldBe('stepDownExplicitBounds(-10, 10, .1, "-0.1")', '"-0.2"'); 211 shouldBe('stepDownExplicitBounds(-10, 10, .1, "-0.2")', '"-0.3"'); 212 shouldBe('stepDownExplicitBounds(-10, 10, .1, "-1.0")', '"-1.1"'); 213 shouldBe('stepDownExplicitBounds(-10, 10, .1, "-1.1")', '"-1.2"'); 214 shouldBe('stepDownExplicitBounds(-10, 10, .1, "-1.2")', '"-1.3"'); 215 shouldBe('stepDownExplicitBounds(-10, 10, .1, "-2.0")', '"-2.1"'); 216 217 debug(''); 218 shouldBe('stepUpExplicitBounds(-10, 10, .1, ".1")', '"0.2"'); 219 shouldBe('stepUpExplicitBounds(-10, 10, .1, ".2")', '"0.3"'); 220 shouldBe('stepUpExplicitBounds(-10, 10, .1, "1.")', '"1.1"'); 221 shouldBe('stepUpExplicitBounds(-10, 10, .1, "2.")', '"2.1"'); 222 223 debug(''); 224 shouldBe('stepUpExplicitBounds(-10, 10, .1, "-.1")', '"0"'); 225 shouldBe('stepUpExplicitBounds(-10, 10, .1, "-.2")', '"-0.1"'); 226 shouldBe('stepUpExplicitBounds(-10, 10, .1, "-1.")', '"-0.9"'); 227 shouldBe('stepUpExplicitBounds(-10, 10, .1, "-2.")', '"-1.9"'); 228 229 shouldBe('stepDownExplicitBounds(-10, 10, .1, ".1")', '"0"'); 230 shouldBe('stepDownExplicitBounds(-10, 10, .1, ".2")', '"0.1"'); 231 shouldBe('stepDownExplicitBounds(-10, 10, .1, "1.")', '"0.9"'); 232 shouldBe('stepDownExplicitBounds(-10, 10, .1, "2.")', '"1.9"'); 233 234 debug(''); 235 shouldBe('stepDownExplicitBounds(-10, 10, .1, "-.1")', '"-0.2"'); 236 shouldBe('stepDownExplicitBounds(-10, 10, .1, "-.2")', '"-0.3"'); 237 shouldBe('stepDownExplicitBounds(-10, 10, .1, "-1.")', '"-1.1"'); 238 shouldBe('stepDownExplicitBounds(-10, 10, .1, "-2.")', '"-2.1"'); 239 240 debug(''); 111 241 debug('Invalid step value'); 112 242 shouldBe('stepUpExplicitBounds(null, null, "foo", "0")', '"1"'); … … 116 246 shouldBe('stepDownExplicitBounds(null, null, "0", "2")', '"1"'); 117 247 shouldBe('stepDownExplicitBounds(null, null, "-1", "3")', '"2"'); 248 249 debug(''); 118 250 debug('Step=any'); 119 251 shouldBe('stepUpExplicitBounds(null, null, "any", "1")', '"2"'); 120 252 shouldBe('stepDownExplicitBounds(null, null, "any", "1")', '"0"'); 253 254 debug(''); 121 255 debug('Overflow/underflow'); 122 256 shouldBe('stepUpExplicitBounds(null, "100", "1", "99")', '"100"'); … … 131 265 shouldBe('stepUpExplicitBounds(-100, 0, 1, -1, 2)', '"0"'); 132 266 shouldBe('stepUpExplicitBounds(null, null, "3.40282346e+38", "1", 2)', '"0"'); 267 268 debug(''); 133 269 debug('stepDown()/stepUp() for stepMismatch values'); 134 270 shouldBe('stepUpExplicitBounds(null, null, 2, 1)', '"4"'); 135 271 shouldBe('stepUpExplicitBounds(0, null, 10, 9, 9)', '"100"'); 136 272 shouldBe('stepDownExplicitBounds(0, null, 10, 19)', '"10"'); 273 274 debug(''); 137 275 debug('value + step is <= max, but rounded result would be > max.'); 138 276 shouldBe('stepUpExplicitBounds(null, 99, 10, 89)', '"90"'); 277 278 debug(''); 139 279 debug('Huge value and small step'); 140 280 shouldBe('stepUpExplicitBounds(0, 1e38, 1, 1e38, 999)', '"1e+38"'); 141 281 shouldBe('stepDownExplicitBounds(0, 1e38, 1, 1e38, 999)', '"1e+38"'); 282 283 debug(''); 142 284 debug('Fractional numbers'); 143 285 shouldBe('stepUpExplicitBounds(null, null, 0.33333333333333333, 0, 3)', '"1"'); -
trunk/LayoutTests/fast/forms/range/range-stepup-stepdown.html
r155268 r191940 64 64 shouldBe('stepUpExplicitBounds(null, null, null, "")', '"51"'); 65 65 shouldBe('stepDownExplicitBounds(null, null, null, "")', '"49"'); 66 67 debug(''); 66 68 debug('Non-number arguments (stepCount)'); 67 69 shouldBe('stepUpExplicitBounds(null, null, null, "0", "0")', '"0"'); … … 71 73 shouldBe('stepUpExplicitBounds(null, null, null, "0", null)', '"0"'); 72 74 shouldBe('stepDownExplicitBounds(null, null, null, "0", null)', '"0"'); 75 76 debug(''); 73 77 debug('Normal cases'); 74 78 shouldBe('stepUpExplicitBounds(null, null, null, "0")', '"1"'); … … 78 82 shouldBe('stepDownExplicitBounds("-100", null, null, "1", 2)', '"-1"'); 79 83 shouldBe('stepDownExplicitBounds("-100", null, null, "-1", -1)', '"0"'); 84 85 debug(''); 86 debug('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 96 shouldBe('stepUpExplicitBounds(-10, 10, 1, "0.1")', '"1"'); 97 shouldBe('stepUpExplicitBounds(-10, 10, 1, "0.2")', '"1"'); 98 shouldBe('stepUpExplicitBounds(-10, 10, 1, "1.0")', '"2"'); 99 shouldBe('stepUpExplicitBounds(-10, 10, 1, "1.1")', '"2"'); 100 shouldBe('stepUpExplicitBounds(-10, 10, 1, "1.2")', '"2"'); 101 shouldBe('stepUpExplicitBounds(-10, 10, 1, "2.0")', '"3"'); 102 103 // Same as above, but with negative numbers. 104 debug(''); 105 shouldBe('stepUpExplicitBounds(-10, 10, 1, "-0.1")', '"1"'); 106 shouldBe('stepUpExplicitBounds(-10, 10, 1, "-0.2")', '"1"'); 107 shouldBe('stepUpExplicitBounds(-10, 10, 1, "-1.0")', '"0"'); 108 shouldBe('stepUpExplicitBounds(-10, 10, 1, "-1.1")', '"0"'); 109 shouldBe('stepUpExplicitBounds(-10, 10, 1, "-1.2")', '"0"'); 110 shouldBe('stepUpExplicitBounds(-10, 10, 1, "-2.0")', '"-1"'); 111 112 // Same as above, but stepping down rather than up. 113 debug(''); 114 shouldBe('stepDownExplicitBounds(-10, 10, 1, "0.1")', '"-1"'); 115 shouldBe('stepDownExplicitBounds(-10, 10, 1, "0.2")', '"-1"'); 116 shouldBe('stepDownExplicitBounds(-10, 10, 1, "1.0")', '"0"'); 117 shouldBe('stepDownExplicitBounds(-10, 10, 1, "1.1")', '"0"'); 118 shouldBe('stepDownExplicitBounds(-10, 10, 1, "1.2")', '"0"'); 119 shouldBe('stepDownExplicitBounds(-10, 10, 1, "2.0")', '"1"'); 120 121 debug(''); 122 shouldBe('stepDownExplicitBounds(-10, 10, 1, "-0.1")', '"-1"'); 123 shouldBe('stepDownExplicitBounds(-10, 10, 1, "-0.2")', '"-1"'); 124 shouldBe('stepDownExplicitBounds(-10, 10, 1, "-1.0")', '"-2"'); 125 shouldBe('stepDownExplicitBounds(-10, 10, 1, "-1.1")', '"-2"'); 126 shouldBe('stepDownExplicitBounds(-10, 10, 1, "-1.2")', '"-2"'); 127 shouldBe('stepDownExplicitBounds(-10, 10, 1, "-2.0")', '"-3"'); 128 129 // Same as above, but with leading/trailing zeros removed. 130 debug(''); 131 shouldBe('stepUpExplicitBounds(-10, 10, 1, ".1")', '"1"'); 132 shouldBe('stepUpExplicitBounds(-10, 10, 1, ".2")', '"1"'); 133 shouldBe('stepUpExplicitBounds(-10, 10, 1, "1.")', '"2"'); 134 shouldBe('stepUpExplicitBounds(-10, 10, 1, "2.")', '"3"'); 135 136 debug(''); 137 shouldBe('stepUpExplicitBounds(-10, 10, 1, "-.1")', '"1"'); 138 shouldBe('stepUpExplicitBounds(-10, 10, 1, "-.2")', '"1"'); 139 shouldBe('stepUpExplicitBounds(-10, 10, 1, "-1.")', '"0"'); 140 shouldBe('stepUpExplicitBounds(-10, 10, 1, "-2.")', '"-1"'); 141 142 debug(''); 143 shouldBe('stepDownExplicitBounds(-10, 10, 1, ".1")', '"-1"'); 144 shouldBe('stepDownExplicitBounds(-10, 10, 1, ".2")', '"-1"'); 145 shouldBe('stepDownExplicitBounds(-10, 10, 1, "1.")', '"0"'); 146 shouldBe('stepDownExplicitBounds(-10, 10, 1, "2.")', '"1"'); 147 148 debug(''); 149 shouldBe('stepDownExplicitBounds(-10, 10, 1, "-.1")', '"-1"'); 150 shouldBe('stepDownExplicitBounds(-10, 10, 1, "-.2")', '"-1"'); 151 shouldBe('stepDownExplicitBounds(-10, 10, 1, "-1.")', '"-2"'); 152 shouldBe('stepDownExplicitBounds(-10, 10, 1, "-2.")', '"-3"'); 153 154 // Same as above, but stepping by .1 rather than 1. 155 debug(''); 156 shouldBe('stepUpExplicitBounds(-10, 10, .1, "0.1")', '"0.2"'); 157 shouldBe('stepUpExplicitBounds(-10, 10, .1, "0.2")', '"0.3"'); 158 shouldBe('stepUpExplicitBounds(-10, 10, .1, "1.0")', '"1.1"'); 159 shouldBe('stepUpExplicitBounds(-10, 10, .1, "1.1")', '"1.2"'); 160 shouldBe('stepUpExplicitBounds(-10, 10, .1, "1.2")', '"1.3"'); 161 shouldBe('stepUpExplicitBounds(-10, 10, .1, "2.0")', '"2.1"'); 162 163 debug(''); 164 shouldBe('stepUpExplicitBounds(-10, 10, .1, "-0.1")', '"0"'); 165 shouldBe('stepUpExplicitBounds(-10, 10, .1, "-0.2")', '"-0.1"'); 166 shouldBe('stepUpExplicitBounds(-10, 10, .1, "-1.0")', '"-0.9"'); 167 shouldBe('stepUpExplicitBounds(-10, 10, .1, "-1.1")', '"-1"'); 168 shouldBe('stepUpExplicitBounds(-10, 10, .1, "-1.2")', '"-1.1"'); 169 shouldBe('stepUpExplicitBounds(-10, 10, .1, "-2.0")', '"-1.9"'); 170 171 debug(''); 172 shouldBe('stepDownExplicitBounds(-10, 10, .1, "0.1")', '"0"'); 173 shouldBe('stepDownExplicitBounds(-10, 10, .1, "0.2")', '"0.1"'); 174 shouldBe('stepDownExplicitBounds(-10, 10, .1, "1.0")', '"0.9"'); 175 shouldBe('stepDownExplicitBounds(-10, 10, .1, "1.1")', '"1"'); 176 shouldBe('stepDownExplicitBounds(-10, 10, .1, "1.2")', '"1.1"'); 177 shouldBe('stepDownExplicitBounds(-10, 10, .1, "2.0")', '"1.9"'); 178 179 debug(''); 180 shouldBe('stepDownExplicitBounds(-10, 10, .1, "-0.1")', '"-0.2"'); 181 shouldBe('stepDownExplicitBounds(-10, 10, .1, "-0.2")', '"-0.3"'); 182 shouldBe('stepDownExplicitBounds(-10, 10, .1, "-1.0")', '"-1.1"'); 183 shouldBe('stepDownExplicitBounds(-10, 10, .1, "-1.1")', '"-1.2"'); 184 shouldBe('stepDownExplicitBounds(-10, 10, .1, "-1.2")', '"-1.3"'); 185 shouldBe('stepDownExplicitBounds(-10, 10, .1, "-2.0")', '"-2.1"'); 186 187 debug(''); 188 shouldBe('stepUpExplicitBounds(-10, 10, .1, ".1")', '"0.2"'); 189 shouldBe('stepUpExplicitBounds(-10, 10, .1, ".2")', '"0.3"'); 190 shouldBe('stepUpExplicitBounds(-10, 10, .1, "1.")', '"1.1"'); 191 shouldBe('stepUpExplicitBounds(-10, 10, .1, "2.")', '"2.1"'); 192 193 debug(''); 194 shouldBe('stepUpExplicitBounds(-10, 10, .1, "-.1")', '"0"'); 195 shouldBe('stepUpExplicitBounds(-10, 10, .1, "-.2")', '"-0.1"'); 196 shouldBe('stepUpExplicitBounds(-10, 10, .1, "-1.")', '"-0.9"'); 197 shouldBe('stepUpExplicitBounds(-10, 10, .1, "-2.")', '"-1.9"'); 198 199 debug(''); 200 shouldBe('stepDownExplicitBounds(-10, 10, .1, ".1")', '"0"'); 201 shouldBe('stepDownExplicitBounds(-10, 10, .1, ".2")', '"0.1"'); 202 shouldBe('stepDownExplicitBounds(-10, 10, .1, "1.")', '"0.9"'); 203 shouldBe('stepDownExplicitBounds(-10, 10, .1, "2.")', '"1.9"'); 204 205 debug(''); 206 shouldBe('stepDownExplicitBounds(-10, 10, .1, "-.1")', '"-0.2"'); 207 shouldBe('stepDownExplicitBounds(-10, 10, .1, "-.2")', '"-0.3"'); 208 shouldBe('stepDownExplicitBounds(-10, 10, .1, "-1.")', '"-1.1"'); 209 shouldBe('stepDownExplicitBounds(-10, 10, .1, "-2.")', '"-2.1"'); 210 211 debug(''); 80 212 debug('Extra arguments'); 81 213 shouldBe('setInputAttributes(null, null, null, "0"); input.stepUp(1,2); input.value', '"1"'); 82 214 shouldBe('setInputAttributes(null, null, null, "1"); input.stepDown(1,3); input.value', '"0"'); 215 216 debug(''); 83 217 debug('Invalid step value'); 84 218 shouldBe('stepUpExplicitBounds(null, null, "foo", "0")', '"1"'); … … 88 222 shouldBe('stepDownExplicitBounds(null, null, "0", "2")', '"1"'); 89 223 shouldBe('stepDownExplicitBounds(null, null, "-1", "3")', '"2"'); 224 225 debug(''); 90 226 debug('Step=any'); 91 227 shouldThrow('stepUpExplicitBounds(null, null, "any", "1")', invalidStateErr); 92 228 shouldThrow('stepDownExplicitBounds(null, null, "any", "1")', invalidStateErr); 229 230 debug(''); 93 231 debug('Overflow/underflow'); 94 232 shouldBe('stepUpExplicitBounds(null, "100", "1", "99")', '"100"'); … … 108 246 shouldBe('input.value', '"-1"'); 109 247 shouldThrow('stepUpExplicitBounds(null, null, "3.40282346e+38", "1", "2")', invalidStateErr); 248 249 debug(''); 110 250 debug('stepDown()/stepUp() for stepMismatch values'); 111 251 shouldBe('stepUpExplicitBounds(null, null, 2, 1)', '"4"'); … … 113 253 shouldBe('stepUpExplicitBounds(0, null, 10, 9, 9)', '"100"'); 114 254 shouldBe('stepDownExplicitBounds(0, null, 10, 19)', '"10"'); 255 256 debug(''); 115 257 debug('value + step is <= max, but rounded result would be > max.'); 116 258 shouldThrow('stepUpExplicitBounds(null, 99, 10, 89)', invalidStateErr); 259 260 debug(''); 117 261 debug('Huge value and small step'); 118 262 shouldBe('stepUpExplicitBounds(0, 1e38, 1, 1e38, 999999)', '"1e+38"'); 119 263 shouldBe('stepDownExplicitBounds(0, 1e38, 1, 1e38, 999999)', '"1e+38"'); 264 265 debug(''); 120 266 debug('Fractional numbers'); 121 267 shouldBe('stepUpExplicitBounds(null, null, 0.33333333333333333, 0, 3)', '"1"'); … … 128 274 shouldBe('stepDownExplicitBounds(null, null, 0.1, 1, 8)', '"0.2"'); 129 275 shouldBe('stepDownExplicitBounds(null, null, 0.1, 1)', '"0.9"'); 276 277 debug(''); 130 278 </script> 131 279 <script src="../../../resources/js-test-post.js"></script> -
trunk/Source/WebCore/ChangeLog
r191938 r191940 1 2015-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 1 30 2015-11-02 Jiewen Tan <jiewen_tan@apple.com> 2 31 -
trunk/Source/WebCore/html/InputType.cpp
r191876 r191940 1063 1063 // - The value should be the larger matched value nearest to 0 if n > 0 1064 1064 // e.g. <input type=number min=-100 step=3> -> 2 1065 // - The value should be the smal er matched value nearest to 0 if n < 01065 // - The value should be the smaller matched value nearest to 0 if n < 0 1066 1066 // e.g. <input type=number min=-100 step=3> -> -1 1067 1067 // As for date/datetime-local/month/time/week types, the current value is assumed as "the current local date/time". … … 1078 1078 // - The value should be the larger matched value nearest to 0 if n > 0 1079 1079 // e.g. <input type=number value=3 min=-100 step=3> -> 5 1080 // - The value should be the smal er matched value nearest to 0 if n < 01080 // - The value should be the smaller matched value nearest to 0 if n < 0 1081 1081 // e.g. <input type=number value=3 min=-100 step=3> -> 2 1082 1082 // -
trunk/Source/WebCore/platform/Decimal.cpp
r162907 r191940 825 825 826 826 HandleCharAndBreak('0', StateZero); 827 HandleCharAndBreak('.', StateDot); 827 828 return nan(); 828 829 … … 875 876 return zero(sign); 876 877 877 if (state == StateDigit || state == State EDigit || state == StateDotDigit) {878 if (state == StateDigit || state == StateDot || state == StateDotDigit || state == StateEDigit) { 878 879 int resultExponent = exponent * (exponentSign == Negative ? -1 : 1) - numberOfDigitsAfterDot + numberOfExtraDigits; 879 880 if (resultExponent < ExponentMin)
Note: See TracChangeset
for help on using the changeset viewer.