4 <script src=
"../../../resources/js-test.js"></script>
7 <p id=
"description"></p>
8 <div id=
"console"></div>
10 description('Check stepUp() and stepDown() behavior for type=time.');
12 var input
= document
.createElement('input');
14 function setInputAttributes(min
, max
, step
, value
) {
21 function stepUp(value
, step
, max
, optionalStepCount
) {
22 setInputAttributes(null, max
, step
, value
);
23 if (typeof optionalStepCount
!= "undefined")
24 input
.stepUp(optionalStepCount
);
30 function stepDown(value
, step
, min
, optionalStepCount
) {
31 setInputAttributes(min
, null, step
, value
);
32 if (typeof optionalStepCount
!= "undefined")
33 input
.stepDown(optionalStepCount
);
40 debug('Invalid value');
41 shouldBeEqualToString('stepUp("", null, null)', '00:01');
42 shouldBeEqualToString('stepDown("", null, null)', '00:00');
43 debug('Non-number arguments');
44 shouldBeEqualToString('stepUp("20:13", null, null, "0")', '20:13');
45 shouldBeEqualToString('stepDown("20:13", null, null, "0")', '20:13');
46 shouldBeEqualToString('stepUp("20:13", null, null, "foo")', '20:13');
47 shouldBeEqualToString('stepDown("20:13", null, null, "foo")', '20:13');
48 shouldBeEqualToString('stepUp("20:13", null, null, null)', '20:13');
49 shouldBeEqualToString('stepDown("20:13", null, null, null)', '20:13');
50 debug('Normal cases');
51 shouldBeEqualToString('stepUp("20:13", null, null)', '20:14');
52 shouldBeEqualToString('stepDown("20:13", null, null)', '20:12');
53 shouldBeEqualToString('stepUp("20:13", null, null, 10)', '20:23');
54 shouldBeEqualToString('stepDown("20:13", null, null, 11)', '20:02');
55 shouldBeEqualToString('stepUp("20:13", "4", null, 2)', '20:13:08');
56 shouldBeEqualToString('stepDown("20:13", "4", null, 3)', '20:12:48');
58 shouldThrow('stepUp("20:13", "any", null)');
59 shouldThrow('stepDown("20:13", "any", null)');
60 debug('Overflow/underflow');
61 shouldBeEqualToString('stepUp("20:13", "3.40282346e+38", null)', '20:13');
62 shouldBeEqualToString('stepDown("20:13", "3.40282346e+38", null)', '20:13');
63 shouldBeEqualToString('stepUp("20:13", "1", "20:13")', '20:13:00');
64 shouldBeEqualToString('stepDown("20:13", "1", "20:13")', '20:13:00');
65 shouldBeEqualToString('stepUp("23:59", null, null)', '23:59');
66 shouldBeEqualToString('stepDown("00:00", null, null)', '00:00');
69 debug('Invalid min/max:');
70 shouldBeEqualToString('setInputAttributes("10:00", "09:00", "60", "08:00"); input.stepUp(); input.value', '08:00');
71 // Threre are no valid values between 00:00 - 00:33 because the step-base
73 var inputWithInitialValue
= document
.createElement('input');
74 inputWithInitialValue
.type
= 'time';
75 inputWithInitialValue
.setAttribute('value', '12:34');
76 inputWithInitialValue
.setAttribute('step', '3600');
77 inputWithInitialValue
.setAttribute('max', '00:33');
78 shouldBeEqualToString('inputWithInitialValue.stepUp(); inputWithInitialValue.value', '12:34');
81 debug('Step-mismatched initial values');
82 // There are no step-match values in 00:00 - 23:59:59.999 except 00:00.
83 shouldBeEqualToString('stepUp("20:13", "86400.000", null, 65536)', '00:00');
84 shouldBeEqualToString('stepUp("20:13", "86400.001", null, 65536)', '00:00:00.000');
85 shouldBeEqualToString('stepUp("20:13", "600", null, 1)', '20:20');
86 shouldBeEqualToString('stepUp("20:13", "600", null, 2)', '20:30');
87 shouldBeEqualToString('stepDown("20:13", "600", null, 1)', '20:10');
88 shouldBeEqualToString('stepDown("20:13", "600", null, 2)', '20:00');