Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / forms / datetimelocal / datetimelocal-stepup-stepdown.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <p id="description"></p>
8 <div id="console"></div>
9 <script>
10 description('Check stepUp() and stepDown() behavior for type=datetime-local.');
11
12 var input = document.createElement('input');
13
14 function setInputAttributes(min, max, step, value) {
15     input.min = min;
16     input.max = max;
17     input.step = step;
18     input.value = value;
19 }
20
21 function stepUp(value, step, max, optionalStepCount) {
22     setInputAttributes(null, max, step, value);
23     if (typeof optionalStepCount != "undefined")
24         input.stepUp(optionalStepCount);
25     else
26         input.stepUp();
27     return input.value;
28 }
29
30 function stepDown(value, step, min, optionalStepCount) {
31     setInputAttributes(min, null, step, value);
32     if (typeof optionalStepCount != "undefined")
33         input.stepDown(optionalStepCount);
34     else
35         input.stepDown();
36     return input.value;
37 }
38
39 input.type = 'datetime-local';
40 debug('Invalid value');
41 shouldBeEqualToString('stepUp("", null, null)', '1970-01-01T00:01');
42 shouldBeEqualToString('stepDown("", null, null)', '1969-12-31T23:59');
43 debug('Non-number arguments');
44 shouldBeEqualToString('stepUp("2010-02-10T20:13", null, null, "0")', '2010-02-10T20:13');
45 shouldBeEqualToString('stepDown("2010-02-10T20:13", null, null, "0")', '2010-02-10T20:13');
46 shouldBeEqualToString('stepUp("2010-02-10T20:13", null, null, "foo")', '2010-02-10T20:13');
47 shouldBeEqualToString('stepDown("2010-02-10T20:13", null, null, "foo")', '2010-02-10T20:13');
48 shouldBeEqualToString('stepUp("2010-02-10T20:13", null, null, null)', '2010-02-10T20:13');
49 shouldBeEqualToString('stepDown("2010-02-10T20:13", null, null, null)', '2010-02-10T20:13');
50 debug('Normal cases');
51 shouldBeEqualToString('stepUp("2010-02-10T20:13", null, null)', '2010-02-10T20:14');
52 shouldBeEqualToString('stepDown("2010-02-10T20:13", null, null)', '2010-02-10T20:12');
53 shouldBeEqualToString('stepUp("2010-02-10T20:13", null, null, 10)', '2010-02-10T20:23');
54 shouldBeEqualToString('stepDown("2010-02-10T20:13", null, null, 11)', '2010-02-10T20:02');
55 shouldBeEqualToString('stepUp("1970-01-01T20:13", "4", null, 2)', '1970-01-01T20:13:08');
56 shouldBeEqualToString('stepDown("1970-01-01T20:13", "4", null, 3)', '1970-01-01T20:12:48');
57 debug('Step=any');
58 shouldThrow('stepUp("2010-02-10T20:13", "any", null)');
59 shouldThrow('stepDown("2010-02-10T20:13", "any", null)');
60 debug('Overflow/underflow');
61 shouldBeEqualToString('stepUp("2010-02-10T20:13", "3.40282346e+38", null)', '275760-09-13T00:00:00');
62 shouldBeEqualToString('stepDown("2010-02-10T20:13", "3.40282346e+38", null)', '1970-01-01T00:00:00');
63 shouldBeEqualToString('stepUp("2010-02-10T20:13", "1", "2010-02-10T20:13")', '2010-02-10T20:13:00');
64 shouldBeEqualToString('stepDown("2010-02-10T20:13", "1", "2010-02-10T20:13")', '2010-02-10T20:13:00');
65 </script>
66 </body>
67 </html>