blob: 41df14c045d2db541633bc28bd47f2e9dd3dea85 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description('Check stepMismatch results for type=week.');
var input = document.createElement('input');
document.body.appendChild(input);
function stepMismatchFor(value, step, min, disabled) {
input.min = min;
input.step = step;
input.value = value;
input.disabled = !!disabled;
return input.validity.stepMismatch;
}
input.type = 'week';
debug('Empty values');
shouldBeFalse('stepMismatchFor("", null, null)');
shouldBeFalse('stepMismatchFor("", "2", "1970-W02")');
debug('Normal step values');
shouldBeTrue('stepMismatchFor("2010-W03", "2", "2010-W02")');
shouldBeFalse('stepMismatchFor("2010-W02", "2", "2010-W02")');
shouldBeFalse('stepMismatchFor("2010-W04", "2", "2010-W02")');
shouldBeTrue('stepMismatchFor("1800-W11", "3", "1800-W09")');
shouldBeFalse('stepMismatchFor("1800-W09", "3", "1800-W09")');
shouldBeFalse('stepMismatchFor("1800-W12", "3", "1800-W09")');
shouldBeTrue('stepMismatchFor("275760-W35", "3", "275760-W33")');
shouldBeFalse('stepMismatchFor("275760-W35", "2", "275760-W33")');
debug('Implicit step base');
shouldBeFalse('stepMismatchFor("1970-W01", "2", null)');
shouldBeTrue('stepMismatchFor("1970-W02", "2", null)');
shouldBeFalse('stepMismatchFor("1970-W03", "2", null)');
shouldBeTrue('stepMismatchFor("1970-W04", "2", null)');
debug('Fractional step values');
shouldBeFalse('stepMismatchFor("2010-W03", "0.1", "2010-W02")');
shouldBeFalse('stepMismatchFor("2010-W03", "1.1", "2010-W02")');
shouldBeTrue('stepMismatchFor("2010-W03", "1.9", "2010-W02")');
debug('Invalid or no step values');
shouldBeFalse('stepMismatchFor("2010-W03", null, "2010-W02")');
shouldBeFalse('stepMismatchFor("2010-W03", "-1", "2010-W02")');
shouldBeFalse('stepMismatchFor("2010-W03", "foo", "2010-W02")');
debug('Special step value');
shouldBeFalse('stepMismatchFor("2010-W03", "any", "2010-W02")');
debug('Disabled');
shouldBeTrue('stepMismatchFor("2010-W03", "2", "2010-W02", true)');
</script>
<script src="../../../resources/js-test-post.js"></script>
</body>
</html>