|
| 1 | +<!DOCTYPE HTML> |
| 2 | +<title>Input Step Down</title> |
| 3 | + |
| 4 | +<link rel="help" href="https://html.spec.whatwg.org/multipage/input.html#dom-input-stepup"> |
| 5 | + |
| 6 | +<script src="/resources/testharness.js"></script> |
| 7 | +<script src="/resources/testharnessreport.js"></script> |
| 8 | + |
| 9 | +<input type='number' id='input'> |
| 10 | + |
| 11 | +<script> |
| 12 | + const input = document.getElementById("input"); |
| 13 | + |
| 14 | + function testStepDown(initialValue, minValue, expectedValue) { |
| 15 | + input.value = initialValue; |
| 16 | + input.min = minValue; |
| 17 | + |
| 18 | + input.stepDown(); |
| 19 | + |
| 20 | + assert_equals(input.value, expectedValue); |
| 21 | + } |
| 22 | + |
| 23 | + const tests = [ |
| 24 | + { initialValue: '', minValue: '', expectedValue: '-1', description: 'stepDown() on input with no initial or min values' }, |
| 25 | + { initialValue: '', minValue: '7', expectedValue: '7', description: 'stepDown() on input with no initial value and positive min value' }, |
| 26 | + { initialValue: '', minValue: '-7', expectedValue: '-1', description: 'stepDown() on input with no initial value and negative min value' }, |
| 27 | + { initialValue: '7', minValue: '7', expectedValue: '7', description: 'stepDown() on input with initial value equal to min value' }, |
| 28 | + { initialValue: '3', minValue: '7', expectedValue: '3', description: 'stepDown() on input with initial value less than min value' }, |
| 29 | + { initialValue: '10', minValue: '7', expectedValue: '9', description: 'stepDown() on input with initial value greater than min value' }, |
| 30 | + ]; |
| 31 | + |
| 32 | + for(const t of tests) { |
| 33 | + test(()=>{ |
| 34 | + testStepDown( |
| 35 | + t.initialValue, |
| 36 | + t.minValue, |
| 37 | + t.expectedValue |
| 38 | + ); |
| 39 | + }, |
| 40 | + t.description); |
| 41 | + } |
| 42 | +</script> |
0 commit comments