8 Replies Latest reply on Sep 24, 2012 11:43 AM by anouard

    WebEngine HTML/JavaScript errors

    bgoetzmann
      Hello,

      Is there a way to kwown if the WebView's WebEngine has detected HTML/JavaScript errors when loading content? And is there a way to list these errors?


      Cheers,

      Bertrand
        • 1. Re: WebEngine HTML/JavaScript errors
          jsmith
          Couldn't tell you the canonical way to do this.

          Some thoughts:
          1. There is a new debug API for WebView in 2.2, perhaps that may also be of use to you.
          2. Firebug Lite can be be used to debug the WebEngine (it lists JavaScript errors after is has been loaded).
          3. For catching JavaScript errors, you could try the JavaScript window on error function - http://www.w3.org/wiki/DOM/window.onerror. If you don't control the html you are loading, you will need to insert it some way (e.g. via webEngine().executeScript()), in which case timing the insertion to happen before any javascript has been executed might be tricky.
          4. There is an exception property on the loadworker, but don't think it would be much help here as I think it is for different kinds of errors like "could not connect", you could trap it and see what it contains.
          5. You could monitor the webengine's location property and fetch the url seperately and pass it through a tool like htmltidy in diagnostic mode which will generate a list of html errors and warnings (wouldn't exactly match webview's parsing handler).

          The html5 parsing algorithm is very forgiving of sloppy and mismatched html.
          Generally browsing engines just tend to ignore javascript and html errors and continue processing - they are not strict validators.
          • 2. Re: WebEngine HTML/JavaScript errors
            893762
            As jsmith has already pointed out, load errors are reported through the 'exception' and other WebEngine.loadWorker properties, see also http://javafx-jira.kenai.com/browse/RT-14291 .

            As to parsing errors, browsers normally report them through the so called console messages that can be viewed using e.g. DevTools in Chrome or Firebug in Firefox. Internally, WebView has a similar capability, that is, can receive console messages from the browser engine and forward them to interested parties, however, that functionality is not exposed through the public APIs yet. If you need this feature, please consider filing an RFE.
            • 3. Re: WebEngine HTML/JavaScript errors
              Patrick Martin
              I just save the content as an html file to disk and load it into Firefox/Firebug/View Errors.

              - Pat
              • 4. Re: WebEngine HTML/JavaScript errors
                shruda
                Hi jsmith,
                I have some questions to one of your comments:
                jsmith wrote:
                1. There is a new debug API for WebView in 2.2, perhaps that may also be of use to you.
                Is this new debug API already part of the JavaFX 2.2 build b17 and do you know where I can find a documentation which describes how to use that new debug API?

                Will there a remote-debugging tool like the Google Chrome Developer Tools or how can I image it?
                https://developers.google.com/chrome-developer-tools/docs/remote-debugging#remote

                Best Regards
                Steve
                • 5. Re: WebEngine HTML/JavaScript errors
                  jsmith
                  Is this new debug API already part of the JavaFX 2.2 build b17
                  Probably.
                  I think the API has been first developed as an internal API in closed source to assist in debugging WebView via NetBeans.
                  I recall seeing mention of it in a jira case, but I can't find the related jira at the moment.
                  There may be a plan to make it part of the public API, but I don't think it would be in the 2.2 timeframe.
                  do you know where I can find a documentation which describes how to use that new debug API?
                  I don't know if such documentation exists.
                  Will there a remote-debugging tool like the Google Chrome Developer Tools
                  I don't know.
                  • 6. Re: WebEngine HTML/JavaScript errors
                    shruda
                    Hi jsmith,
                    thank you for your fast response. That means probably that the WebView will remain a blackbox for the next year until the JavaFX 3.0 Release.

                    I would be very glad if the JavaFX gururs also think on us eclipse developers ;-)
                    • 7. Re: WebEngine HTML/JavaScript errors
                      jsmith
                      I would be very glad if the JavaFX gururs also think on us eclipse developers
                      Raise a feature request at http://efxclipse.org/ for that.
                      • 8. Re: WebEngine HTML/JavaScript errors
                        anouard
                        Hi,
                        Does anyone got more information about WebView and JS debugging?
                        In lastest builds, I didn't notice any debug API. Any clues/ideas are welcome!

                        Thanks a lot.