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

WebEngine document becomes null after PAGE_REPLACED event

    Details

    • Subcomponent:
      web
    • Introduced In Build:
      b01
    • Introduced In Version:
    • CPU:
      x86_64
    • OS:
      generic

      Backports

        Description

        A DESCRIPTION OF THE PROBLEM :
        the document of the WebEngine return nulls after the PAGE_REPLACED event. Probably because the PAGE_REPLACED events set the boolean invalidate to false which causes the getDocument to always return null.

        REGRESSION : Last worked in version 8u162

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Load the following url in the WebEngine https://movies-finder.firebaseapp.com/
        After clicking on one of the menu items ( which triggers the PAGE_REPLACED event),
        The document of the webEngine returns null


        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        The document of the webEngine is the same as Document e = (Document) engine.executeScript("document");
        ACTUAL -
        The document of the webEngine is null

        ---------- BEGIN SOURCE ----------
        import javax.swing.JFrame;

        import org.w3c.dom.Document;

        import javafx.application.Platform;
        import javafx.beans.value.ChangeListener;
        import javafx.beans.value.ObservableValue;
        import javafx.embed.swing.JFXPanel;
        import javafx.scene.Scene;
        import javafx.scene.web.WebEngine;
        import javafx.scene.web.WebView;

        public class TestCase_001 {
        public static void main(String[] args) {
        Platform.setImplicitExit(false);

        JFrame frame = new JFrame("JFXTest");
        frame.setSize(1400, 1000);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JFXPanel jfxPanel = new JFXPanel();

        Platform.runLater(() -> {
        WebView webView = new WebView();
        final WebEngine engine = webView.getEngine();
        engine.load("https://movies-finder.firebaseapp.com/");
        engine.documentProperty().addListener(new ChangeListener<Document>() {
        @Override
        public void changed(ObservableValue<? extends Document> prop, Document oldDoc, Document newDoc) {
        System.out.println("old document " + oldDoc);
        System.out.println("new document " + newDoc);

        Document e = (Document) engine.executeScript("document");
        Document e2 = engine.getDocument();
        System.out.println("document from script " + e);
        System.out.println("document from engine " + e2);
        }
        });
        Scene scene = new Scene(webView);
        jfxPanel.setScene(scene);
        });

        frame.add(jfxPanel);
        frame.setVisible(true);
        }
        }
        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
         Object obj = engine.documentProperty();
                    System.out.println(Arrays.toString(obj.getClass().getDeclaredMethods()));
                    Method method = obj.getClass().getDeclaredMethod("invalidate",Boolean.TYPE);
                    if (method!=null){
                        method.setAccessible(true);
                        method.invoke(obj, true);
                    }

        FREQUENCY : always


          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  arajkumar Arunprasad Rajkumar
                  Reporter:
                  webbuggrp Webbug Group
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  5 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: