4 <script src=
"../../../resources/js-test.js"></script>
5 <script src=
"../resources/common.js"></script>
8 <p id=
"description"></p>
9 <div id=
"console"></div>
10 <input type=
"datetime-local" id=
"input" value=
"2000-01-01T01:01:01">
12 description('Test if change event fires when the user selects the default value after the value was changed by JS.');
14 var eventsCounter
= {};
15 function recordEvent(event
) {
16 if (eventsCounter
[event
.type
] === undefined)
17 eventsCounter
[event
.type
] = 0;
18 eventsCounter
[event
.type
]++;
19 debug('==> "' + event
.type
+ '" event was dispatched.');
22 var input
= document
.getElementById('input');
23 input
.addEventListener('input', recordEvent
, false);
24 input
.addEventListener('change', recordEvent
, false);
26 input
.value
= '2001-01-01T01:01:01';
28 shouldBeEqualToString('input.value', '2001-01-01T01:01:01');
29 shouldBeUndefined('eventsCounter.input');
30 shouldBeUndefined('eventsCounter.change');
32 // We assume the date format is MM/dd/yyyy h:m a.
35 eventSender
.keyDown('rightArrow');
36 eventSender
.keyDown('rightArrow');
37 eventSender
.keyDown('downArrow');
39 shouldBeEqualToString('input.value', '2000-01-01T01:01:01');
40 shouldBe('eventsCounter.input', '1');
41 shouldBe('eventsCounter.change', '1');