tizen beta release
[profile/ivi/webkit-efl.git] / LayoutTests / fast / forms / datetimelocal / ValidityState-rangeOverflow-datetimelocal.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('This test aims to check for rangeOverflow flag with datetime-local input fields');
11
12 var input = document.createElement('input');
13
14 function checkOverflow(value, max, disabled)
15 {
16     input.value = value;
17     input.max = max;
18     input.disabled = !!disabled;
19     var overflow = input.validity.rangeOverflow;
20     var resultText = 'The value "' + input.value + '" ' +
21         (overflow ? 'overflows' : 'doesn\'t overflow') +
22         ' the maximum value "' + input.max + '"' + (disabled ? ' when disabled.' : '.');
23     if (overflow)
24         testPassed(resultText);
25     else
26         testFailed(resultText);
27 }
28
29 function checkNotOverflow(value, max, disabled)
30 {
31     input.value = value;
32     input.max = max;
33     input.disabled = !!disabled;
34     var overflow = input.validity.rangeOverflow;
35     var resultText = 'The value "' + input.value + '" ' +
36         (overflow ? 'overflows' : 'doesn\'t overflow') +
37         ' the maximum value "' + input.max + '"' + (disabled ? ' when disabled.' : '.');
38     if (overflow)
39         testFailed(resultText);
40     else
41         testPassed(resultText);
42 }
43
44 input.type = 'datetime-local';
45 input.min = '';
46 // No overflow cases
47 checkNotOverflow('2010-01-27T12:34', null);
48 checkNotOverflow('2010-01-27T12:34', '');
49 checkNotOverflow('2010-01-27T12:34', 'foo');
50 checkNotOverflow('2010-01-27T12:34', '2010-01-27T12:34');
51 checkNotOverflow('2010-01-27T12:34', '2010-01-27T12:34:56');
52 checkNotOverflow('2010-01-27T12:34', '2011-01-26T12:34');
53 checkNotOverflow('foo', '2011-01-26T12:34');
54 checkNotOverflow('2010-01-27T12:34', '0000-01-01T00:00'); // Too small max value.
55
56 // Overflow cases
57 checkOverflow('2010-01-27T12:34', '2010-01-26T12:33:59.999');
58 checkOverflow('9999-01-01T23:59', '2010-12-31T00:00');
59 input.min = '2010-01-28T12:00';  // value < min && value > max
60 checkOverflow('2010-01-27T12:34', '2010-01-26T12:34');
61
62 // Disabled
63 checkNotOverflow('9999-01-01T23:59', '2010-12-31T00:00', true);
64 </script>
65 <script src="../../js/resources/js-test-post.js"></script>
66 </body>
67 </html>