Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / calendar-picker / date-picker-events.html
blob4fd9eec611b91b4ef653a193d65330e3b23b40a1
1 <!DOCTYPE html>
2 <html>
3 <head>
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>
7 </head>
8 <body>
9 <p id="description"></p>
10 <div id="console"></div>
11 <input type="date" id="date1" value="2000-01-02">
13 <script>
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);
30 function 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.');
33 removeCommitDelay();
34 eventSender.keyDown('\n');
35 shouldBeEqualToString('date1.value', '2000-01-03');
37 shouldBe('eventsCounter.input', '1');
38 shouldBe('eventsCounter.change', '1');
40 eventsCounter = {};
41 waitUntilClosing(function() {
42 openPicker(date1, test2);
43 });
46 function 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');
53 finishJSTest();
55 </script>
56 </body>
57 </html>