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=
"date" id=
"date1" value=
"2000-01-02">
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 date1
= document
.getElementById('date1');
25 date1
.addEventListener('input', recordEvent
, false);
26 date1
.addEventListener('change', recordEvent
, false);
28 openPicker(date1
, test1
);
31 eventSender
.keyDown('rightArrow');
32 debug('Choosing a new value from the calendar picker. "input" and "change" events should be dispatched in this order.');
34 eventSender
.keyDown('\n');
35 shouldBeEqualToString('date1.value', '2000-01-03');
37 shouldBe('eventsCounter.input', '1');
38 shouldBe('eventsCounter.change', '1');
41 waitUntilClosing(function() {
42 openPicker(date1
, test2
);
47 debug('Choosing the same value from the calendar picker. No events should be dispatched.');
48 eventSender
.keyDown('\n');
49 shouldBeEqualToString('date1.value', '2000-01-03');
50 shouldBeUndefined('eventsCounter.input');
51 shouldBeUndefined('eventsCounter.change');