4 <script src="../../js/resources/js-test-pre.js"></script>
7 <p id="description"></p>
8 <div id="console"></div>
10 description('This test aims to check for rangeUnderflow flag with date input fields');
12 var input = document.createElement('input');
14 function checkUnderflow(value, min, disabled)
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.' : '.');
24 testPassed(resultText);
26 testFailed(resultText);
29 function checkNotUnderflow(value, min, disabled)
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.' : '.');
39 testFailed(resultText);
41 testPassed(resultText);
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');
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');
65 checkNotUnderflow('9999-01-01', '10000-12-31', true);
67 <script src="../../js/resources/js-test-post.js"></script>