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=week.');
12 var input = document.createElement('input');
13 var invalidStateErr = '"InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable."';
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);
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-W02", null, null, "0")', '"2010-W02"');
46 shouldBe('stepDown("2010-W02", null, null, "0")', '"2010-W02"');
47 shouldBe('stepUp("2010-W02", null, null, "foo")', '"2010-W02"');
48 shouldBe('stepDown("2010-W02", null, null, "foo")', '"2010-W02"');
49 shouldBe('stepUp("2010-W02", null, null, null)', '"2010-W02"');
50 shouldBe('stepDown("2010-W02", null, null, null)', '"2010-W02"');
51 debug('Normal cases');
52 shouldBe('stepUp("2010-W02", null, null)', '"2010-W03"');
53 shouldBe('stepDown("2010-W02", null, null)', '"2010-W01"');
54 shouldBe('stepUp("2010-W02", null, null, 10)', '"2010-W12"');
55 shouldBe('stepDown("2010-W02", null, null, 11)', '"2009-W44"');
56 shouldBe('stepUp("1970-W01", "4", null, 2)', '"1970-W09"');
57 shouldBe('stepDown("1970-W01", "4", null, 3)', '"1969-W41"');
59 shouldThrow('stepUp("2010-W02", "any", null)', invalidStateErr);
60 shouldThrow('stepDown("2010-W02", "any", null)', invalidStateErr);
61 debug('Overflow/underflow');
62 shouldThrow('stepUp("2010-W02", "3.40282346e+38", null)', invalidStateErr);
63 shouldThrow('stepDown("2010-W02", "3.40282346e+38", null)', invalidStateErr);
64 shouldThrow('stepUp("2010-W02", "1", "2010-W02")', invalidStateErr);
65 shouldThrow('stepDown("2010-W02", "1", "2010-W02")', invalidStateErr);