title: JavaFX WebView up call from JavaScript doesn't work
body: <p>I have a JavaFX WebView and want to call the method "hello" of the class "JavaBridge" from "test.html" displayed in the webview. 
  Why doesn't this work? I making sure that the "bridge" object only be added to the window.object when the page has been fully rendered, so that is probably not the problem. I can't see any problem with the HTML either. </p>
  
  <p>Here is the HTML code ("test.html"):</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;a href="#click" onclick="bridge.hello()"&gt;call java&lt;/a&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And here is the Java Code:</p>
  
  <pre><code>import javafx.application.Application;
  import javafx.beans.value.ChangeListener;
  import javafx.beans.value.ObservableValue;
  import javafx.concurrent.Worker;
  import javafx.concurrent.Worker.State;
  import javafx.scene.Scene;
  import javafx.scene.control.Button;
  import javafx.scene.layout.StackPane;
  import javafx.stage.Stage;
  import javafx.scene.web.WebEngine;
  import javafx.scene.web.WebView;
  import netscape.javascript.JSObject;
  
  public class HelloWorld extends Application {
  
    public static void main(String[] args) {
      launch(args);
    }
  
    @Override
    public void start(Stage primaryStage) {
  
      java.net.URI uri = java.nio.file.Paths.get("test.html").toAbsolutePath().toUri();
      WebView root = new javafx.scene.web.WebView();
      root.getEngine().load(uri.toString());
  
      root.getEngine().
      getLoadWorker().
      stateProperty().
      addListener(new ChangeListener &lt; State &gt; () {
        @Override public void changed(ObservableValue ov, State oldState, State newState) {
  
          if (newState == Worker.State.SUCCEEDED) {
            System.out.println("READY");
            JSObject jsobj = (JSObject) root.getEngine().executeScript("window");
            jsobj.setMember("bridge", new JavaBridge());
          }
  
        }
      });
      primaryStage.setScene(new javafx.scene.Scene(root, 800, 600));
      primaryStage.show();
    }
  }
  
  class JavaBridge {
    public void hello() {
      System.out.println("hello");
    }
  }
  </code></pre>