Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / calendar-picker / datetimelocal-picker-events.html
blob75a0cb3ab9a6cbc7a2b493bb96f55cb649b08712
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="datetime-local" id="datetimelocal1" value="">
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 datetimelocal1 = document.getElementById('datetimelocal1');
25 datetimelocal1.addEventListener('input', recordEvent, false);
26 datetimelocal1.addEventListener('change', recordEvent, false);
28 openPicker(datetimelocal1, test1);
30 function 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.');
32 removeCommitDelay();
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);
47 function 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');
50 removeCommitDelay();
51 eventSender.keyDown('\n');
52 shouldBeEqualToString('datetimelocal1.value', '2013-01-22T17:49');
53 shouldBe('eventsCounter.input', '1');
54 shouldBe('eventsCounter.change', '1');
56 finishJSTest();
58 </script>
59 </body>
60 </html>