430b8299e1dcbdd837de98cc9f356a4ada6ecd9c
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / forms / week / week-stepup-stepdown.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../js/resources/js-test-pre.js"></script>
5 </head>
6 <body>
7 <p id="description"></p>
8 <div id="console"></div>
9 <script>
10 description('Check stepUp() and stepDown() bahevior for type=week.');
11
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."';
14
15 function setInputAttributes(min, max, step, value) {
16     input.min = min;
17     input.max = max;
18     input.step = step;
19     input.value = value;
20 }
21
22 function stepUp(value, step, max, optionalStepCount) {
23     setInputAttributes(null, max, step, value);
24     if (typeof optionalStepCount != "undefined")
25         input.stepUp(optionalStepCount);
26     else
27         input.stepUp();
28     return input.value;
29 }
30
31 function stepDown(value, step, min, optionalStepCount) {
32     setInputAttributes(min, null, step, value);
33     if (typeof optionalStepCount != "undefined")
34         input.stepDown(optionalStepCount);
35     else
36         input.stepDown();
37     return input.value;
38 }
39
40 input.type = 'week';
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"');
58 debug('Step=any');
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);
66
67 debug('');
68 </script>
69 </body>
70 </html>