4 <script src=
"../../../resources/js-test.js"></script>
5 <script src=
"../../forms/resources/picker-common.js"></script>
6 <script src=
"resources/calendar-picker-common.js"></script>
9 <p id=
"description"></p>
10 <div id=
"console"></div>
11 <input type=
"datetime-local" id=
"datetimelocal1" value=
"">
14 description('Tests if value selection by calendar picker dispatches correct events.');
16 var eventsCounter
= {};
17 function recordEvent(event
) {
18 if (eventsCounter
[event
.type
] === undefined)
19 eventsCounter
[event
.type
] = 0;
20 eventsCounter
[event
.type
]++;
21 debug('==> "' + event
.type
+ '" event was dispatched.');
24 var datetimelocal1
= document
.getElementById('datetimelocal1');
25 datetimelocal1
.addEventListener('input', recordEvent
, false);
26 datetimelocal1
.addEventListener('change', recordEvent
, false);
28 openPicker(datetimelocal1
, test1
);
31 debug('Choosing a new date value from the calendar picker. No events should be dispatched because the hour field and the minutes field are empty.');
33 eventSender
.keyDown('leftArrow');
34 eventSender
.keyDown('\n');
35 shouldBeEqualToString('datetimelocal1.value', '');
36 shouldBeUndefined('eventsCounter.input');
37 shouldBeUndefined('eventsCounter.change');
39 waitUntilClosing(test1AfterClosing
);
42 function test1AfterClosing() {
43 datetimelocal1
.value
= "2013-01-21T17:49";
44 openPicker(datetimelocal1
, test2
);
48 debug('Choosing a new value from the calendar picker. "Input" and "change" events should be dispatched in this order.');
49 eventSender
.keyDown('rightArrow');
51 eventSender
.keyDown('\n');
52 shouldBeEqualToString('datetimelocal1.value', '2013-01-22T17:49');
53 shouldBe('eventsCounter.input', '1');
54 shouldBe('eventsCounter.change', '1');