4 <script src="../../js/resources/js-test-pre.js"></script>
7 <p id="description"></p>
8 <div id="console"></div>
10 description('Check stepUp() and stepDown() bahevior for type=datetime.');
12 var input = document.createElement('input');
13 var invalidStateErr = '"Error: INVALID_STATE_ERR: DOM Exception 11"';
15 function setInputAttributes(min, max, step, value) {
22 function stepUp(value, step, max, optionalStepCount) {
23 setInputAttributes(null, max, step, value);
24 if (typeof optionalStepCount != "undefined")
25 input.stepUp(optionalStepCount);
31 function stepDown(value, step, min, optionalStepCount) {
32 setInputAttributes(min, null, step, value);
33 if (typeof optionalStepCount != "undefined")
34 input.stepDown(optionalStepCount);
40 input.type = 'datetime';
41 debug('Invalid value');
42 shouldThrow('stepUp("", null, null)', invalidStateErr);
43 shouldThrow('stepDown("", null, null)', invalidStateErr);
44 debug('Non-number arguments');
45 shouldBe('stepUp("2010-02-10T20:13Z", null, null, "0")', '"2010-02-10T20:13Z"');
46 shouldBe('stepDown("2010-02-10T20:13Z", null, null, "0")', '"2010-02-10T20:13Z"');
47 shouldBe('stepUp("2010-02-10T20:13Z", null, null, "foo")', '"2010-02-10T20:13Z"');
48 shouldBe('stepDown("2010-02-10T20:13Z", null, null, "foo")', '"2010-02-10T20:13Z"');
49 shouldBe('stepUp("2010-02-10T20:13Z", null, null, null)', '"2010-02-10T20:13Z"');
50 shouldBe('stepDown("2010-02-10T20:13Z", null, null, null)', '"2010-02-10T20:13Z"');
51 debug('Normal cases');
52 shouldBe('stepUp("2010-02-10T20:13Z", null, null)', '"2010-02-10T20:14Z"');
53 shouldBe('stepDown("2010-02-10T20:13Z", null, null)', '"2010-02-10T20:12Z"');
54 shouldBe('stepUp("2010-02-10T20:13Z", null, null, 10)', '"2010-02-10T20:23Z"');
55 shouldBe('stepDown("2010-02-10T20:13Z", null, null, 11)', '"2010-02-10T20:02Z"');
56 shouldBe('stepUp("1970-01-01T20:13Z", "4", null, 2)', '"1970-01-01T20:13:08Z"');
57 shouldBe('stepDown("1970-01-01T20:13Z", "4", null, 3)', '"1970-01-01T20:12:48Z"');
59 shouldThrow('stepUp("2010-02-10T20:13Z", "any", null)', invalidStateErr);
60 shouldThrow('stepDown("2010-02-10T20:13Z", "any", null)', invalidStateErr);
61 debug('Overflow/underflow');
62 shouldThrow('stepUp("2010-02-10T20:13Z", "3.40282346e+38", null)', invalidStateErr);
63 shouldThrow('stepDown("2010-02-10T20:13Z", "3.40282346e+38", null)', invalidStateErr);
64 shouldThrow('stepUp("2010-02-10T20:13Z", "1", "2010-02-10T20:13Z")', invalidStateErr);
65 shouldThrow('stepDown("2010-02-10T20:13Z", "1", "2010-02-10T20:13Z")', invalidStateErr);
67 <script src="../../js/resources/js-test-post.js"></script>