4 <script src="../../js/resources/js-test-pre.js"></script>
7 <p id="description"></p>
8 <div id="console"></div>
10 description('Check stepping-up and -down for time input fields from renderer. No cases of empty initial values.');
12 var input = document.createElement('input');
13 var invalidStateErr = '"Error: INVALID_STATE_ERR: DOM Exception 11"';
15 function sendKey(keyName) {
16 var event = document.createEvent('KeyboardEvent');
17 event.initKeyboardEvent('keydown', true, true, document.defaultView, keyName);
18 input.dispatchEvent(event);
21 function setInputAttributes(min, max, step, value) {
28 function stepUp(value, step, max, optionalStepCount) {
29 setInputAttributes(null, max, step, value);
30 if (typeof optionalStepCount != "undefined")
31 if (optionalStepCount < 0)
32 for (var i = 0; i < -optionalStepCount; i++)
35 for (var i = 0; i < optionalStepCount; i++)
42 function stepDown(value, step, min, optionalStepCount) {
43 setInputAttributes(min, null, step, value);
44 if (typeof optionalStepCount != "undefined")
45 if (optionalStepCount < 0)
46 for (var i = 0; i < -optionalStepCount; i++)
49 for (var i = 0; i < optionalStepCount; i++)
57 debug('Function arguments are (value, step, {min or max}, [stepCount]).');
58 debug('Normal cases');
59 shouldBe('stepUp("20:13", null, null)', '"20:14"');
60 shouldBe('stepDown("20:13", null, null)', '"20:12"');
61 shouldBe('stepUp("20:13", null, null, 10)', '"20:23"');
62 shouldBe('stepDown("20:13", null, null, 11)', '"20:02"');
63 shouldBe('stepUp("20:13", "4", null, 2)', '"20:13:08"');
64 shouldBe('stepDown("20:13", "4", null, 3)', '"20:12:48"');
66 shouldBe('stepUp("20:13", "any", null)', '"20:14"');
67 shouldBe('stepDown("20:13", "any", null)', '"20:12"');
68 debug('Overflow/underflow');
69 shouldBe('stepUp("20:13", "3.40282346e+38", null)', '"23:59:59.999"');
70 shouldBe('stepDown("20:13", "3.40282346e+38", null)', '"00:00:00.000"');
71 shouldBe('stepUp("20:13", "1", "20:13")', '"20:13"');
72 shouldBe('stepDown("20:13", "1", "20:13")', '"20:13"');
73 shouldBe('stepUp("23:59", null, null)', '"23:59"');
74 shouldBe('stepDown("00:00", null, null)', '"00:00"');
75 debug('stepDown()/stepUp() for stepMismatch values');
76 shouldBe('stepDown("20:13", "3", "20:12:56")', '"20:12:59"');
77 shouldBe('stepUp("00:13", "7", "")', '"00:13:04"');
81 <script src="../../js/resources/js-test-post.js"></script>