| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../../../resources/testharness.js"></script> |
| <script src="../../../resources/testharnessreport.js"></script> |
| <script src="../resources/common.js"></script> |
| <script src="../resources/picker-common.js"></script> |
| <script src="../calendar-picker/resources/calendar-picker-common.js"></script> |
| </head> |
| <body> |
| <input type="week" id="week-0" value="2018-W23"> |
| <script> |
| |
| promise_test(() => { |
| let weekElement = document.getElementById('week-0'); |
| return openPickerWithPromise(weekElement) |
| .then(() => { |
| eventSender.keyDown('Home'); |
| assert_equals(weekElement.value, "2018-W22", "Home hotkey should go to the first week of the month"); |
| |
| for (let week of [18, 13,9,5,1]) { |
| eventSender.keyDown('Home'); |
| assert_equals(weekElement.value, "2018-W" + ("0" + week).substr(-2), "Home hotkey should go to the first week of the previous month"); |
| } |
| |
| eventSender.keyDown('Home'); |
| assert_equals(weekElement.value, "2017-W48", "Home hotkey should wrap to the previous year"); |
| |
| eventSender.keyDown('End'); |
| assert_equals(weekElement.value, "2017-W52", "End hotkey should go to the end week of the month"); |
| |
| eventSender.keyDown('End'); |
| assert_equals(weekElement.value, "2018-W05", "End hotkey should go to the end week of the next month (wrapping to next year)"); |
| |
| eventSender.keyDown('Enter'); |
| assert_equals(internals.pagePopupWindow, null, "Enter key should have closed popup."); |
| }); |
| }, "Week picker: Home/end month hotkeys"); |
| |
| </script> |
| </body> |
| </html> |