<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script src="../../forms/resources/picker-common.js"></script>
<script src="resources/calendar-picker-common.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>

<input type=date id=date value="2011-05-02" step="9">
<input type=date id="date-bare" step="9">

<script>
description('Test if step limits available dates in calendar picker.');

document.getElementById('date-bare').value = '2011-05-01';
openPicker(document.getElementById('date-bare'), test1);

function test1() {
    debug("Step without value or min attributes.");
    shouldBeEqualToString('availableDayCells()', '2011-05-08,2011-05-17,2011-05-26,2011-06-04');

    // Close popup
    eventSender.keyDown('escape');
    waitUntilClosing(test1AfterClose);
}

function test1AfterClose() {
    openPicker(document.getElementById('date'), test2);
}

function test2() {
    debug("Step without min.");
    shouldBeEqualToString('availableDayCells()', '2011-05-02,2011-05-11,2011-05-20,2011-05-29');

    // Close popup
    eventSender.keyDown('escape');
    waitUntilClosing(test2AfterClose);
}

function test2AfterClose() {
    document.getElementById('date').min = '2011-05-01';

    // Reopen popup
    openPicker(document.getElementById('date'), test3);
}

function test3() {
    debug("Step when min is set.");
    shouldBeEqualToString('availableDayCells()', '2011-05-01,2011-05-10,2011-05-19,2011-05-28');
    finishJSTest();
}
</script>
</body>
</html>