4 <script src=
"../../../resources/js-test.js"></script>
8 description('This test aims to check for rangeUnderflow flag with a number input field');
10 var input
= document
.createElement('input');
12 function checkUnderflow(value
, min
, disabled
)
16 input
.disabled
= !!disabled
;
17 var underflow
= input
.validity
.rangeUnderflow
;
18 var resultText
= 'The value "' + input
.value
+ '" ' +
19 (underflow
? 'undeflows' : 'doesn\'t underflow') +
20 ' the minimum value "' + input
.min
+ '"' + (disabled
? ' when disabled.' : '.');
22 testPassed(resultText
);
24 testFailed(resultText
);
27 function checkNotUnderflow(value
, min
, disabled
)
31 input
.disabled
= !!disabled
;
32 var underflow
= input
.validity
.rangeUnderflow
;
33 var resultText
= 'The value "' + input
.value
+ '" ' +
34 (underflow
? 'underflows' : 'doesn\'t underflow') +
35 ' the minimum value "' + input
.min
+ '"' + (disabled
? ' when disabled.' : '.');
37 testFailed(resultText
);
39 testPassed(resultText
);
43 input
.type
= 'number';
46 input
.type
= 'number';
47 checkNotUnderflow('101', '100'); // Very normal case.
48 checkNotUnderflow('-99', '-100');
49 checkNotUnderflow('101', '1E+2');
50 checkNotUnderflow('1.01', '1.00');
51 checkNotUnderflow('abc', '100'); // Invalid value.
52 checkNotUnderflow('', '1'); // No value.
53 checkNotUnderflow('-1', ''); // No min.
54 checkNotUnderflow('-1', 'xxx'); // Invalid min.
55 // The following case should be rangeUnderflow==true ideally. But the "double" type doesn't have enough precision.
56 checkNotUnderflow('0.999999999999999999999999999999999999999998', '0.999999999999999999999999999999999999999999');
59 checkUnderflow('99', '100');
60 checkUnderflow('-101', '-100');
61 checkUnderflow('99', '1E+2');
62 input
.max
= '100'; // value < min && value > max
63 checkUnderflow('101', '200');
66 checkNotUnderflow('99', '1E+2', true);