/** * Shortcut for {@link #fireEvent(Event)}. * @param eventType the event type (like "load", "click") * @return the execution result, or <code>null</code> if nothing is executed */ public ScriptResult fireEvent(final String eventType) { return fireEvent(new Event(this, eventType)); }
/** * Shortcut for {@link #fireEvent(Event)}. * @param eventType the event type (like "load", "click") * @return the execution result, or <code>null</code> if nothing is executed */ public ScriptResult fireEvent(final String eventType) { return fireEvent(new Event(this, eventType)); }
void performSingleKeyAction(HtmlElement element, CharSequence modifierKey, String eventDescription) { boolean shiftKey = modifierKey.equals(Keys.SHIFT); boolean ctrlKey = modifierKey.equals(Keys.CONTROL); boolean altKey = modifierKey.equals(Keys.ALT); Event keyEvent = new KeyboardEvent(element, eventDescription, 0, shiftKey, ctrlKey, altKey); element.fireEvent(keyEvent); }
/** * Shortcut for {@link #fireEvent(Event)}. * @param eventType the event type (like "load", "click") * @return the execution result, or <code>null</code> if nothing is executed */ public ScriptResult fireEvent(final String eventType) { return fireEvent(new Event(this, eventType)); }
final ScriptResult scriptResult = fireEvent(event); if (scriptResult == null) { return (P) clickPage;
final ScriptResult scriptResult = fireEvent(event); if (scriptResult == null) { return (P) clickPage;
final ScriptResult scriptResult = fireEvent(event); if (scriptResult == null) { return (P) clickPage;
/** * 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 <tt>true</tt> if SHIFT is pressed during the mouse event * @param ctrlKey <tt>true</tt> if CTRL is pressed during the mouse event * @param altKey <tt>true</tt> if ALT is pressed during the mouse event * @param button the button code, must be {@link MouseEvent#BUTTON_LEFT}, {@link MouseEvent#BUTTON_MIDDLE} * or {@link MouseEvent#BUTTON_RIGHT} * @return the page which this element's window contains after the event */ private Page doMouseEvent(final String eventType, final boolean shiftKey, final boolean ctrlKey, final boolean altKey, final int button) { if (this instanceof DisabledElement && ((DisabledElement) this).isDisabled()) { return getPage(); } final HtmlPage page = (HtmlPage) getPage(); final Event event = new MouseEvent(this, eventType, shiftKey, ctrlKey, altKey, button); final ScriptResult scriptResult = fireEvent(event); final Page currentPage; if (scriptResult == null) { currentPage = page; } else { currentPage = scriptResult.getNewPage(); } return currentPage; }
/** * 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 <tt>true</tt> if SHIFT is pressed during the mouse event * @param ctrlKey <tt>true</tt> if CTRL is pressed during the mouse event * @param altKey <tt>true</tt> if ALT is pressed during the mouse event * @param button the button code, must be {@link MouseEvent#BUTTON_LEFT}, {@link MouseEvent#BUTTON_MIDDLE} * or {@link MouseEvent#BUTTON_RIGHT} * @return the page which this element's window contains after the event */ private Page doMouseEvent(final String eventType, final boolean shiftKey, final boolean ctrlKey, final boolean altKey, final int button) { if (this instanceof DisabledElement && ((DisabledElement) this).isDisabled()) { return getPage(); } final HtmlPage page = (HtmlPage) getPage(); final Event event = new MouseEvent(this, eventType, shiftKey, ctrlKey, altKey, button); final ScriptResult scriptResult = fireEvent(event); final Page currentPage; if (scriptResult == null) { currentPage = page; } else { currentPage = scriptResult.getNewPage(); } return currentPage; }
/** * 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 <tt>true</tt> if SHIFT is pressed during the mouse event * @param ctrlKey <tt>true</tt> if CTRL is pressed during the mouse event * @param altKey <tt>true</tt> if ALT is pressed during the mouse event * @param button the button code, must be {@link MouseEvent#BUTTON_LEFT}, {@link MouseEvent#BUTTON_MIDDLE} * or {@link MouseEvent#BUTTON_RIGHT} * @return the page which this element's window contains after the event */ private Page doMouseEvent(final String eventType, final boolean shiftKey, final boolean ctrlKey, final boolean altKey, final int button) { if (this instanceof DisabledElement && ((DisabledElement) this).isDisabled()) { return getPage(); } final HtmlPage page = (HtmlPage) getPage(); final Event event = new MouseEvent(this, eventType, shiftKey, ctrlKey, altKey, button); final ScriptResult scriptResult = fireEvent(event); final Page currentPage; if (scriptResult == null) { currentPage = page; } else { currentPage = scriptResult.getNewPage(); } return currentPage; }
/** * Executes the onchange script code for this element if this is appropriate. * This means that the element must have an onchange script, script must be enabled * and the change in the element must not have been triggered by a script. * * @param htmlElement the element that contains the onchange attribute * @return the page that occupies this window after this method completes (may or * may not be the same as the original page) */ static Page executeOnChangeHandlerIfAppropriate(final HtmlElement htmlElement) { final SgmlPage page = htmlElement.getPage(); final JavaScriptEngine engine = htmlElement.getPage().getWebClient().getJavaScriptEngine(); if (engine.isScriptRunning()) { return page; } final ScriptResult scriptResult = htmlElement.fireEvent(Event.TYPE_CHANGE); if (page.getWebClient().getWebWindows().contains(page.getEnclosingWindow())) { return page.getEnclosingWindow().getEnclosedPage(); // may be itself or a newly loaded one } else if (scriptResult != null) { // current window doesn't exist anymore return scriptResult.getNewPage(); } return page; } }
/** * Executes the onchange script code for this element if this is appropriate. * This means that the element must have an onchange script, script must be enabled * and the change in the element must not have been triggered by a script. * * @param htmlElement the element that contains the onchange attribute * @return the page that occupies this window after this method completes (may or * may not be the same as the original page) */ static Page executeOnChangeHandlerIfAppropriate(final HtmlElement htmlElement) { final SgmlPage page = htmlElement.getPage(); final JavaScriptEngine engine = htmlElement.getPage().getWebClient().getJavaScriptEngine(); if (engine.isScriptRunning()) { return page; } final ScriptResult scriptResult = htmlElement.fireEvent(Event.TYPE_CHANGE); if (page.getWebClient().getWebWindows().contains(page.getEnclosingWindow())) { return page.getEnclosingWindow().getEnclosedPage(); // may be itself or a newly loaded one } else if (scriptResult != null) { // current window doesn't exist anymore return scriptResult.getNewPage(); } return page; } }
/** * Executes the onchange script code for this element if this is appropriate. * This means that the element must have an onchange script, script must be enabled * and the change in the element must not have been triggered by a script. * * @param htmlElement the element that contains the onchange attribute * @return the page that occupies this window after this method completes (may or * may not be the same as the original page) */ static Page executeOnChangeHandlerIfAppropriate(final HtmlElement htmlElement) { final SgmlPage page = htmlElement.getPage(); final JavaScriptEngine engine = htmlElement.getPage().getWebClient().getJavaScriptEngine(); if (engine.isScriptRunning()) { return page; } final ScriptResult scriptResult = htmlElement.fireEvent(Event.TYPE_CHANGE); if (page.getWebClient().getWebWindows().contains(page.getEnclosingWindow())) { return page.getEnclosingWindow().getEnclosedPage(); // may be itself or a newly loaded one } else if (scriptResult != null) { // current window doesn't exist anymore return scriptResult.getNewPage(); } return page; } }
if (element!=null) { // -- KK patch. I don't know exactly when element can be null, but Hudson tests exhibit this. final Event event = new Event(element, eventType); element.fireEvent(event); if (!isOnbeforeunloadAccepted(this, event)) { return false;
final HtmlElement element = getDocumentElement(); final Event event = new Event(element, eventType); element.fireEvent(event); if (!isOnbeforeunloadAccepted(this, event)) { return false;
stateUpdated = true; final ScriptResult scriptResult = fireEvent(event); final Page currentPage; if (scriptResult == null) {
stateUpdated = true; final ScriptResult scriptResult = fireEvent(event); final Page currentPage; if (scriptResult == null) {
/** * Executes the onchange script code for this element if this is appropriate. * This means that the element must have an onchange script, script must be enabled * and the change in the element must not have been triggered by a script. * * @param htmlElement the element that contains the onchange attribute * @return the page that occupies this window after this method completes (may or * may not be the same as the original page) */ static Page executeOnChangeHandlerIfAppropriate(final HtmlElement htmlElement) { final SgmlPage page = htmlElement.getPage(); final AbstractJavaScriptEngine<?> engine = htmlElement.getPage().getWebClient().getJavaScriptEngine(); if (engine.isScriptRunning()) { return page; } final ScriptResult scriptResult = htmlElement.fireEvent(Event.TYPE_CHANGE); if (page.getWebClient().containsWebWindow(page.getEnclosingWindow())) { // may be itself or a newly loaded one return page.getEnclosingWindow().getEnclosedPage(); } if (scriptResult != null) { // current window doesn't exist anymore return page.getWebClient().getCurrentWindow().getEnclosedPage(); } return page; }
/** * Executes the onchange script code for this element if this is appropriate. * This means that the element must have an onchange script, script must be enabled * and the change in the element must not have been triggered by a script. * * @param htmlElement the element that contains the onchange attribute * @return the page that occupies this window after this method completes (may or * may not be the same as the original page) */ static Page executeOnChangeHandlerIfAppropriate(final HtmlElement htmlElement) { final SgmlPage page = htmlElement.getPage(); final AbstractJavaScriptEngine<?> engine = htmlElement.getPage().getWebClient().getJavaScriptEngine(); if (engine.isScriptRunning()) { return page; } final ScriptResult scriptResult = htmlElement.fireEvent(Event.TYPE_CHANGE); if (page.getWebClient().containsWebWindow(page.getEnclosingWindow())) { // may be itself or a newly loaded one return page.getEnclosingWindow().getEnclosedPage(); } if (scriptResult != null) { // current window doesn't exist anymore return page.getWebClient().getCurrentWindow().getEnclosedPage(); } return page; }
final HtmlElement focusedElement = ((HtmlPage) enclosedPage).getFocusedElement(); if (focusedElement != null) { focusedElement.fireEvent(Event.TYPE_BLUR);