| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <script src="../../../../../fast/js/resources/js-test-pre.js"></script> | |
| 5 <script src="../../../../../fast/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=""> | |
| 12 | |
| 13 <script> | |
| 14 description('Tests if value selection by calendar picker dispatches correct even
ts.'); | |
| 15 | |
| 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.'); | |
| 22 } | |
| 23 | |
| 24 var datetimelocal1 = document.getElementById('datetimelocal1'); | |
| 25 datetimelocal1.addEventListener('input', recordEvent, false); | |
| 26 datetimelocal1.addEventListener('change', recordEvent, false); | |
| 27 | |
| 28 openPicker(datetimelocal1, test1); | |
| 29 | |
| 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 eventSender.keyDown('\n'); | |
| 33 shouldBeEqualToString('datetimelocal1.value', ''); | |
| 34 shouldBeUndefined('eventsCounter.input'); | |
| 35 shouldBeUndefined('eventsCounter.change'); | |
| 36 | |
| 37 eventSender.keyDown('\x1B'); | |
| 38 waitUntilClosing(test1AfterClosing); | |
| 39 } | |
| 40 | |
| 41 function test1AfterClosing() { | |
| 42 datetimelocal1.value = "2013-01-21T17:49"; | |
| 43 openPicker(datetimelocal1, test2); | |
| 44 } | |
| 45 | |
| 46 function test2() { | |
| 47 debug('Choosing a new value from the calendar picker. "Input" and "change" e
vents should be dispatched in this order.'); | |
| 48 eventSender.keyDown('rightArrow'); | |
| 49 eventSender.keyDown('\n'); | |
| 50 shouldBeEqualToString('datetimelocal1.value', '2013-01-22T17:49'); | |
| 51 shouldBe('eventsCounter.input', '1'); | |
| 52 shouldBe('eventsCounter.change', '1'); | |
| 53 | |
| 54 finishJSTest(); | |
| 55 } | |
| 56 </script> | |
| 57 <script src="../../../../../fast/js/resources/js-test-post.js"></script> | |
| 58 </body> | |
| 59 </html> | |
| OLD | NEW |