Simulates the specified mouse event, returning the page which this element's window contains after the event. The returned page may or may not be the same as the original page, depending on JavaScript event handlers, etc. @param eventType the mouse event type to simulate @param shiftKey {@code true
(final String eventType, final boolean shiftKey, final boolean ctrlKey,
final boolean altKey, final int button)
| 1470 | * @return the page which this element's window contains after the event |
| 1471 | */ |
| 1472 | private Page doMouseEvent(final String eventType, final boolean shiftKey, final boolean ctrlKey, |
| 1473 | final boolean altKey, final int button) { |
| 1474 | final SgmlPage page = getPage(); |
| 1475 | final WebClient webClient = getPage().getWebClient(); |
| 1476 | if (!webClient.isJavaScriptEnabled()) { |
| 1477 | return page; |
| 1478 | } |
| 1479 | |
| 1480 | final ScriptResult scriptResult; |
| 1481 | final Event event; |
| 1482 | if (MouseEvent.TYPE_CONTEXT_MENU.equals(eventType)) { |
| 1483 | final BrowserVersion browserVersion = webClient.getBrowserVersion(); |
| 1484 | if (browserVersion.hasFeature(EVENT_CONTEXT_MENU_HAS_DETAIL_1)) { |
| 1485 | event = new PointerEvent(this, eventType, shiftKey, ctrlKey, altKey, button, 1); |
| 1486 | } |
| 1487 | else { |
| 1488 | event = new PointerEvent(this, eventType, shiftKey, ctrlKey, altKey, button, 0); |
| 1489 | } |
| 1490 | } |
| 1491 | else if (MouseEvent.TYPE_DBL_CLICK.equals(eventType)) { |
| 1492 | event = new MouseEvent(this, eventType, shiftKey, ctrlKey, altKey, button, 2); |
| 1493 | } |
| 1494 | else { |
| 1495 | event = new MouseEvent(this, eventType, shiftKey, ctrlKey, altKey, button, 1); |
| 1496 | } |
| 1497 | scriptResult = fireEvent(event); |
| 1498 | |
| 1499 | final Page currentPage; |
| 1500 | if (scriptResult == null) { |
| 1501 | currentPage = page; |
| 1502 | } |
| 1503 | else { |
| 1504 | currentPage = webClient.getCurrentWindow().getEnclosedPage(); |
| 1505 | } |
| 1506 | |
| 1507 | final boolean mouseOver = !MouseEvent.TYPE_MOUSE_OUT.equals(eventType); |
| 1508 | if (mouseOver_ != mouseOver) { |
| 1509 | mouseOver_ = mouseOver; |
| 1510 | |
| 1511 | page.clearComputedStyles(); |
| 1512 | } |
| 1513 | |
| 1514 | return currentPage; |
| 1515 | } |
| 1516 | |
| 1517 | /** |
| 1518 | * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span><br> |
no test coverage detected