Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8193493

WebView fails to render content when opened inside of an Alert (or Dialog)

XMLWordPrintable

    • web
    • x86
    • other

      FULL PRODUCT VERSION :
      java version "9.0.1"
      Java(TM) SE Runtime Environment (build 9.0.1+11)
      Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 10.0.16299.64]

      A DESCRIPTION OF THE PROBLEM :
      When an Alert uses a WebView in its content - the html is not rendered.




      REGRESSION. Last worked in version 8u162

      ADDITIONAL REGRESSION INFORMATION:
      I have validate with JDK 1.8.0_162 that the contents of the WebView are rendered correctly as expected. I used the exact same code snippet mentioned below (steps to reproduce section).

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Build the following code and run with Java 9.0.1
      Click the button and the alert pops up, however the WebView content is not rendered


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      webview content should be rendered and visible in the alert
      ACTUAL -
      webview content is not rendered, the alert is empty

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.Alert;
      import javafx.scene.control.Button;
      import javafx.scene.layout.Pane;
      import javafx.scene.layout.StackPane;
      import javafx.scene.web.WebView;
      import javafx.stage.Stage;

      public class Broken extends Application {
          @Override
          public void start(Stage stage) {
              stage.setTitle("No WebView!");

              Button button = new Button("Open Alert");
              button.setOnMouseClicked(event -> {
                  WebView webView = new WebView();
                  webView.getEngine().load("http://example.com");

                  StackPane pane = new StackPane(webView);
                  pane.setPrefSize(500, 400);

                  Alert alert = new Alert(Alert.AlertType.INFORMATION);
                  alert.getDialogPane().setHeader(new Pane());
                  alert.setTitle("dialog shows nothing");
                  alert.getDialogPane().setContent(pane);
                  alert.showAndWait();
              });

              StackPane pane = new StackPane(button);
              stage.setScene(new Scene(pane, 800, 600));

              stage.show();
          }

          public static void main(String[] args) {
              Application.launch(args);
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      none really, but I have found that showing a WebView within a new Stage (rather than using a dialog) works fine.

            pmangal Priyanka Mangal (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: