<!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=month.');

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 = 'month';
debug('Empty values');
shouldBeFalse('stepMismatchFor("", null, null)');
shouldBeFalse('stepMismatchFor("", "2", "1969-12")');
debug('Normal step values');
shouldBeTrue('stepMismatchFor("2010-03", "2", "2010-02")');
shouldBeFalse('stepMismatchFor("2010-02", "2", "2010-02")');
shouldBeFalse('stepMismatchFor("2010-04", "2", "2010-02")');
shouldBeTrue('stepMismatchFor("1800-11", "3", "1800-09")');
shouldBeFalse('stepMismatchFor("1800-09", "3", "1800-09")');
shouldBeFalse('stepMismatchFor("1800-12", "3", "1800-09")');
shouldBeTrue('stepMismatchFor("275760-09", "3", "275760-08")');
shouldBeFalse('stepMismatchFor("275760-09", "2", "275760-09")');
debug('Implicit step base');
shouldBeTrue('stepMismatchFor("1970-02", "2", null)');
shouldBeFalse('stepMismatchFor("1970-03", "2", null)');
debug('Fractional step values');
shouldBeFalse('stepMismatchFor("2010-03", "0.1", "2010-02")');
shouldBeFalse('stepMismatchFor("2010-03", "1.1", "2010-02")');
shouldBeTrue('stepMismatchFor("2010-03", "1.9", "2010-02")');
debug('Invalid or no step values');
shouldBeFalse('stepMismatchFor("2010-03", null, "2010-02")');
shouldBeFalse('stepMismatchFor("2010-03", "-1", "2010-02")');
shouldBeFalse('stepMismatchFor("2010-03", "foo", "2010-02")');
debug('Special step value');
shouldBeFalse('stepMismatchFor("2010-03", "any", "2010-02")');
debug('Disabled');
shouldBeTrue('stepMismatchFor("2010-03", "2", "2010-02", true)');

debug('');
</script>
<script src="../../../resources/js-test-post.js"></script>
</body>
</html>
