| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <script src="../../../resources/js-test.js"></script> | |
| 5 <script src="../resources/common.js"></script> | |
| 6 <script src="../resources/picker-common.js"></script> | |
| 7 </head> | |
| 8 <body> | |
| 9 <select id="menu"> | |
| 10 <option>foo</option> | |
| 11 <option selected>bar</option> | |
| 12 <option hidden>baz</option> | |
| 13 <optgroup label="qux"> | |
| 14 <option>garply</option> | |
| 15 </optgroup> | |
| 16 </select> | |
| 17 <script> | |
| 18 var menu = document.getElementById('menu'); | |
| 19 var picker = null; | |
| 20 function openPickerErrorCallback() { | |
| 21 testFailed('picker didn\'t open') | |
| 22 finishJSTest(); | |
| 23 } | |
| 24 openPicker(menu, test1, openPickerErrorCallback); | |
| 25 | |
| 26 function test1() { | |
| 27 picker = window.internals.pagePopupWindow.global.picker; | |
| 28 shouldBeEqualToString('picker._selectElement.value', '1'); | |
| 29 shouldBeEqualToString('menu.value', 'bar'); | |
| 30 shouldBeEqualToString('internals.selectMenuListText(menu)', 'bar'); | |
| 31 | |
| 32 eventSender.keyDown('downArrow'); | |
| 33 shouldBeEqualToString('picker._selectElement.value', '4'); | |
| 34 shouldBeEqualToString('menu.value', 'bar'); | |
| 35 shouldBeEqualToString('internals.selectMenuListText(menu)', 'garply'); | |
| 36 | |
| 37 eventSender.keyDown('downArrow'); | |
| 38 shouldBeEqualToString('picker._selectElement.value', '4'); | |
| 39 shouldBeEqualToString('menu.value', 'bar'); | |
| 40 shouldBeEqualToString('internals.selectMenuListText(menu)', 'garply'); | |
| 41 | |
| 42 eventSender.keyDown('upArrow'); | |
| 43 shouldBeEqualToString('picker._selectElement.value', '1'); | |
| 44 shouldBeEqualToString('menu.value', 'bar'); | |
| 45 shouldBeEqualToString('internals.selectMenuListText(menu)', 'bar'); | |
| 46 | |
| 47 eventSender.keyDown('upArrow'); | |
| 48 shouldBeEqualToString('picker._selectElement.value', '0'); | |
| 49 shouldBeEqualToString('menu.value', 'bar'); | |
| 50 shouldBeEqualToString('internals.selectMenuListText(menu)', 'foo'); | |
| 51 | |
| 52 eventSender.keyDown('upArrow'); | |
| 53 shouldBeEqualToString('picker._selectElement.value', '0'); | |
| 54 shouldBeEqualToString('menu.value', 'bar'); | |
| 55 shouldBeEqualToString('internals.selectMenuListText(menu)', 'foo'); | |
| 56 | |
| 57 eventSender.keyDown('\n'); | |
| 58 shouldBeNull('window.internals.pagePopupWindow'); | |
| 59 shouldBeEqualToString('menu.value', 'foo'); | |
| 60 shouldBeEqualToString('internals.selectMenuListText(menu)', 'foo'); | |
| 61 | |
| 62 waitUntilClosing(function() { | |
| 63 openPicker(menu, test2, openPickerErrorCallback); | |
| 64 }); | |
| 65 } | |
| 66 | |
| 67 function test2() { | |
| 68 picker = window.internals.pagePopupWindow.global.picker; | |
| 69 shouldBeEqualToString('picker._selectElement.value', '0'); | |
| 70 shouldBeEqualToString('internals.selectMenuListText(menu)', 'foo'); | |
| 71 | |
| 72 eventSender.keyDown('downArrow'); | |
| 73 shouldBeEqualToString('picker._selectElement.value', '1'); | |
| 74 shouldBeEqualToString('menu.value', 'foo'); | |
| 75 shouldBeEqualToString('internals.selectMenuListText(menu)', 'bar'); | |
| 76 | |
| 77 // Escape should close the popup and select that keyboard selected item. | |
| 78 eventSender.keyDown('escape'); | |
| 79 shouldBeNull('window.internals.pagePopupWindow'); | |
| 80 shouldBeEqualToString('menu.value', 'bar'); | |
| 81 shouldBeEqualToString('internals.selectMenuListText(menu)', 'bar'); | |
| 82 | |
| 83 waitUntilClosing(function() { | |
| 84 openPicker(menu, test3, openPickerErrorCallback); | |
| 85 }); | |
| 86 } | |
| 87 | |
| 88 function test3() { | |
| 89 picker = window.internals.pagePopupWindow.global.picker; | |
| 90 shouldBeEqualToString('picker._selectElement.value', '1'); | |
| 91 shouldBeEqualToString('internals.selectMenuListText(menu)', 'bar'); | |
| 92 | |
| 93 eventSender.keyDown('g'); | |
| 94 shouldBeEqualToString('picker._selectElement.value', '4'); | |
| 95 shouldBeEqualToString('menu.value', 'bar'); | |
| 96 shouldBeEqualToString('internals.selectMenuListText(menu)', 'garply'); | |
| 97 | |
| 98 // Escape should close the popup and select that keyboard selected item. | |
| 99 eventSender.keyDown('escape'); | |
| 100 shouldBeNull('window.internals.pagePopupWindow'); | |
| 101 shouldBeEqualToString('menu.value', 'garply'); | |
| 102 shouldBeEqualToString('internals.selectMenuListText(menu)', 'garply'); | |
| 103 | |
| 104 waitUntilClosing(function() { | |
| 105 openPicker(menu, test4, openPickerErrorCallback); | |
| 106 }); | |
| 107 } | |
| 108 | |
| 109 function test4() { | |
| 110 picker = window.internals.pagePopupWindow.global.picker; | |
| 111 shouldBeEqualToString('picker._selectElement.value', '4'); | |
| 112 shouldBeEqualToString('internals.selectMenuListText(menu)', 'garply'); | |
| 113 | |
| 114 hoverOverElement(picker._selectElement.children[0]); | |
| 115 shouldBeEqualToString('picker._selectElement.value', '0'); | |
| 116 shouldBeEqualToString('menu.value', 'garply'); | |
| 117 shouldBeEqualToString('internals.selectMenuListText(menu)', 'garply'); | |
| 118 | |
| 119 // Escape should close the popup. Simply hovering over an item should not se
lect it. | |
| 120 eventSender.keyDown('escape'); | |
| 121 shouldBeNull('window.internals.pagePopupWindow'); | |
| 122 shouldBeEqualToString('menu.value', 'garply'); | |
| 123 shouldBeEqualToString('internals.selectMenuListText(menu)', 'garply'); | |
| 124 | |
| 125 waitUntilClosing(function() { | |
| 126 openPicker(menu, test5, openPickerErrorCallback); | |
| 127 }); | |
| 128 } | |
| 129 | |
| 130 function test5() { | |
| 131 picker = window.internals.pagePopupWindow.global.picker; | |
| 132 shouldBeEqualToString('picker._selectElement.value', '4'); | |
| 133 shouldBeEqualToString('internals.selectMenuListText(menu)', 'garply'); | |
| 134 | |
| 135 hoverOverElement(picker._selectElement.children[0]); | |
| 136 shouldBeEqualToString('picker._selectElement.value', '0'); | |
| 137 shouldBeEqualToString('menu.value', 'garply'); | |
| 138 shouldBeEqualToString('internals.selectMenuListText(menu)', 'garply'); | |
| 139 | |
| 140 // leftArrow doesn't change the selection in the popup. So, | |
| 141 // selectMenuListText won't change. | |
| 142 eventSender.keyDown('leftArrow'); | |
| 143 shouldBeEqualToString('picker._selectElement.value', '0'); | |
| 144 shouldBeEqualToString('menu.value', 'garply'); | |
| 145 shouldBeEqualToString('internals.selectMenuListText(menu)', 'garply'); | |
| 146 | |
| 147 eventSender.keyDown('escape'); | |
| 148 shouldBeNull('window.internals.pagePopupWindow'); | |
| 149 shouldBeEqualToString('menu.value', 'garply'); | |
| 150 shouldBeEqualToString('internals.selectMenuListText(menu)', 'garply'); | |
| 151 menu.selectedIndex = 0; | |
| 152 | |
| 153 waitUntilClosing(function() { | |
| 154 openPicker(menu, test6, openPickerErrorCallback); | |
| 155 }); | |
| 156 } | |
| 157 | |
| 158 function test6() { | |
| 159 picker = window.internals.pagePopupWindow.global.picker; | |
| 160 shouldBeEqualToString('picker._selectElement.value', '0'); | |
| 161 shouldBeEqualToString('internals.selectMenuListText(menu)', 'foo'); | |
| 162 | |
| 163 eventSender.keyDown('downArrow'); | |
| 164 shouldBeEqualToString('picker._selectElement.value', '1'); | |
| 165 shouldBeEqualToString('menu.value', 'foo'); | |
| 166 shouldBeEqualToString('internals.selectMenuListText(menu)', 'bar'); | |
| 167 | |
| 168 clickElement(picker._selectElement.children[0]); | |
| 169 shouldBeNull('window.internals.pagePopupWindow'); | |
| 170 shouldBeEqualToString('menu.value', 'foo'); | |
| 171 shouldBeEqualToString('internals.selectMenuListText(menu)', 'foo'); | |
| 172 | |
| 173 finishJSTest(); | |
| 174 } | |
| 175 </script> | |
| 176 </body> | |
| 177 </html> | |
| OLD | NEW |