4 <script src=
"../../../resources/js-test.js"></script>
5 <script src=
"../resources/common.js"></script>
9 description('Check stepping-up and -down for date input fields from renderer.');
10 if (!window
.eventSender
)
11 debug('This test requires eventSender.');
13 var input
= document
.createElement('input');
15 document
.body
.appendChild(input
);
17 function setInputAttributes(value
, min
, max
) {
23 function stepUp(value
, min
, max
) {
24 setInputAttributes(value
, min
, max
);
25 eventSender
.keyDown('upArrow');
29 function stepDown(value
, min
, max
) {
30 setInputAttributes(value
, min
, max
);
31 eventSender
.keyDown('downArrow');
36 debug('Function arguments are (value, min, max, [keySequence]).');
38 shouldBeEqualToString('stepUp("2000-05-01", "2000-05-01", "2000-10-31")', '2000-06-01');
39 shouldBeEqualToString('stepDown("2000-05-01", "2000-05-01", "2000-10-31")', '2000-10-01');
40 shouldBeEqualToString('stepUp("2000-05-01", "2000-02-01", "2000-05-31")', '2000-02-01');
41 shouldBeEqualToString('stepDown("2000-05-01", "2000-02-01", "2000-05-31")', '2000-04-01');
42 shouldBeEqualToString('stepUp("2000-05-01", "2000-08-01", "2000-10-31")', '2000-08-01');
43 shouldBeEqualToString('stepDown("2000-05-01", "2000-08-01", "2000-10-31")', '2000-10-01');
44 shouldBeEqualToString('stepUp("2000-05-01", "2000-03-01", "2000-03-31")', '2000-03-01');
45 shouldBeEqualToString('stepDown("2000-05-01", "2000-03-01", "2000-03-31")', '2000-03-01');
46 shouldBeEqualToString('stepUp("2000-05-01", "2000-03-01", "2001-05-31")', '2000-06-01');
47 shouldBeEqualToString('stepDown("2000-05-01", "2000-05-01", "2001-08-31")', '2000-04-01');
50 eventSender
.keyDown('rightArrow');
51 shouldBeEqualToString('stepUp("2000-05-10", "2000-05-10", "2000-05-20")', '2000-05-11');
52 shouldBeEqualToString('stepDown("2000-05-10", "2000-05-10", "2000-05-20")', '2000-05-20');
53 shouldBeEqualToString('stepUp("2000-05-10", "2000-05-05", "2000-05-10")', '2000-05-05');
54 shouldBeEqualToString('stepDown("2000-05-10", "2000-05-05", "2000-05-10")', '2000-05-09');
55 shouldBeEqualToString('stepUp("2000-05-10", "2000-05-20", "2000-05-30")', '2000-05-20');
56 shouldBeEqualToString('stepDown("2000-05-10", "2000-05-20", "2000-05-30")', '2000-05-30');
57 shouldBeEqualToString('stepUp("2000-05-10", "2000-05-05", "2000-05-05")', '2000-05-05');
58 shouldBeEqualToString('stepDown("2000-05-10", "2000-05-05", "2000-05-05")', '2000-05-05');
59 shouldBeEqualToString('stepUp("2000-05-10", "2000-05-05", "2001-05-10")', '2000-05-11');
60 shouldBeEqualToString('stepDown("2000-05-10", "2000-05-10", "2001-05-15")', '2000-05-09');
61 shouldBeEqualToString('stepUp("2000-05-10", "2000-05-05", "2000-06-10")', '2000-05-11');
62 shouldBeEqualToString('stepDown("2000-05-10", "2000-05-10", "2000-06-15")', '2000-05-09');
65 setInputAttributes(null, null, null, null);
66 eventSender
.keyDown('rightArrow');
67 shouldBeEqualToString('stepUp("2000-01-01", "2000-01-01", "2009-12-31")', '2001-01-01');
68 shouldBeEqualToString('stepDown("2000-01-01", "2000-01-01", "2009-12-31")', '2009-01-01');
69 shouldBeEqualToString('stepUp("2000-01-01", "1990-01-01", "2000-12-31")', '1990-01-01');
70 shouldBeEqualToString('stepDown("2000-01-01", "1990-01-01", "2000-12-31")', '1999-01-01');
71 shouldBeEqualToString('stepUp("275760-01-01", "1990-01-01", null)', '1990-01-01');
72 shouldBeEqualToString('stepDown("1990-01-01", "1990-01-01", null)', '275760-01-01');
73 shouldBeEqualToString('stepUp("2000-01-01", null, "2000-12-31")', '0001-01-01');
74 shouldBeEqualToString('stepDown("0001-01-01", null, "2000-12-31")', '2000-01-01');
75 shouldBeEqualToString('stepUp("1990-01-01", "2000-01-01", "2009-12-31")', '2000-01-01');
76 shouldBeEqualToString('stepDown("1990-01-01", "2000-01-01", "2009-12-31")', '2009-01-01');
77 shouldBeEqualToString('stepUp("2020-01-01", "2000-01-01", "2000-12-31")', '2000-01-01');
78 shouldBeEqualToString('stepDown("2020-01-01", "2000-01-01", "2000-12-31")', '2000-01-01');