| <!DOCTYPE html> |
| <html> |
| <body> |
| <p tabindex="1">This tests moving the focus from a select element while its popup menu is open. WebKit should dismiss the popup.</p> |
| <select> |
| <option>Click here</option> |
| <option>You should see this</option> |
| </select> |
| <div id="result"></div> |
| <script> |
| |
| const select = document.querySelector('select'); |
| |
| if (window.testRunner) |
| testRunner.waitUntilDone(); |
| else { |
| select.addEventListener('mousedown', () => { |
| setTimeout(() => document.querySelector('p').focus(), 0); |
| }); |
| } |
| |
| window.onload = () => { |
| const event = document.createEvent("MouseEvent"); |
| event.initMouseEvent("mousedown", true, true, document.defaultView, 1, select.offsetLeft + 5, select.offsetTop + 5, select.offsetLeft + 5, select.offsetTop + 5, false, false, false, false, 0, document); |
| select.dispatchEvent(event); |
| |
| if (!window.testRunner) |
| return; |
| |
| testRunner.runUIScript(`uiController.uiScriptComplete()`, () => { |
| document.querySelector('p').focus(); |
| document.getElementById('result').textContent = internals.isSelectPopupVisible(select) ? 'FAIL' : 'PASS'; |
| testRunner.notifyDone(); |
| }); |
| } |
| |
| </script> |
| </body> |
| </html> |