4 <script src=
"../../../resources/js-test.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
, sanitized
)
33 input
.disabled
= !!disabled
;
34 var underflow
= input
.validity
.rangeUnderflow
;
35 var resultText
= 'The value "' + input
.value
+ '" ' +
36 (sanitized
? 'sanitized from "' + value
+ '" ' : '') +
37 (underflow
? 'underflows' : 'doesn\'t underflow') +
38 ' the minimum value "' + input
.min
+ '"' + (disabled
? ' when disabled.' : '.');
40 testFailed(resultText
);
42 testPassed(resultText
);
45 function checkSanitizedValueNotUnderflow(value
, max
, disabled
)
47 // For date types, invalid values are sanitized to "".
48 checkNotUnderflow(value
, max
, disabled
, true);
54 checkNotUnderflow('2010-01-27', null);
55 checkNotUnderflow('2010-01-27', '');
56 checkNotUnderflow('2010-01-27', 'foo');
57 // 1000-01-01 is smaller than the implicit minimum value.
58 // But the date parser rejects it before comparing the minimum value.
59 checkNotUnderflow('1000-01-01', '');
60 checkNotUnderflow('1582-10-15', '');
61 checkNotUnderflow('2010-01-27', '2010-01-26');
62 checkNotUnderflow('2010-01-27', '2009-01-28');
63 checkSanitizedValueNotUnderflow('foo', '2011-01-26');
66 checkUnderflow('2010-01-27', '2010-01-28');
67 checkUnderflow('9999-01-01', '10000-12-31');
68 input
.max
= '2010-01-01'; // value < min && value > max
69 checkUnderflow('2010-01-27', '2010-02-01');
72 checkNotUnderflow('9999-01-01', '10000-12-31', true);