tizen beta release
[framework/web/webkit-efl.git] / LayoutTests / fast / forms / time / time-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=time.');
11
12 var input = document.createElement('input');
13 var invalidStateErr = '"Error: INVALID_STATE_ERR: DOM Exception 11"';
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 = 'time';
41 debug('Invalid value');
42 shouldThrow('stepUp("", null, null)', invalidStateErr);
43 shouldThrow('stepDown("", null, null)', invalidStateErr);
44 debug('Non-number arguments');
45 shouldBe('stepUp("20:13", null, null, "0")', '"20:13"');
46 shouldBe('stepDown("20:13", null, null, "0")', '"20:13"');
47 shouldBe('stepUp("20:13", null, null, "foo")', '"20:13"');
48 shouldBe('stepDown("20:13", null, null, "foo")', '"20:13"');
49 shouldBe('stepUp("20:13", null, null, null)', '"20:13"');
50 shouldBe('stepDown("20:13", null, null, null)', '"20:13"');
51 debug('Normal cases');
52 shouldBe('stepUp("20:13", null, null)', '"20:14"');
53 shouldBe('stepDown("20:13", null, null)', '"20:12"');
54 shouldBe('stepUp("20:13", null, null, 10)', '"20:23"');
55 shouldBe('stepDown("20:13", null, null, 11)', '"20:02"');
56 shouldBe('stepUp("20:13", "4", null, 2)', '"20:13:08"');
57 shouldBe('stepDown("20:13", "4", null, 3)', '"20:12:48"');
58 debug('Step=any');
59 shouldThrow('stepUp("20:13", "any", null)', invalidStateErr);
60 shouldThrow('stepDown("20:13", "any", null)', invalidStateErr);
61 debug('Overflow/underflow');
62 shouldThrow('stepUp("20:13", "3.40282346e+38", null)', invalidStateErr);
63 shouldThrow('stepDown("20:13", "3.40282346e+38", null)', invalidStateErr);
64 shouldThrow('stepUp("20:13", "1", "20:13")', invalidStateErr);
65 shouldThrow('stepDown("20:13", "1", "20:13")', invalidStateErr);
66 shouldThrow('stepUp("23:59", null, null)', invalidStateErr);
67 shouldThrow('stepDown("00:00", null, null)', invalidStateErr);
68
69 debug('');
70 </script>
71 <script src="../../js/resources/js-test-post.js"></script>
72 </body>
73 </html>