| 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/common.js"></script> | 5 <script src="../../forms/resources/common.js"></script> |
| 6 <script src="../../forms/resources/common-wheel-event.js"></script> | 6 <script src="../../forms/resources/common-wheel-event.js"></script> |
| 7 <script src="../../forms/resources/picker-common.js"></script> | 7 <script src="../../forms/resources/picker-common.js"></script> |
| 8 <script src="resources/suggestion-picker-common.js"></script> | 8 <script src="resources/suggestion-picker-common.js"></script> |
| 9 </head> | 9 </head> |
| 10 <body style="background-color: #bbbbbb;"> | 10 <body style="background-color: #bbbbbb;"> |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 <option>2012-11-22T01:18</option> | 32 <option>2012-11-22T01:18</option> |
| 33 <option>2012-11-22T01:19</option> | 33 <option>2012-11-22T01:19</option> |
| 34 <option>2012-11-22T01:20</option> | 34 <option>2012-11-22T01:20</option> |
| 35 <option>2012-11-22T01:21</option> | 35 <option>2012-11-22T01:21</option> |
| 36 </datalist> | 36 </datalist> |
| 37 <script> | 37 <script> |
| 38 debug('Check that page popup doesn\'t exist at first.'); | 38 debug('Check that page popup doesn\'t exist at first.'); |
| 39 shouldBeNull('$("mock-page-popup")'); | 39 shouldBeNull('$("mock-page-popup")'); |
| 40 | 40 |
| 41 window.onload = function() { | 41 window.onload = function() { |
| 42 openPicker($('datetime-local'), test1); | 42 openPickerWithMock($('datetime-local'), test1); |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 | 45 |
| 46 function test1() { | 46 function test1() { |
| 47 debug('Check that page popup exists.'); | 47 debug('Check that page popup exists.'); |
| 48 shouldBeEqualToString('popupWindow.pagePopupController.toString()', '[object
PagePopupController]'); | 48 shouldBeEqualToString('popupWindow.pagePopupController.toString()', '[object
PagePopupController]'); |
| 49 | 49 |
| 50 debug('Check that hovering over an entry highlights it.'); | 50 debug('Check that hovering over an entry highlights it.'); |
| 51 hoverOverElement(popupWindow.document.querySelector('.suggestion-list-entry:
nth-child(2)')); | 51 hoverOverElement(popupWindow.document.querySelector('.suggestion-list-entry:
nth-child(2)')); |
| 52 shouldBeEqualToString('highlightedEntry()', '2012-11-22T01:02'); | 52 shouldBeEqualToString('highlightedEntry()', '2012-11-22T01:02'); |
| 53 | 53 |
| 54 debug('Check that moving the mouse outside the popup de-highlights entries.'
); | 54 debug('Check that moving the mouse outside the popup de-highlights entries.'
); |
| 55 hoverOverElement(document.getElementById('description')); | 55 hoverOverElement(document.getElementById('description')); |
| 56 shouldBeNull('highlightedEntry()'); | 56 shouldBeNull('highlightedEntry()'); |
| 57 | 57 |
| 58 debug('Check that mouse click closes the popup and sets the value.'); | 58 debug('Check that mouse click closes the popup and sets the value.'); |
| 59 clickElement(popupWindow.document.querySelector('.suggestion-list-entry:nth-
child(3)')); | 59 clickElement(popupWindow.document.querySelector('.suggestion-list-entry:nth-
child(3)')); |
| 60 waitUntilClosing(test1AfterClosing); | 60 waitUntilClosing(test1AfterClosing); |
| 61 } | 61 } |
| 62 | 62 |
| 63 function test1AfterClosing() { | 63 function test1AfterClosing() { |
| 64 shouldBeNull('document.getElementById("mock-page-popup")'); | 64 shouldBeNull('document.getElementById("mock-page-popup")'); |
| 65 shouldBeEqualToString('document.getElementById("datetime-local").value', '20
12-11-22T01:03'); | 65 shouldBeEqualToString('document.getElementById("datetime-local").value', '20
12-11-22T01:03'); |
| 66 | 66 |
| 67 openPicker($('datetime-local'), test2); | 67 openPickerWithMock($('datetime-local'), test2); |
| 68 } | 68 } |
| 69 | 69 |
| 70 var scrollTopBeforeWheelEvent = 0; | 70 var scrollTopBeforeWheelEvent = 0; |
| 71 var scrollTopAfterWheelEvent = 0; | 71 var scrollTopAfterWheelEvent = 0; |
| 72 | 72 |
| 73 function test2() { | 73 function test2() { |
| 74 var suggestionList = popupWindow.document.getElementsByClassName('suggestion
-list')[0]; | 74 var suggestionList = popupWindow.document.getElementsByClassName('suggestion
-list')[0]; |
| 75 | 75 |
| 76 debug('Check that you can scroll using the mouse wheel.'); | 76 debug('Check that you can scroll using the mouse wheel.'); |
| 77 | 77 |
| 78 scrollTopBeforeWheelEvent = suggestionList.scrollTop; | 78 scrollTopBeforeWheelEvent = suggestionList.scrollTop; |
| 79 dispatchWheelEvent(suggestionList, 0, -100); | 79 dispatchWheelEvent(suggestionList, 0, -100); |
| 80 scrollTopAfterWheelEvent = suggestionList.scrollTop; | 80 scrollTopAfterWheelEvent = suggestionList.scrollTop; |
| 81 shouldBeTrue('scrollTopBeforeWheelEvent < scrollTopAfterWheelEvent'); | 81 shouldBeTrue('scrollTopBeforeWheelEvent < scrollTopAfterWheelEvent'); |
| 82 | 82 |
| 83 scrollTopBeforeWheelEvent = suggestionList.scrollTop; | 83 scrollTopBeforeWheelEvent = suggestionList.scrollTop; |
| 84 dispatchWheelEvent(suggestionList, 0, 100); | 84 dispatchWheelEvent(suggestionList, 0, 100); |
| 85 scrollTopAfterWheelEvent = suggestionList.scrollTop; | 85 scrollTopAfterWheelEvent = suggestionList.scrollTop; |
| 86 shouldBeTrue('scrollTopBeforeWheelEvent > scrollTopAfterWheelEvent'); | 86 shouldBeTrue('scrollTopBeforeWheelEvent > scrollTopAfterWheelEvent'); |
| 87 | 87 |
| 88 popupWindow.focus(); | 88 popupWindow.focus(); |
| 89 eventSender.keyDown('escape'); | 89 eventSender.keyDown('escape'); |
| 90 waitUntilClosing(test2AfterClosing); | 90 waitUntilClosing(test2AfterClosing); |
| 91 } | 91 } |
| 92 | 92 |
| 93 function test2AfterClosing() { | 93 function test2AfterClosing() { |
| 94 shouldBeNull('$("mock-page-popup")'); | 94 shouldBeNull('$("mock-page-popup")'); |
| 95 | 95 |
| 96 openPicker($('datetime-local'), test3); | 96 openPickerWithMock($('datetime-local'), test3); |
| 97 } | 97 } |
| 98 | 98 |
| 99 function test3() { | 99 function test3() { |
| 100 debug('Check that you can scroll using the scroll bar.'); | 100 debug('Check that you can scroll using the scroll bar.'); |
| 101 | 101 |
| 102 var suggestionList = popupWindow.document.getElementsByClassName('suggestion
-list')[0]; | 102 var suggestionList = popupWindow.document.getElementsByClassName('suggestion
-list')[0]; |
| 103 var suggestionListOffset = cumulativeOffset(suggestionList); | 103 var suggestionListOffset = cumulativeOffset(suggestionList); |
| 104 var scrollbarCenterX = suggestionListOffset[0] + suggestionList.offsetWidth
- popupWindow.getScrollbarWidth() / 2; | 104 var scrollbarCenterX = suggestionListOffset[0] + suggestionList.offsetWidth
- popupWindow.getScrollbarWidth() / 2; |
| 105 | 105 |
| 106 scrollTopBeforeWheelEvent = suggestionList.scrollTop; | 106 scrollTopBeforeWheelEvent = suggestionList.scrollTop; |
| 107 eventSender.mouseMoveTo(scrollbarCenterX, suggestionListOffset[1] + 20); //
20 is the height of the up arrow button plus a few pixels | 107 eventSender.mouseMoveTo(scrollbarCenterX, suggestionListOffset[1] + 20); //
20 is the height of the up arrow button plus a few pixels |
| 108 eventSender.mouseDown(); | 108 eventSender.mouseDown(); |
| 109 eventSender.mouseMoveTo(scrollbarCenterX, suggestionListOffset[1] + suggesti
onList.offsetHeight); | 109 eventSender.mouseMoveTo(scrollbarCenterX, suggestionListOffset[1] + suggesti
onList.offsetHeight); |
| 110 eventSender.mouseUp(); | 110 eventSender.mouseUp(); |
| 111 scrollTopAfterWheelEvent = suggestionList.scrollTop; | 111 scrollTopAfterWheelEvent = suggestionList.scrollTop; |
| 112 shouldBeTrue('scrollTopBeforeWheelEvent < scrollTopAfterWheelEvent'); | 112 shouldBeTrue('scrollTopBeforeWheelEvent < scrollTopAfterWheelEvent'); |
| 113 | 113 |
| 114 finishJSTest(); | 114 finishJSTest(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 </script> | 117 </script> |
| 118 </body> | 118 </body> |
| 119 </html> | 119 </html> |
| OLD | NEW |