| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="../../../resources/js-test.js"></script> | 4 <script src="../../../resources/js-test.js"></script> |
| 5 <script src="../../forms/resources/picker-common.js"></script> | 5 <script src="../../forms/resources/picker-common.js"></script> |
| 6 <script src="resources/calendar-picker-common.js"></script> | 6 <script src="resources/calendar-picker-common.js"></script> |
| 7 </head> | 7 </head> |
| 8 <body> | 8 <body> |
| 9 <p id="description"></p> | 9 <p id="description"></p> |
| 10 <div id="console"></div> | 10 <div id="console"></div> |
| 11 <input type="date" id="date1" value="2000-01-02"> | 11 <input type="date" id="date1" value="2000-01-02"> |
| 12 | 12 |
| 13 <script> | 13 <script> |
| 14 description('Tests if value selection by calendar picker dispatches correct even
ts.'); | 14 description('Tests if value selection by calendar picker dispatches correct even
ts.'); |
| 15 | 15 |
| 16 var eventsCounter = {}; | 16 var eventsCounter = {}; |
| 17 function recordEvent(event) { | 17 function recordEvent(event) { |
| 18 if (eventsCounter[event.type] === undefined) | 18 if (eventsCounter[event.type] === undefined) |
| 19 eventsCounter[event.type] = 0; | 19 eventsCounter[event.type] = 0; |
| 20 eventsCounter[event.type]++; | 20 eventsCounter[event.type]++; |
| 21 debug('==> "' + event.type + '" event was dispatched.'); | 21 debug('==> "' + event.type + '" event was dispatched.'); |
| 22 } | 22 } |
| 23 | 23 |
| 24 var date1 = document.getElementById('date1'); | 24 var date1 = document.getElementById('date1'); |
| 25 date1.addEventListener('input', recordEvent, false); | 25 date1.addEventListener('input', recordEvent, false); |
| 26 date1.addEventListener('change', recordEvent, false); | 26 date1.addEventListener('change', recordEvent, false); |
| 27 | 27 |
| 28 openPicker(date1, test1); | 28 openPickerWithMock(date1, test1); |
| 29 | 29 |
| 30 function test1() { | 30 function test1() { |
| 31 eventSender.keyDown('rightArrow'); | 31 eventSender.keyDown('rightArrow'); |
| 32 debug('Choosing a new value from the calendar picker. "input" and "change" e
vents should be dispatched in this order.'); | 32 debug('Choosing a new value from the calendar picker. "input" and "change" e
vents should be dispatched in this order.'); |
| 33 removeCommitDelay(); | 33 removeCommitDelay(); |
| 34 eventSender.keyDown('\n'); | 34 eventSender.keyDown('\n'); |
| 35 shouldBeEqualToString('date1.value', '2000-01-03'); | 35 shouldBeEqualToString('date1.value', '2000-01-03'); |
| 36 | 36 |
| 37 shouldBe('eventsCounter.input', '1'); | 37 shouldBe('eventsCounter.input', '1'); |
| 38 shouldBe('eventsCounter.change', '1'); | 38 shouldBe('eventsCounter.change', '1'); |
| 39 | 39 |
| 40 eventsCounter = {}; | 40 eventsCounter = {}; |
| 41 waitUntilClosing(function() { | 41 waitUntilClosing(function() { |
| 42 openPicker(date1, test2); | 42 openPickerWithMock(date1, test2); |
| 43 }); | 43 }); |
| 44 } | 44 } |
| 45 | 45 |
| 46 function test2() { | 46 function test2() { |
| 47 debug('Choosing the same value from the calendar picker. No events should be
dispatched.'); | 47 debug('Choosing the same value from the calendar picker. No events should be
dispatched.'); |
| 48 eventSender.keyDown('\n'); | 48 eventSender.keyDown('\n'); |
| 49 shouldBeEqualToString('date1.value', '2000-01-03'); | 49 shouldBeEqualToString('date1.value', '2000-01-03'); |
| 50 shouldBeUndefined('eventsCounter.input'); | 50 shouldBeUndefined('eventsCounter.input'); |
| 51 shouldBeUndefined('eventsCounter.change'); | 51 shouldBeUndefined('eventsCounter.change'); |
| 52 | 52 |
| 53 finishJSTest(); | 53 finishJSTest(); |
| 54 } | 54 } |
| 55 </script> | 55 </script> |
| 56 </body> | 56 </body> |
| 57 </html> | 57 </html> |
| OLD | NEW |