I have a sample JavaFX application with WebView loading HTML from local file. In HTML I’m opening websocket (to wss://echo.websocket.org/) and defining onopen, onmessage and onerror callbacks.
When I run it with 8u401 I see popups, but I don’t see anything for 8u411.
I was able to reproduce it on Windows 10 and MacOS.
Java code to reproduce:
package org.example.javafx;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.scene.web.WebEvent;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
import javax.swing.*;
import java.net.URL;
public class WebViewExample extends Application {
public static void main(String[] args) {
launch(args);
}
public void start(Stage primaryStage) {
primaryStage.setTitle("JavaFX WebView Example running with " + Runtime.class.getPackage().getImplementationVersion());
WebView webView = new WebView();
webView.getEngine().setOnAlert(new EventHandler<WebEvent<String>>(){
public void handle(WebEvent<String> arg0) {
JOptionPane.showMessageDialog(null, arg0.getData(),"Mensaje", JOptionPane.INFORMATION_MESSAGE);
}
});
URL url = this.getClass().getResource("main.html");
webView.getEngine().load(url.toString());
VBox vBox = new VBox(webView);
Scene scene = new Scene(vBox, 960, 600);
primaryStage.setScene(scene);
primaryStage.show();
}
}
and HTML file:
<!DOCTYPE html>
<html>
<body>
<script>
let socket = new WebSocket("wss://echo.websocket.org/");
socket.onopen = function(e) {
alert("[open] Connection established");
socket.send("My name is John");
};
socket.onmessage = function(event) {
alert('[message] Data received from server!');
};
socket.onerror = function(event) {
alert("ERROR!");
};
</script>
</body>
</html>
Is there anything missing?
I have tried 32bit, 64bit JRE, Mac OS and Windows.