75 lines
2.2 KiB
HTML
75 lines
2.2 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<script src="../../../resources/js-test-pre.js"></script>
|
|
</head>
|
|
<body>
|
|
<p id="description"></p>
|
|
<div id="console"></div>
|
|
<script>
|
|
description('This test aims to check for rangeOverflow flag with month input fields');
|
|
|
|
var input = document.createElement('input');
|
|
|
|
function checkOverflow(value, max, disabled)
|
|
{
|
|
input.value = value;
|
|
input.max = max;
|
|
input.disabled = !!disabled;
|
|
var overflow = input.validity.rangeOverflow;
|
|
var resultText = 'The value "' + input.value + '" ' +
|
|
(overflow ? 'overflows' : 'doesn\'t overflow') +
|
|
' the maximum value "' + input.max + '"' + (disabled ? ' when disabled.' : '.');
|
|
if (overflow)
|
|
testPassed(resultText);
|
|
else
|
|
testFailed(resultText);
|
|
}
|
|
|
|
function checkNotOverflow(value, max, disabled, sanitized)
|
|
{
|
|
input.value = value;
|
|
input.max = max;
|
|
input.disabled = !!disabled;
|
|
var overflow = input.validity.rangeOverflow;
|
|
var resultText = 'The value "' + input.value + '" ' +
|
|
(sanitized ? 'sanitized from "' + value + '" ' : '') +
|
|
(overflow ? 'overflows' : 'doesn\'t overflow') +
|
|
' the maximum value "' + input.max + '"' + (disabled ? ' when disabled.' : '.');
|
|
if (overflow)
|
|
testFailed(resultText);
|
|
else
|
|
testPassed(resultText);
|
|
}
|
|
|
|
function checkSanitizedValueNotOverflow(value, max, disabled)
|
|
{
|
|
// For date types, invalid values are sanitized to "".
|
|
checkNotOverflow(value, max, disabled, true);
|
|
}
|
|
|
|
input.type = 'month';
|
|
input.min = '';
|
|
// No overflow cases
|
|
checkNotOverflow('2010-01', null);
|
|
checkNotOverflow('2010-01', '');
|
|
checkNotOverflow('2010-01', 'foo');
|
|
checkNotOverflow('2010-01', '2010-01');
|
|
checkNotOverflow('2010-01', '2010-02');
|
|
checkNotOverflow('2010-01', '2011-01');
|
|
checkSanitizedValueNotOverflow('foo', '2011-01');
|
|
checkNotOverflow('2010-01', '0000-01'); // Too small max value.
|
|
|
|
// Overflow cases
|
|
checkOverflow('2010-01', '2009-12');
|
|
checkOverflow('9999-01', '2010-12');
|
|
input.min = '2010-02'; // value < min && value > max
|
|
checkOverflow('2010-01', '2009-12');
|
|
|
|
// Disabled
|
|
checkNotOverflow('9999-01', '2010-12', true);
|
|
</script>
|
|
<script src="../../../resources/js-test-post.js"></script>
|
|
</body>
|
|
</html>
|