Skip to content

Commit

Permalink
8236912: NullPointerException when clicking in WebView with Button 4 …
Browse files Browse the repository at this point in the history
…or Button 5

Reviewed-by: ghb, kcr
  • Loading branch information
Robert Lichtenberger authored and kevinrushforth committed Jan 27, 2020
1 parent da99e24 commit aa6f3a4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -994,12 +994,13 @@ private void processMouseEvent(MouseEvent ev) {
}

final Integer id = idMap.get(type);
if (id == null) {
final Integer button = idMap.get(ev.getButton());
if (id == null || button == null) {
// not supported by webkit
return;
}
WCMouseEvent mouseEvent =
new WCMouseEvent(id, idMap.get(ev.getButton()),
new WCMouseEvent(id, button,
ev.getClickCount(), (int) x, (int) y,
(int) screenX, (int) screenY,
System.currentTimeMillis(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
import java.io.File;
import java.util.concurrent.FutureTask;

import javafx.application.Platform;
import javafx.event.Event;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;
import javafx.scene.web.WebEngineShim;
import javafx.scene.web.WebView;

Expand All @@ -54,6 +56,18 @@ public class WebViewTest extends TestBase {
checkZoom(view, ZOOM);
}

@Test public void testForwardMouseButton() {
WebView view = getView();
Event forward = new MouseEvent(MouseEvent.MOUSE_PRESSED, 0, 0, 0, 0, MouseButton.FORWARD, 1, false, false, false, false, false, false, false, false, true, true, false, true, null);
view.fireEvent(forward); // must not throw NullPointerException (JDK-8236912)
}

@Test public void testBackMouseButton() {
WebView view = getView();
Event back = new MouseEvent(MouseEvent.MOUSE_PRESSED, 0, 0, 0, 0, MouseButton.BACK, 1, false, false, false, false, false, false, false, true, false, true, false, true, null);
view.fireEvent(back); // must not throw NullPointerException (JDK-8236912)
}

void checkFontScale(WebView view, float scale) {
assertEquals("WebView.fontScale", scale, view.getFontScale(), DELTA);
assertEquals("WebPage.zoomFactor",
Expand Down

0 comments on commit aa6f3a4

Please sign in to comment.