<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script src="../resources/common.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<input type="datetime-local" id="input" value="2000-01-01T01:01:01">
<script>
description('Test if change event fires when the user selects the default value after the value was changed by JS.');
var eventsCounter = {};
function recordEvent(event) {
if (eventsCounter[event.type] === undefined)
eventsCounter[event.type] = 0;
eventsCounter[event.type]++;
debug('==> "' + event.type + '" event was dispatched.');
}
var input = document.getElementById('input');
input.addEventListener('input', recordEvent, false);
input.addEventListener('change', recordEvent, false);
input.value = '2001-01-01T01:01:01';
shouldBeEqualToString('input.value', '2001-01-01T01:01:01');
shouldBeUndefined('eventsCounter.input');
shouldBeUndefined('eventsCounter.change');
// We assume the date format is MM/dd/yyyy h:m a.
input.focus();
eventSender.keyDown('ArrowRight');
eventSender.keyDown('ArrowRight');
eventSender.keyDown('ArrowDown');
shouldBeEqualToString('input.value', '2000-01-01T01:01:01');
shouldBe('eventsCounter.input', '1');
shouldBe('eventsCounter.change', '1');
</script>
</body>
</html>