Search code examples
javawebviewjavafxfirebug-lite

JAVAFX / WebView / WebEngine FireBugLite or Some other debugger?


I am developing an app and need to run a debugger on the WebView/WebEngine part of the application so I can better debug my application. But the code I found across the internet to inject Firebug Lite is not working for some reason.

The Javascript code itself works fine if I run it on the Firefox Console, but not when the same code is executed through the JavaFX webview/webengine. The netbeans console doesn't throw any errors others... so I am not sure why the FirebugLite UI is not rendering/loading.

What could be causing this, any other alternatives?

I'm using JavaFX 2.2

// Doesn't work....

webView.getEngine().executeScript("if (!document.getElementById('FirebugLite')){E = document['createElement' + 'NS'] && document.documentElement.namespaceURI;E = E ? document['createElement' + 'NS'](E, 'script') : document['createElement']('script');E['setAttribute']('id', 'FirebugLite');E['setAttribute']('src', 'https://getfirebug.com/' + 'firebug-lite.js' + '#startOpened');E['setAttribute']('FirebugLite', '4');(document['getElementsByTagName']('head')[0] || document['getElementsByTagName']('body')[0]).appendChild(E);E = new Image;E['setAttribute']('src', 'https://getfirebug.com/' + '#startOpened');}"); 

Solution

  • I was able to fix the problem. It seems like the current stable version of FirebugLite works well for traditional browsers but something is different that makes it fail for an application viewed by the JAVAFX WebView.

    I was able to add Firebug to my application by using an uncompressed version of FirebugLite

    <script type='text/javascript' src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
    

    The solution came from: Testing IE6 with Firebug Lite