input-stepdown.html (1629B)
1 <!DOCTYPE HTML> 2 <html> 3 <title>Forms</title> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <h3>input_stepDown</h3> 7 <input type='number' id='input_number'> 8 <input type="number" id="number_input" min="300" step="1" value="200"> 9 <input type="date" id="date_input" min="2011-02-10" step="1" value="2010-02-10"> 10 <input type="datetime-local" id="dtl_input" min="2011-02-10T20:13" step="1" value="2010-02-10T20:13"> 11 <input type="time" id="time_input" min="21:13" step="60" value="20:13"> 12 13 <script> 14 var input_number = document.getElementById("input_number"); 15 input_number.max = "30"; 16 input_number.step = "3"; 17 input_number.value = "30"; 18 input_number.stepDown(5); 19 20 if (typeof(input_number.stepDown) == "function") { 21 test(function() { 22 assert_equals(input_number.value, "15", "call of stepDown method is failed."); 23 }); 24 } else { 25 test(function() { 26 assert_unreached("stepDown attribute is not exist."); 27 }); 28 } 29 30 function testStepDownOverflow(id, value, type) { 31 test(function() { 32 var input = document.getElementById(id); 33 input.stepDown(); 34 assert_equals(input.value, value, "value shouldn't change."); 35 }, "Calling stepDown() on input - " + type + " - where value < min should not modify value."); 36 } 37 38 testStepDownOverflow("number_input", "200", "number"); 39 testStepDownOverflow("date_input", "2010-02-10", "date"); 40 testStepDownOverflow("dtl_input", "2010-02-10T20:13", "datetime-local"); 41 testStepDownOverflow("time_input", "20:13", "time"); 42 </script> 43 </html>