diff --git a/modules/javafx.web/src/main/java/javafx/scene/web/WebView.java b/modules/javafx.web/src/main/java/javafx/scene/web/WebView.java index 8889a6f88c8..5a78739cff2 100644 --- a/modules/javafx.web/src/main/java/javafx/scene/web/WebView.java +++ b/modules/javafx.web/src/main/java/javafx/scene/web/WebView.java @@ -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(), diff --git a/modules/javafx.web/src/test/java/test/javafx/scene/web/WebViewTest.java b/modules/javafx.web/src/test/java/test/javafx/scene/web/WebViewTest.java index f47667cdcaf..0b97ce551ec 100644 --- a/modules/javafx.web/src/test/java/test/javafx/scene/web/WebViewTest.java +++ b/modules/javafx.web/src/test/java/test/javafx/scene/web/WebViewTest.java @@ -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; @@ -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",