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