1 description('This test aims to check for rangeOverflow flag with input fields');
3 var input = document.createElement('input');
5 function checkOverflow(value, max, disabled)
9 input.disabled = !!disabled;
10 var overflow = input.validity.rangeOverflow;
11 var resultText = 'The value "' + input.value + '" ' +
12 (overflow ? 'overflows' : 'doesn\'t overflow') +
13 ' the maximum value "' + input.max + '"' + (disabled ? ' when disabled.' : '.');
15 testPassed(resultText);
17 testFailed(resultText);
20 function checkNotOverflow(value, max, disabled)
24 input.disabled = !!disabled;
25 var overflow = input.validity.rangeOverflow;
26 var resultText = 'The value "' + input.value + '" ' +
27 (overflow ? 'overflows' : 'doesn\'t overflow') +
28 ' the maximum value "' + input.max + '"' + (disabled ? ' when disabled.' : '.');
30 testFailed(resultText);
32 testPassed(resultText);
35 // ----------------------------------------------------------------
37 input.type = 'text'; // No overflow for type=text.
38 checkNotOverflow('101', '100');
40 // ----------------------------------------------------------------
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);