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 rangeOverflow flag with month input fields');
12 var input
= document
.createElement('input');
14 function checkOverflow(value
, max
, disabled
)
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.' : '.');
24 testPassed(resultText
);
26 testFailed(resultText
);
29 function checkNotOverflow(value
, max
, disabled
, sanitized
)
33 input
.disabled
= !!disabled
;
34 var overflow
= input
.validity
.rangeOverflow
;
35 var resultText
= 'The value "' + input
.value
+ '" ' +
36 (sanitized
? 'sanitized from "' + value
+ '" ' : '') +
37 (overflow
? 'overflows' : 'doesn\'t overflow') +
38 ' the maximum value "' + input
.max
+ '"' + (disabled
? ' when disabled.' : '.');
40 testFailed(resultText
);
42 testPassed(resultText
);
45 function checkSanitizedValueNotOverflow(value
, max
, disabled
)
47 // For date types, invalid values are sanitized to "".
48 checkNotOverflow(value
, max
, disabled
, true);
54 checkNotOverflow('2010-01', null);
55 checkNotOverflow('2010-01', '');
56 checkNotOverflow('2010-01', 'foo');
57 checkNotOverflow('2010-01', '2010-01');
58 checkNotOverflow('2010-01', '2010-02');
59 checkNotOverflow('2010-01', '2011-01');
60 checkSanitizedValueNotOverflow('foo', '2011-01');
61 checkNotOverflow('2010-01', '0000-01'); // Too small max value.
64 checkOverflow('2010-01', '2009-12');
65 checkOverflow('9999-01', '2010-12');
66 input
.min
= '2010-02'; // value < min && value > max
67 checkOverflow('2010-01', '2009-12');
70 checkNotOverflow('9999-01', '2010-12', true);