Changeset 56242 in webkit
- Timestamp:
- Mar 19, 2010 9:16:16 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r56240 r56242 1 2010-03-19 Joseph Pecoraro <joepeck@webkit.org> 2 3 Reviewed by David Kilzer. 4 5 <input type=range> does not validate correctly without a renderer and the tests are incorrect 6 https://bugs.webkit.org/show_bug.cgi?id=36259 7 8 Setting value attribute on an <input type=range> to an out-of-range value fires oninput 9 https://bugs.webkit.org/show_bug.cgi?id=16990 10 11 When setting the range element's value, overflows and underflows are 12 automatically sanitized to valid values. Fixed the behavior and removed 13 tests that were testing for improper behavior. 14 15 * fast/forms/ValidityState-rangeOverflow-expected.txt: 16 * fast/forms/ValidityState-rangeUnderflow-expected.txt: 17 * fast/forms/input-stepup-stepdown-expected.txt: 18 * fast/forms/script-tests/ValidityState-rangeOverflow.js: 19 * fast/forms/script-tests/ValidityState-rangeUnderflow.js: 20 * fast/forms/script-tests/input-stepup-stepdown.js: 21 * fast/forms/script-tests/validationMessage.js: 22 * fast/forms/validationMessage-expected.txt: 23 24 Added test verifying that bug 16990 was fixed as well. 25 26 * fast/forms/range-input-dynamic-oninput-expected.txt: Added. 27 * fast/forms/range-input-dynamic-oninput.html Added. 28 29 Improved test because handling of this case changed. 30 31 * fast/forms/range-reset-expected.txt: 32 * fast/forms/range-reset.html: 33 1 34 2010-03-19 Darin Fisher <darin@chromium.org> 2 35 -
trunk/LayoutTests/fast/forms/ValidityState-rangeOverflow-expected.txt
r54271 r56242 74 74 PASS The value "101" overflows the maximum value "100". 75 75 76 Type=range77 PASS The value "99" doesn't overflow the maximum value "100".78 PASS The value "-101" doesn't overflow the maximum value "-100".79 PASS The value "99" doesn't overflow the maximum value "1E+2".80 PASS The value "0.99" doesn't overflow the maximum value "1.00".81 PASS The value "abc" doesn't overflow the maximum value "100".82 PASS The value "" doesn't overflow the maximum value "-1".83 PASS The value "0.999999999999999999999999999999999999999999" doesn't overflow the maximum value "0.999999999999999999999999999999999999999998".84 PASS The value "101" doesn't overflow the maximum value "100".85 PASS The value "101" overflows the maximum value "100".86 PASS The value "-99" overflows the maximum value "-100".87 PASS The value "101" overflows the maximum value "1E+2".88 PASS The value "101" overflows the maximum value "".89 PASS The value "101" overflows the maximum value "xxx".90 91 76 Type=time 92 77 PASS The value "13:16" doesn't overflow the maximum value "". -
trunk/LayoutTests/fast/forms/ValidityState-rangeUnderflow-expected.txt
r54271 r56242 74 74 PASS The value "101" undeflows the minimum value "200". 75 75 76 Type=range77 PASS The value "101" doesn't underflow the minimum value "100".78 PASS The value "-99" doesn't underflow the minimum value "-100".79 PASS The value "101" doesn't underflow the minimum value "1E+2".80 PASS The value "1.01" doesn't underflow the minimum value "1.00".81 PASS The value "abc" doesn't underflow the minimum value "100".82 PASS The value "" doesn't underflow the minimum value "1".83 PASS The value "0.999999999999999999999999999999999999999998" doesn't underflow the minimum value "0.999999999999999999999999999999999999999999".84 PASS The value "101" doesn't underflow the minimum value "100".85 PASS The value "99" undeflows the minimum value "100".86 PASS The value "-101" undeflows the minimum value "-100".87 PASS The value "99" undeflows the minimum value "1E+2".88 PASS The value "-1" undeflows the minimum value "".89 PASS The value "-1" undeflows the minimum value "xxx".90 91 76 Type=time 92 77 PASS The value "13:16" doesn't underflow the minimum value "". -
trunk/LayoutTests/fast/forms/input-stepup-stepdown-expected.txt
r55423 r56242 168 168 169 169 Range type 170 Invalid value 171 PASS stepUp("", null, null) threw exception Error: INVALID_STATE_ERR: DOM Exception 11. 172 PASS stepDown("", null, null) threw exception Error: INVALID_STATE_ERR: DOM Exception 11. 173 Non-number arguments 174 PASS stepUp("0", null, null, "0") is "0" 175 PASS stepDown("0", null, null, "0") is "0" 176 PASS stepUp("0", null, null, "foo") is "0" 177 PASS stepDown("0", null, null, "foo") is "0" 178 PASS stepUp("0", null, null, null) is "0" 179 PASS stepDown("0", null, null, null) is "0" 180 Normal cases 181 PASS stepUp("0", null, null) is "1" 182 PASS stepUp("1", null, null, 2) is "3" 183 PASS stepUp("3", null, null, -1) is "2" 184 PASS stepDown("2", null, "-100") is "1" 185 PASS stepDown("1", null, "-100", 2) is "-1" 186 PASS stepDown("-1", null, "-100", -1) is "0" 170 function arguments are (min, max, step, value, [stepCount]) 171 Using the default values 172 PASS stepUpExplicitBounds(null, null, null, "") is "51" 173 PASS stepDownExplicitBounds(null, null, null, "") is "49" 174 Non-number arguments (stepCount) 175 PASS stepUpExplicitBounds(null, null, null, "0", "0") is "0" 176 PASS stepDownExplicitBounds(null, null, null, "0", "0") is "0" 177 PASS stepUpExplicitBounds(null, null, null, "0", "foo") is "0" 178 PASS stepDownExplicitBounds(null, null, null, "0", "foo") is "0" 179 PASS stepUpExplicitBounds(null, null, null, "0", null) is "0" 180 PASS stepDownExplicitBounds(null, null, null, "0", null) is "0" 181 Normal cases 182 PASS stepUpExplicitBounds(null, null, null, "0") is "1" 183 PASS stepUpExplicitBounds(null, null, null, "1", 2) is "3" 184 PASS stepUpExplicitBounds(null, null, null, "3", -1) is "2" 185 PASS stepDownExplicitBounds("-100", null, null, "2") is "1" 186 PASS stepDownExplicitBounds("-100", null, null, "1", 2) is "-1" 187 PASS stepDownExplicitBounds("-100", null, null, "-1", -1) is "0" 187 188 Extra arguments 188 PASS input.value = "0"; input.min = null; input.step = null; input.stepUp(1,2); input.value is "1"189 PASS input.value = "1"; input.stepDown(1,3); input.value is "0"189 PASS setInputAttributes(null, null, null, "0"); input.stepUp(1,2); input.value is "1" 190 PASS setInputAttributes(null, null, null, "1"); input.stepDown(1,3); input.value is "0" 190 191 Invalid step value 191 PASS stepUp("0", "foo", null) is "1" 192 PASS stepUp("1", "0", null) is "2" 193 PASS stepUp("2", "-1", null) is "3" 194 Step=any 195 PASS stepUp("0", "any", null) threw exception Error: INVALID_STATE_ERR: DOM Exception 11. 196 PASS stepDown("0", "any", null) threw exception Error: INVALID_STATE_ERR: DOM Exception 11. 197 Overflow/underflow 198 PASS stepDown("1", "1", "0") is "0" 199 PASS stepDown("0", "1", "0") threw exception Error: INVALID_STATE_ERR: DOM Exception 11. 200 PASS stepDown("1", "1", "0", 2) threw exception Error: INVALID_STATE_ERR: DOM Exception 11. 192 PASS stepUpExplicitBounds(null, null, "foo", "0") is "1" 193 PASS stepUpExplicitBounds(null, null, "0", "1") is "2" 194 PASS stepUpExplicitBounds(null, null, "-1", "2") is "3" 195 PASS stepDownExplicitBounds(null, null, "foo", "1") is "0" 196 PASS stepDownExplicitBounds(null, null, "0", "2") is "1" 197 PASS stepDownExplicitBounds(null, null, "-1", "3") is "2" 198 Step=any 199 PASS stepUpExplicitBounds(null, null, "any", "1") threw exception Error: INVALID_STATE_ERR: DOM Exception 11. 200 PASS stepDownExplicitBounds(null, null, "any", "1") threw exception Error: INVALID_STATE_ERR: DOM Exception 11. 201 Overflow/underflow 202 PASS stepUpExplicitBounds(null, "100", "1", "99") is "100" 203 PASS stepUpExplicitBounds(null, "100", "1", "100") threw exception Error: INVALID_STATE_ERR: DOM Exception 11. 204 PASS input.value is "100" 205 PASS stepUpExplicitBounds(null, "100", "1", "99", "2") threw exception Error: INVALID_STATE_ERR: DOM Exception 11. 206 PASS input.value is "99" 207 PASS stepDownExplicitBounds("0", null, "1", "1") is "0" 208 PASS stepDownExplicitBounds("0", null, "1", "0") threw exception Error: INVALID_STATE_ERR: DOM Exception 11. 209 PASS input.value is "0" 210 PASS stepDownExplicitBounds("0", null, "1", "1", "2") threw exception Error: INVALID_STATE_ERR: DOM Exception 11. 201 211 PASS input.value is "1" 202 PASS stepDown ("1", "1.7976931348623156e+308", "", 2) threw exception Error: INVALID_STATE_ERR: DOM Exception 11.203 PASS input.min = "-100"; stepUp("-1", "1", "0") is "0"204 PASS stepUp ("0", "1", "0") threw exception Error: INVALID_STATE_ERR: DOM Exception 11.205 PASS input.min = "-100"; stepUp("-1", "1", "0", 2) threw exception Error: INVALID_STATE_ERR: DOM Exception 11.212 PASS stepDownExplicitBounds(null, null, "1.7976931348623156e+308", "1", "2") threw exception Error: INVALID_STATE_ERR: DOM Exception 11. 213 PASS stepUpExplicitBounds(-100, 0, 1, -1) is "0" 214 PASS stepUpExplicitBounds(null, 0, 1, 0) threw exception Error: INVALID_STATE_ERR: DOM Exception 11. 215 PASS stepUpExplicitBounds(-100, 0, 1, -1, 2) threw exception Error: INVALID_STATE_ERR: DOM Exception 11. 206 216 PASS input.value is "-1" 207 PASS stepUp ("1", "1.7976931348623156e+308", "", 2) threw exception Error: INVALID_STATE_ERR: DOM Exception 11.217 PASS stepUpExplicitBounds(null, null, "1.7976931348623156e+308", "1", "2") threw exception Error: INVALID_STATE_ERR: DOM Exception 11. 208 218 stepDown()/stepUp() for stepMismatch values 209 PASS stepUp ("1", "2", "") is "4"219 PASS stepUpExplicitBounds(null, null, 2, 1) is "4" 210 220 PASS input.stepDown(); input.value is "2" 211 PASS input.min = "0"; stepUp("9", "10", "", 9) is "100" 212 PASS stepDown("19", "10", "0") is "10" 213 PASS stepUp("89", "10", "99") threw exception Error: INVALID_STATE_ERR: DOM Exception 11. 221 PASS stepUpExplicitBounds(0, null, 10, 9, 9) is "100" 222 PASS stepDownExplicitBounds(0, null, 10, 19) is "10" 223 value + step is <= max, but rounded result would be > max. 224 PASS stepUpExplicitBounds(null, 99, 10, 89) threw exception Error: INVALID_STATE_ERR: DOM Exception 11. 214 225 Huge value and small step 215 PASS input.min = "0"; stepUp("1e+308", "1", "1e+308", 999999) is "1e+308"216 PASS input.max = "1e+308"; input.min = "0"; input.step = "1"; input.value = "1e+308"; input.stepDown(999999); input.valueis "1e+308"226 PASS stepUpExplicitBounds(0, 1e308, 1, 1e308, 999999) is "1e+308" 227 PASS stepDownExplicitBounds(0, 1e308, 1, 1e308, 999999) is "1e+308" 217 228 Fractional numbers 218 PASS input.min = ""; stepUp("0", "0.33333333333333333", "", 3) is "1" 219 PASS stepUp("1", "0.1", "", 10) is "2" 229 PASS stepUpExplicitBounds(null, null, 0.33333333333333333, 0, 3) is "1" 230 PASS stepUpExplicitBounds(null, null, 0.1, 1) is "1.1" 231 PASS stepUpExplicitBounds(null, null, 0.1, 1, 8) is "1.8" 232 PASS stepUpExplicitBounds(null, null, 0.1, 1, 10) is "2" 220 233 PASS input.stepUp(); input.stepUp(); input.stepUp(); input.stepUp(); input.stepUp(); input.stepUp(); input.stepUp(); input.stepUp(); input.stepUp(); input.stepUp(); input.value is "3" 221 PASS input.min = "0"; stepUp("0", "0.003921568627450980", "1", 255) is "1"234 PASS stepUpExplicitBounds(0, 1, 0.003921568627450980, 0, 255) is "1" 222 235 PASS for (var i = 0; i < 255; i++) { input.stepDown(); }; input.value is "0" 236 PASS stepDownExplicitBounds(null, null, 0.1, 1, 8) is "0.2" 237 PASS stepDownExplicitBounds(null, null, 0.1, 1) is "0.9" 223 238 224 239 Time type -
trunk/LayoutTests/fast/forms/range-reset-expected.txt
r25701 r56242 4 4 5 5 6 6 7 Slider with explicit limits 7 8 Current value is: "30" 8 9 PASS slider.value is "80" 9 10 Resetting form 10 11 PASS slider.value is "30" 12 13 Slider with default limits, and no explicit value 14 Current value is: "50" 15 PASS slider.value is "80" 16 Resetting form 17 PASS slider.value is "50" 18 19 Slider with default limits, and a step value 20 Current value is: "60" 21 PASS slider.value is "80" 22 Resetting form 23 PASS slider.value is "60" 24 11 25 PASS successfullyParsed is true 12 26 -
trunk/LayoutTests/fast/forms/range-reset.html
r25701 r56242 7 7 <form> 8 8 <input id="slider" type="range" min="0" max="100" value="30"> 9 <input id="defaults" type="range"> 10 <input id="step" type="range" step="20"> 9 11 </form> 10 12 <div id="console"></div> … … 17 19 } 18 20 19 var slider = document.getElementById("slider"); 21 var slider; // Global needed for eval in shouldBe calls. 22 function testSliderReset(id) 23 { 24 slider = document.getElementById(id); 25 var originalValue = quoteNumber(slider.value); 26 debug("Current value is: " + originalValue); 20 27 21 var originalValue = quoteNumber(slider.value);22 debug("Current value is: " + originalValue);28 slider.value = 80; 29 shouldBe("slider.value", quoteNumber(80)); 23 30 24 slider.value = 80; 25 shouldBe("slider.value", quoteNumber(80)); 31 debug("Resetting form"); 32 document.forms[0].reset(); 33 shouldBe("slider.value", originalValue); 26 34 27 debug("Resetting form"); 28 document.forms[0].reset(); 29 shouldBe("slider.value", originalValue); 35 debug(""); 36 } 37 38 debug("Slider with explicit limits"); 39 testSliderReset("slider"); 40 41 debug("Slider with default limits, and no explicit value"); 42 testSliderReset("defaults"); 43 44 debug("Slider with default limits, and a step value"); 45 testSliderReset("step"); 30 46 31 47 var successfullyParsed = true; -
trunk/LayoutTests/fast/forms/script-tests/ValidityState-rangeOverflow.js
r54271 r56242 145 145 // ---------------------------------------------------------------- 146 146 debug(''); 147 debug('Type=range');148 input.type = 'range';149 input.min = '';150 checkNotOverflow('99', '100'); // Very normal case.151 checkNotOverflow('-101', '-100');152 checkNotOverflow('99', '1E+2');153 checkNotOverflow('0.99', '1.00');154 checkNotOverflow('abc', '100'); // Invalid value.155 checkNotOverflow('', '-1'); // No value.156 // The following case should be rangeOverflow==true ideally. But the "double" type doesn't have enough precision.157 checkNotOverflow('0.999999999999999999999999999999999999999999', '0.999999999999999999999999999999999999999998');158 input.min = '200'; // If min > max, max is reset to min.159 checkNotOverflow('101', '100');160 input.min = '';161 162 // Overflow cases163 checkOverflow('101', '100');164 input.min = '-200';165 checkOverflow('-99', '-100');166 input.min = '';167 checkOverflow('101', '1E+2');168 checkOverflow('101', ''); // No max.169 checkOverflow('101', 'xxx'); // Invalid max.170 171 // ----------------------------------------------------------------172 debug('');173 147 debug('Type=time'); 174 148 input.type = 'time'; -
trunk/LayoutTests/fast/forms/script-tests/ValidityState-rangeUnderflow.js
r54271 r56242 155 155 // ---------------------------------------------------------------- 156 156 debug(''); 157 debug('Type=range');158 input.type = 'range';159 input.max = '';160 // No underflow cases161 checkNotUnderflow('101', '100'); // Very normal case.162 checkNotUnderflow('-99', '-100');163 checkNotUnderflow('101', '1E+2');164 checkNotUnderflow('1.01', '1.00');165 checkNotUnderflow('abc', '100'); // Invalid value.166 checkNotUnderflow('', '1'); // No value.167 // The following case should be rangeUnderflow==true ideally. But the "double" type doesn't have enough precision.168 checkNotUnderflow('0.999999999999999999999999999999999999999998', '0.999999999999999999999999999999999999999999');169 input.max = '0'; // If min > max, max is reset to min and min is not changed.170 checkNotUnderflow('101', '100');171 input.max = '';172 173 // Underflow cases174 checkUnderflow('99', '100');175 checkUnderflow('-101', '-100');176 checkUnderflow('99', '1E+2');177 checkUnderflow('-1', ''); // No min.178 checkUnderflow('-1', 'xxx'); // Invalid min.179 180 // ----------------------------------------------------------------181 debug('');182 157 debug('Type=time'); 183 158 input.type = 'time'; -
trunk/LayoutTests/fast/forms/script-tests/input-stepup-stepdown.js
r55423 r56242 4 4 var invalidStateErr = '"Error: INVALID_STATE_ERR: DOM Exception 11"'; 5 5 6 function setInputAttributes(min, max, step, value) { 7 input.min = min; 8 input.max = max; 9 input.step = step; 10 input.value = value; 11 } 12 6 13 function stepUp(value, step, max, optionalStepCount) { 7 input.value = value; 8 input.step = step; 9 input.min = null; 10 input.max = max; 14 setInputAttributes(null, max, step, value); 11 15 if (typeof optionalStepCount != "undefined") 12 16 input.stepUp(optionalStepCount); … … 17 21 18 22 function stepDown(value, step, min, optionalStepCount) { 19 input.value = value; 20 input.step = step; 21 input.min = min; 22 input.max = null; 23 setInputAttributes(min, null, step, value); 23 24 if (typeof optionalStepCount != "undefined") 24 25 input.stepDown(optionalStepCount); 26 else 27 input.stepDown(); 28 return input.value; 29 } 30 31 // Range value gets automatically shifted based on bounds, 32 // So always set the min and max first to get expected behavior 33 34 function stepUpExplicitBounds(min, max, step, value, stepCount) { 35 setInputAttributes(min, max, step, value); 36 if (typeof stepCount !== 'undefined') 37 input.stepUp(stepCount); 38 else 39 input.stepUp(); 40 return input.value; 41 } 42 43 function stepDownExplicitBounds(min, max, step, value, stepCount) { 44 setInputAttributes(min, max, step, value); 45 if (typeof stepCount !== 'undefined') 46 input.stepDown(stepCount); 25 47 else 26 48 input.stepDown(); … … 204 226 debug('Range type'); 205 227 input.type = 'range'; 206 debug('Invalid value'); 207 shouldThrow('stepUp("", null, null)', invalidStateErr); 208 shouldThrow('stepDown("", null, null)', invalidStateErr); 209 debug('Non-number arguments'); 210 shouldBe('stepUp("0", null, null, "0")', '"0"'); 211 shouldBe('stepDown("0", null, null, "0")', '"0"'); 212 shouldBe('stepUp("0", null, null, "foo")', '"0"'); 213 shouldBe('stepDown("0", null, null, "foo")', '"0"'); 214 shouldBe('stepUp("0", null, null, null)', '"0"'); 215 shouldBe('stepDown("0", null, null, null)', '"0"'); 216 debug('Normal cases'); 217 shouldBe('stepUp("0", null, null)', '"1"'); 218 shouldBe('stepUp("1", null, null, 2)', '"3"'); 219 shouldBe('stepUp("3", null, null, -1)', '"2"'); 220 shouldBe('stepDown("2", null, "-100")', '"1"'); 221 shouldBe('stepDown("1", null, "-100", 2)', '"-1"'); 222 shouldBe('stepDown("-1", null, "-100", -1)', '"0"'); 228 debug('function arguments are (min, max, step, value, [stepCount])'); 229 debug('Using the default values'); 230 shouldBe('stepUpExplicitBounds(null, null, null, "")', '"51"'); 231 shouldBe('stepDownExplicitBounds(null, null, null, "")', '"49"'); 232 debug('Non-number arguments (stepCount)'); 233 shouldBe('stepUpExplicitBounds(null, null, null, "0", "0")', '"0"'); 234 shouldBe('stepDownExplicitBounds(null, null, null, "0", "0")', '"0"'); 235 shouldBe('stepUpExplicitBounds(null, null, null, "0", "foo")', '"0"'); 236 shouldBe('stepDownExplicitBounds(null, null, null, "0", "foo")', '"0"'); 237 shouldBe('stepUpExplicitBounds(null, null, null, "0", null)', '"0"'); 238 shouldBe('stepDownExplicitBounds(null, null, null, "0", null)', '"0"'); 239 debug('Normal cases'); 240 shouldBe('stepUpExplicitBounds(null, null, null, "0")', '"1"'); 241 shouldBe('stepUpExplicitBounds(null, null, null, "1", 2)', '"3"'); 242 shouldBe('stepUpExplicitBounds(null, null, null, "3", -1)', '"2"'); 243 shouldBe('stepDownExplicitBounds("-100", null, null, "2")', '"1"'); 244 shouldBe('stepDownExplicitBounds("-100", null, null, "1", 2)', '"-1"'); 245 shouldBe('stepDownExplicitBounds("-100", null, null, "-1", -1)', '"0"'); 223 246 debug('Extra arguments'); 224 shouldBe(' input.value = "0"; input.min = null; input.step = null; input.stepUp(1,2); input.value', '"1"');225 shouldBe(' input.value = "1"; input.stepDown(1,3); input.value', '"0"');247 shouldBe('setInputAttributes(null, null, null, "0"); input.stepUp(1,2); input.value', '"1"'); 248 shouldBe('setInputAttributes(null, null, null, "1"); input.stepDown(1,3); input.value', '"0"'); 226 249 debug('Invalid step value'); 227 shouldBe('stepUp("0", "foo", null)', '"1"'); 228 shouldBe('stepUp("1", "0", null)', '"2"'); 229 shouldBe('stepUp("2", "-1", null)', '"3"'); 230 debug('Step=any'); 231 shouldThrow('stepUp("0", "any", null)', invalidStateErr); 232 shouldThrow('stepDown("0", "any", null)', invalidStateErr); 233 debug('Overflow/underflow'); 234 shouldBe('stepDown("1", "1", "0")', '"0"'); 235 shouldThrow('stepDown("0", "1", "0")', invalidStateErr); 236 shouldThrow('stepDown("1", "1", "0", 2)', invalidStateErr); 250 shouldBe('stepUpExplicitBounds(null, null, "foo", "0")', '"1"'); 251 shouldBe('stepUpExplicitBounds(null, null, "0", "1")', '"2"'); 252 shouldBe('stepUpExplicitBounds(null, null, "-1", "2")', '"3"'); 253 shouldBe('stepDownExplicitBounds(null, null, "foo", "1")', '"0"'); 254 shouldBe('stepDownExplicitBounds(null, null, "0", "2")', '"1"'); 255 shouldBe('stepDownExplicitBounds(null, null, "-1", "3")', '"2"'); 256 debug('Step=any'); 257 shouldThrow('stepUpExplicitBounds(null, null, "any", "1")', invalidStateErr); 258 shouldThrow('stepDownExplicitBounds(null, null, "any", "1")', invalidStateErr); 259 debug('Overflow/underflow'); 260 shouldBe('stepUpExplicitBounds(null, "100", "1", "99")', '"100"'); 261 shouldThrow('stepUpExplicitBounds(null, "100", "1", "100")', invalidStateErr); 262 shouldBe('input.value', '"100"'); 263 shouldThrow('stepUpExplicitBounds(null, "100", "1", "99", "2")', invalidStateErr); 264 shouldBe('input.value', '"99"'); 265 shouldBe('stepDownExplicitBounds("0", null, "1", "1")', '"0"'); 266 shouldThrow('stepDownExplicitBounds("0", null, "1", "0")', invalidStateErr); 267 shouldBe('input.value', '"0"'); 268 shouldThrow('stepDownExplicitBounds("0", null, "1", "1", "2")', invalidStateErr); 237 269 shouldBe('input.value', '"1"'); 238 shouldThrow('stepDown ("1", "1.7976931348623156e+308", "", 2)', invalidStateErr);239 shouldBe(' input.min = "-100"; stepUp("-1", "1", "0")', '"0"');240 shouldThrow('stepUp ("0", "1", "0")', invalidStateErr);241 shouldThrow(' input.min = "-100"; stepUp("-1", "1", "0", 2)', invalidStateErr);270 shouldThrow('stepDownExplicitBounds(null, null, "1.7976931348623156e+308", "1", "2")', invalidStateErr); 271 shouldBe('stepUpExplicitBounds(-100, 0, 1, -1)', '"0"'); 272 shouldThrow('stepUpExplicitBounds(null, 0, 1, 0)', invalidStateErr); 273 shouldThrow('stepUpExplicitBounds(-100, 0, 1, -1, 2)', invalidStateErr); 242 274 shouldBe('input.value', '"-1"'); 243 shouldThrow('stepUp ("1", "1.7976931348623156e+308", "", 2)', invalidStateErr);275 shouldThrow('stepUpExplicitBounds(null, null, "1.7976931348623156e+308", "1", "2")', invalidStateErr); 244 276 debug('stepDown()/stepUp() for stepMismatch values'); 245 shouldBe('stepUp ("1", "2", "")', '"4"');277 shouldBe('stepUpExplicitBounds(null, null, 2, 1)', '"4"'); 246 278 shouldBe('input.stepDown(); input.value', '"2"'); 247 shouldBe(' input.min = "0"; stepUp("9", "10", "", 9)', '"100"');248 shouldBe('stepDown ("19", "10", "0")', '"10"');249 // value + step is <= max, but rounded result would be > max. 250 shouldThrow('stepUp ("89", "10", "99")', invalidStateErr);279 shouldBe('stepUpExplicitBounds(0, null, 10, 9, 9)', '"100"'); 280 shouldBe('stepDownExplicitBounds(0, null, 10, 19)', '"10"'); 281 debug('value + step is <= max, but rounded result would be > max.'); 282 shouldThrow('stepUpExplicitBounds(null, 99, 10, 89)', invalidStateErr); 251 283 debug('Huge value and small step'); 252 shouldBe(' input.min = "0"; stepUp("1e+308", "1", "1e+308", 999999)', '"1e+308"');253 shouldBe(' input.max = "1e+308"; input.min = "0"; input.step = "1"; input.value = "1e+308"; input.stepDown(999999); input.value', '"1e+308"');284 shouldBe('stepUpExplicitBounds(0, 1e308, 1, 1e308, 999999)', '"1e+308"'); 285 shouldBe('stepDownExplicitBounds(0, 1e308, 1, 1e308, 999999)', '"1e+308"'); 254 286 debug('Fractional numbers'); 255 shouldBe('input.min = ""; stepUp("0", "0.33333333333333333", "", 3)', '"1"'); 256 shouldBe('stepUp("1", "0.1", "", 10)', '"2"'); 287 shouldBe('stepUpExplicitBounds(null, null, 0.33333333333333333, 0, 3)', '"1"'); 288 shouldBe('stepUpExplicitBounds(null, null, 0.1, 1)', '"1.1"'); 289 shouldBe('stepUpExplicitBounds(null, null, 0.1, 1, 8)', '"1.8"'); 290 shouldBe('stepUpExplicitBounds(null, null, 0.1, 1, 10)', '"2"'); 257 291 shouldBe('input.stepUp(); input.stepUp(); input.stepUp(); input.stepUp(); input.stepUp(); input.stepUp(); input.stepUp(); input.stepUp(); input.stepUp(); input.stepUp(); input.value', '"3"'); 258 shouldBe(' input.min = "0"; stepUp("0", "0.003921568627450980", "1", 255)', '"1"');292 shouldBe('stepUpExplicitBounds(0, 1, 0.003921568627450980, 0, 255)', '"1"'); 259 293 shouldBe('for (var i = 0; i < 255; i++) { input.stepDown(); }; input.value', '"0"'); 294 shouldBe('stepDownExplicitBounds(null, null, 0.1, 1, 8)', '"0.2"'); 295 shouldBe('stepDownExplicitBounds(null, null, 0.1, 1)', '"0.9"'); 260 296 261 297 debug(''); -
trunk/LayoutTests/fast/forms/script-tests/validationMessage.js
r51172 r56242 33 33 shouldBe("emailInput.validationMessage", "'type mismatch'"); 34 34 35 // A "ranged" input for "range underflow" flag36 var underInput = document.createElement("input");37 underInput.name = "underInput";38 underInput.type = "range";39 underInput.min = "2";40 underInput.value = "1";41 form.appendChild(underInput);42 shouldBe("underInput.validationMessage", "'range underflow'");43 44 // A "ranged" input for "range overflow" flag45 var overInput = document.createElement("input");46 overInput.name = "overInput";47 overInput.type = "range";48 overInput.max = "2";49 overInput.value = "3";50 form.appendChild(overInput);51 shouldBe("overInput.validationMessage", "'range overflow'");52 53 35 // A button can't be valited and, thus, has a blank validationMessage 54 36 var but = document.createElement("button"); -
trunk/LayoutTests/fast/forms/validationMessage-expected.txt
r51172 r56242 8 8 PASS requiredTextArea.validationMessage is 'value missing' 9 9 PASS emailInput.validationMessage is 'type mismatch' 10 PASS underInput.validationMessage is 'range underflow'11 PASS overInput.validationMessage is 'range overflow'12 10 PASS but.validationMessage is '' 13 11 PASS anoninput.validationMessage is '' -
trunk/WebCore/ChangeLog
r56241 r56242 1 2010-03-19 Joseph Pecoraro <joepeck@webkit.org> 2 3 Reviewed by David Kilzer. 4 5 <input type=range> does not validate correctly without a renderer and the tests are incorrect 6 https://bugs.webkit.org/show_bug.cgi?id=36259 7 8 Setting value attribute on an <input type=range> to an out-of-range value fires oninput 9 https://bugs.webkit.org/show_bug.cgi?id=16990 10 11 Part 2 of 2: When setting the range element's value, overflows and underflows 12 are automatically sanitized to valid values. Moved the general case 13 sanitization code out of the Renderer into HTMLInputElement::sanitizeValue. 14 15 * html/HTMLInputElement.cpp: 16 (WebCore::HTMLInputElement::value): when getting a default value on reset() ensure the defaultValue is provided 17 (WebCore::HTMLInputElement::sanitizeValue): clamp the value within the max/min/step range constraints 18 * html/StepRange.cpp: 19 (WebCore::StepRange::StepRange): allow const element in the constructor 20 (WebCore::StepRange::clampValue): clamp from a String value 21 * html/StepRange.h: 22 (WebCore::StepRange::defaultValue): easy calculation of the default value for max/min/step range constraints 23 * rendering/RenderSlider.cpp: 24 (WebCore::RenderSlider::updateFromElement): no longer handle the general case sanitization in the renderer 25 1 26 2010-03-19 Joseph Pecoraro <joepeck@webkit.org> 2 27 -
trunk/WebCore/html/HTMLInputElement.cpp
r56174 r56242 3 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 4 4 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 6 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 7 7 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org) … … 61 61 #include "RenderTextControlSingleLine.h" 62 62 #include "RenderTheme.h" 63 #include "StepRange.h" 63 64 #include "StringHash.h" 64 65 #include "TextEvent.h" … … 310 311 case MONTH: 311 312 case NUMBER: 312 case RANGE:313 313 case TIME: 314 314 case WEEK: { … … 316 316 return isfinite(doubleValue) && doubleValue < minimum(); 317 317 } 318 case RANGE: // Guaranteed by sanitization. 319 ASSERT(parseToDouble(value(), nan) >= minimum()); 318 320 case BUTTON: 319 321 case CHECKBOX: … … 346 348 case MONTH: 347 349 case NUMBER: 348 case RANGE:349 350 case TIME: 350 351 case WEEK: { 351 352 double doubleValue = parseToDouble(value(), nan); 352 return isfinite(doubleValue) && doubleValue > maximum(); 353 } 353 return isfinite(doubleValue) && doubleValue > maximum(); 354 } 355 case RANGE: // Guaranteed by sanitization. 356 ASSERT(parseToDouble(value(), nan) <= maximum()); 354 357 case BUTTON: 355 358 case CHECKBOX: … … 504 507 case RANGE: 505 508 // stepMismatch doesn't occur for RANGE. RenderSlider guarantees the 506 // value matches to step. 509 // value matches to step on user input, and sanitation takes care 510 // of the general case. 507 511 return false; 508 512 case NUMBER: { … … 1483 1487 if (value.isNull()) { 1484 1488 value = sanitizeValue(getAttribute(valueAttr)); 1485 1486 // If no attribute exists, then just use "on" or "" based off the checked() state of the control. 1487 if (value.isNull() && (inputType() == CHECKBOX || inputType() == RADIO)) 1488 return checked() ? "on" : ""; 1489 1490 // If no attribute exists, extra handling may be necessary. 1491 // For Checkbox Types just use "on" or "" based off the checked() state of the control. 1492 // For a Range Input use the calculated default value. 1493 if (value.isNull()) { 1494 if (inputType() == CHECKBOX || inputType() == RADIO) 1495 return checked() ? "on" : ""; 1496 else if (inputType() == RANGE) 1497 return serializeForNumberType(StepRange(this).defaultValue()); 1498 } 1489 1499 } 1490 1500 … … 2493 2503 if (isTextField()) 2494 2504 return InputElement::sanitizeValue(this, proposedValue); 2505 2506 // If the proposedValue is null than this is a reset scenario and we 2507 // want the range input's value attribute to take priority over the 2508 // calculated default (middle) value. 2509 if (inputType() == RANGE && !proposedValue.isNull()) 2510 return serializeForNumberType(StepRange(this).clampValue(proposedValue)); 2511 2495 2512 return proposedValue; 2496 2513 } -
trunk/WebCore/html/StepRange.cpp
r56241 r56242 24 24 #include "HTMLInputElement.h" 25 25 #include "HTMLNames.h" 26 #include "PlatformString.h" 26 27 #include <wtf/MathExtras.h> 27 28 … … 32 33 using namespace HTMLNames; 33 34 34 StepRange::StepRange( HTMLInputElement* element)35 StepRange::StepRange(const HTMLInputElement* element) 35 36 { 36 37 if (element->hasAttribute(precisionAttr)) { … … 58 59 } 59 60 61 double StepRange::clampValue(const String& stringValue) 62 { 63 double value; 64 bool parseSuccess = HTMLInputElement::parseToDoubleForNumberType(stringValue, &value); 65 if (!parseSuccess) 66 value = (minimum + maximum) / 2; 67 return clampValue(value); 68 } 69 60 70 double StepRange::valueFromElement(HTMLInputElement* element, bool* wasClamped) 61 71 { -
trunk/WebCore/html/StepRange.h
r56241 r56242 27 27 28 28 class HTMLInputElement; 29 class String; 29 30 30 31 class StepRange : public Noncopyable { … … 35 36 double maximum; // maximum must be >= minimum. 36 37 37 explicit StepRange( HTMLInputElement*);38 explicit StepRange(const HTMLInputElement*); 38 39 double clampValue(double value); 40 double clampValue(const String& stringValue); 41 42 // Clamp the middle value according to the step 43 double defaultValue() 44 { 45 return clampValue((minimum + maximum) / 2); 46 } 39 47 40 48 // Map value into 0-1 range -
trunk/WebCore/rendering/RenderSlider.cpp
r56241 r56242 304 304 void RenderSlider::updateFromElement() 305 305 { 306 HTMLInputElement* element = static_cast<HTMLInputElement*>(node());307 308 // Send the value back to the element if the range changes it.309 StepRange range(element);310 bool clamped;311 double value = range.valueFromElement(element, &clamped);312 if (clamped)313 element->setValueFromRenderer(HTMLInputElement::serializeForNumberType(value));314 315 306 // Layout will take care of the thumb's size and position. 316 307 if (!m_thumb) {
Note: See TracChangeset
for help on using the changeset viewer.