Git init
[framework/web/webkit-efl.git] / LayoutTests / fast / forms / date / ValidityState-rangeOverflow-date.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <link rel="stylesheet" href="../../js/resources/js-test-style.css">
5 <script src="../../js/resources/js-test-pre.js"></script>
6 </head>
7 <body>
8 <p id="description"></p>
9 <div id="console"></div>
10 <script>
11 description('This test aims to check for rangeOverflow flag with date input fields');
12
13 var input = document.createElement('input');
14
15 function checkOverflow(value, max, disabled)
16 {
17     input.value = value;
18     input.max = max;
19     input.disabled = !!disabled;
20     var overflow = input.validity.rangeOverflow;
21     var resultText = 'The value "' + input.value + '" ' +
22         (overflow ? 'overflows' : 'doesn\'t overflow') +
23         ' the maximum value "' + input.max + '"' + (disabled ? ' when disabled.' : '.');
24     if (overflow)
25         testPassed(resultText);
26     else
27         testFailed(resultText);
28 }
29
30 function checkNotOverflow(value, max, disabled)
31 {
32     input.value = value;
33     input.max = max;
34     input.disabled = !!disabled;
35     var overflow = input.validity.rangeOverflow;
36     var resultText = 'The value "' + input.value + '" ' +
37         (overflow ? 'overflows' : 'doesn\'t overflow') +
38         ' the maximum value "' + input.max + '"' + (disabled ? ' when disabled.' : '.');
39     if (overflow)
40         testFailed(resultText);
41     else
42         testPassed(resultText);
43 }
44
45 input.type = 'date';
46 input.min = '';
47 // No overflow cases
48 checkNotOverflow('2010-01-27', null);
49 checkNotOverflow('2010-01-27', '');
50 checkNotOverflow('2010-01-27', 'foo');
51 checkNotOverflow('2010-01-27', '2010-01-27');
52 checkNotOverflow('2010-01-27', '2010-01-28');
53 checkNotOverflow('2010-01-27', '2011-01-26');
54 checkNotOverflow('foo', '2011-01-26');
55 checkNotOverflow('2010-01-27', '0000-01-01'); // Too small max value.
56
57 // Overflow cases
58 checkOverflow('2010-01-27', '2010-01-26');
59 checkOverflow('9999-01-01', '2010-12-31');
60 input.min = '2010-01-28';  // value < min && value > max
61 checkOverflow('2010-01-27', '2010-01-26');
62
63 // Disabled
64 checkNotOverflow('9999-01-01', '2010-12-31', true);
65
66 var successfullyParsed = true;
67 </script>
68 <script src="../../js/resources/js-test-post.js"></script>
69 </body>
70 </html>