4 <script src="../../../resources/js-test.js"></script>
7 <p id="description"></p>
8 <div id="console"></div>
10 description('Check stepUp() and stepDown() bahevior for type=month.');
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 shouldThrow('stepUp("", null, null)');
42 shouldThrow('stepDown("", null, null)');
43 debug('Non-number arguments');
44 shouldBe('stepUp("2010-02", null, null, "0")', '"2010-02"');
45 shouldBe('stepDown("2010-02", null, null, "0")', '"2010-02"');
46 shouldBe('stepUp("2010-02", null, null, "foo")', '"2010-02"');
47 shouldBe('stepDown("2010-02", null, null, "foo")', '"2010-02"');
48 shouldBe('stepUp("2010-02", null, null, null)', '"2010-02"');
49 shouldBe('stepDown("2010-02", null, null, null)', '"2010-02"');
50 debug('Normal cases');
51 shouldBe('stepUp("2010-02", null, null)', '"2010-03"');
52 shouldBe('stepDown("2010-02", null, null)', '"2010-01"');
53 shouldBe('stepUp("2010-02", null, null, 10)', '"2010-12"');
54 shouldBe('stepDown("2010-02", null, null, 11)', '"2009-03"');
55 shouldBe('stepUp("1970-01", "4", null, 2)', '"1970-09"');
56 shouldBe('stepDown("1970-01", "4", null, 3)', '"1969-01"');
58 shouldThrow('stepUp("2010-02", "any", null)');
59 shouldThrow('stepDown("2010-02", "any", null)');
60 debug('Overflow/underflow');
61 shouldThrow('stepUp("2010-02", "3.40282346e+38", null)');
62 shouldThrow('stepDown("2010-02", "3.40282346e+38", null)');
63 shouldThrow('stepUp("2010-02", "1", "2010-02")');
64 shouldThrow('stepDown("2010-02", "1", "2010-02")');