Skip to content

Commit

Permalink
HtmlUnitMouse: no need to .focus()
Browse files Browse the repository at this point in the history
Previously, HtmlUnit didn't correctly handle
'focus' event on .click()ing an element,
but now it does.  This change fixes a test case

Also, the constructor with HtmlUnitDriver
is not needed, so it is deprecated.

Signed-off-by: Luke Inman-Semerau <[email protected]>
  • Loading branch information
asashour authored and lukeis committed Aug 22, 2015
1 parent c181d39 commit 409699b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ protected void get(URL fullUrl) {

private void resetKeyboardAndMouseState() {
keyboard = new HtmlUnitKeyboard(this);
mouse = new HtmlUnitMouse(this, keyboard);
mouse = new HtmlUnitMouse(keyboard);
}

protected void pickWindow() {
Expand Down
17 changes: 9 additions & 8 deletions java/client/src/org/openqa/selenium/htmlunit/HtmlUnitMouse.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import com.gargoylesoftware.htmlunit.ScriptException;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlInput;
import com.gargoylesoftware.htmlunit.javascript.host.event.MouseEvent;
import com.google.common.base.Preconditions;

Expand All @@ -35,15 +34,21 @@
*
*/
public class HtmlUnitMouse implements Mouse {
private final HtmlUnitDriver parent;
private final HtmlUnitKeyboard keyboard;
private HtmlElement currentActiveElement = null;

public HtmlUnitMouse(HtmlUnitDriver parent, HtmlUnitKeyboard keyboard) {
this.parent = parent;
public HtmlUnitMouse(HtmlUnitKeyboard keyboard) {
this.keyboard = keyboard;
}

/**
* @deprecated as of 2.47.0, please use {@link #HtmlUnitMouse(HtmlUnitKeyboard)} instead
*/
@Deprecated
public HtmlUnitMouse(HtmlUnitDriver parent, HtmlUnitKeyboard keyboard) {
this(keyboard);
}

private HtmlElement getElementForOperation(Coordinates potentialCoordinates) {
if (potentialCoordinates != null) {
return (HtmlElement) potentialCoordinates.getAuxiliary();
Expand All @@ -64,10 +69,6 @@ public void click(Coordinates elementCoordinates) {
moveOutIfNeeded(element);

try {
if (!(element instanceof HtmlInput)) {
element.focus();
}

element.mouseOver();
element.mouseMove();

Expand Down
10 changes: 4 additions & 6 deletions java/client/test/org/openqa/selenium/CorrectEventFiringTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,17 @@
import static org.openqa.selenium.testing.Ignore.Driver.MARIONETTE;
import static org.openqa.selenium.testing.Ignore.Driver.SAFARI;

import java.io.File;
import java.io.IOException;
import java.util.List;

import org.junit.Test;
import org.openqa.selenium.testing.Ignore;
import org.openqa.selenium.testing.JUnit4TestBase;
import org.openqa.selenium.testing.JavascriptEnabled;
import org.openqa.selenium.testing.NotYetImplemented;
import org.openqa.selenium.testing.TestUtilities;
import org.openqa.selenium.testing.drivers.SauceDriver;

import java.io.File;
import java.io.IOException;
import java.util.List;

public class CorrectEventFiringTest extends JUnit4TestBase {

@Ignore(value = {MARIONETTE})
Expand Down Expand Up @@ -126,7 +125,6 @@ public void testShouldNotThrowIfEventHandlerThrows() {

@Ignore(MARIONETTE)
@JavascriptEnabled
@NotYetImplemented(HTMLUNIT)
@Test
public void testShouldFireEventsInTheRightOrder() {
driver.get(pages.javascriptPage);
Expand Down

0 comments on commit 409699b

Please sign in to comment.