tizen beta release
[framework/web/webkit-efl.git] / LayoutTests / fast / forms / date / ValidityState-rangeUnderflow-date.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 rangeUnderflow flag with date input fields');
11
12 var input = document.createElement('input');
13
14 function checkUnderflow(value, min, disabled)
15 {
16     input.value = value;
17     input.min = min;
18     input.disabled = !!disabled;
19     var underflow = input.validity.rangeUnderflow;
20     var resultText = 'The value "' + input.value + '" ' +
21         (underflow ? 'undeflows' : 'doesn\'t underflow') +
22         ' the minimum value "' + input.min + '"' + (disabled ? ' when disabled.' : '.');
23     if (underflow)
24         testPassed(resultText);
25     else
26         testFailed(resultText);
27 }
28
29 function checkNotUnderflow(value, min, disabled)
30 {
31     input.value = value;
32     input.min = min;
33     input.disabled = !!disabled;
34     var underflow = input.validity.rangeUnderflow;
35     var resultText = 'The value "' + input.value + '" ' +
36         (underflow ? 'underflows' : 'doesn\'t underflow') +
37         ' the minimum value "' + input.min + '"' + (disabled ? ' when disabled.' : '.');
38     if (underflow)
39         testFailed(resultText);
40     else
41         testPassed(resultText);
42 }
43
44 input.type = 'date';
45 input.max = '';
46 // No underflow cases
47 checkNotUnderflow('2010-01-27', null);
48 checkNotUnderflow('2010-01-27', '');
49 checkNotUnderflow('2010-01-27', 'foo');
50 // 1000-01-01 is smaller than the implicit minimum value.
51 // But the date parser rejects it before comparing the minimum value.
52 checkNotUnderflow('1000-01-01', '');
53 checkNotUnderflow('1582-10-15', '');
54 checkNotUnderflow('2010-01-27', '2010-01-26');
55 checkNotUnderflow('2010-01-27', '2009-01-28');
56 checkNotUnderflow('foo', '2011-01-26');
57
58 // Underflow cases
59 checkUnderflow('2010-01-27', '2010-01-28');
60 checkUnderflow('9999-01-01', '10000-12-31');
61 input.max = '2010-01-01';  // value < min && value > max
62 checkUnderflow('2010-01-27', '2010-02-01');
63
64 // Disabled
65 checkNotUnderflow('9999-01-01', '10000-12-31', true);
66 </script>
67 <script src="../../js/resources/js-test-post.js"></script>
68 </body>
69 </html>