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=date.');
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)', '1970-01-02');
42 shouldBeEqualToString('stepDown("", null, null)', '1969-12-31');
43 debug('Non-number arguments');
44 shouldBeEqualToString('stepUp("2010-02-10", null, null, "0")', '2010-02-10');
45 shouldBeEqualToString('stepDown("2010-02-10", null, null, "0")', '2010-02-10');
46 shouldBeEqualToString('stepUp("2010-02-10", null, null, "foo")', '2010-02-10');
47 shouldBeEqualToString('stepDown("2010-02-10", null, null, "foo")', '2010-02-10');
48 shouldBeEqualToString('stepUp("2010-02-10", null, null, null)', '2010-02-10');
49 shouldBeEqualToString('stepDown("2010-02-10", null, null, null)', '2010-02-10');
50 debug('Normal cases');
51 shouldBeEqualToString('stepDown("1970-01-04", "2", null)', '1970-01-03');
52 shouldBeEqualToString('stepUp("2010-02-10", null, null)', '2010-02-11');
53 shouldBeEqualToString('stepDown("2010-02-10", null, null)', '2010-02-09');
54 shouldBeEqualToString('stepUp("2010-02-10", null, null, 10)', '2010-02-20');
55 shouldBeEqualToString('stepDown("2010-02-10", null, null, 11)', '2010-01-30');
56 shouldBeEqualToString('stepUp("1970-01-01", "4", null, 2)', '1970-01-09');
57 shouldBeEqualToString('stepDown("1970-01-01", "4", null, 3)', '1969-12-20');
59 shouldThrow('stepUp("2010-02-10", "any", null)');
60 shouldThrow('stepDown("2010-02-10", "any", null)');
61 debug('Overflow/underflow');
62 shouldBeEqualToString('stepUp("2010-02-10", "3.40282346e+38", null)', '1970-01-01');
63 shouldBeEqualToString('stepDown("2010-02-10", "3.40282346e+38", null)', '1970-01-01');
64 shouldBeEqualToString('stepUp("2010-02-10", "1", "2010-02-10")', '2010-02-10');
65 shouldBeEqualToString('stepDown("2010-02-10", "1", "2010-02-10")', '2010-02-10');