Getting dev tools working with XULRunner
March 17th, 2006I’ve recently had a revived interest in Mozilla XUL. Last month I saw a blog about the new XULRunner tool, so I downloaded it a few days ago for a closer look. The first thing that became pretty obvious was that the normal suite of tools that I’m used to working with in Firefox/Mozilla don’t really fit into XULRunner out of the box. These include things like the Extension Developer Extension, the Venkman JavaScript Debugger, and the DOM Inspector.
There are a few places that mention that it should be possible to get these things going, but I couldn’t find any solid instructions on how to do so. I haven’t gotten the DOM Inspector going yet, but see below for a method for getting the first two working in your XULRunner app.
First of all, I did all of this work using a custom built XULRunner on Linux from the XULRunner 1.8.0.1 source drop. I have not tried this on the stock binaries but I think it should work. In any case, here are the configure options I used:
--enable-application=xulrunner --enable-extensions=default,venkman,inspector --enable-svg --enable-storage
The Extension Developer Extension was pretty easy to hack into an XULRunner app. I just extracted the extensiondev.jar from the xpi and created an extensiondev.manifest that reflected what was in the install.js. I dropped both of these files into my app’s chrome directory and was then able to specify the FireFox overlay on my main window (chrome://extensiondev/content/firefoxOverlay.xul). It worked after creating a menupopup with the id “menu_ToolsPopup”, which follows the FireFox naming convention.
Venkman was trickier. I tried the same approach, ending up with a venkman.manifest and venkman.jar in my chrome directory. I then tried to overlay Venkman onto my main window (chrome://venkman/content/venkman-overlay.xul). The first hurdle is that the function toOpenWindowByType does not exist in the default XULRunner overlays. I just reimplemented it with the following:
function toOpenWindowByType(inType, uri)
{
window.open(uri, "_blank", "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar");
}
Then the problem became that it just didn’t work. I was using the venkman.jar that I extracted from the XULRunner build that I was using. I finally switched to the patched version of Venkman for Firefox 1.5 available from here. It worked like a charm. The main thing you have to do is uncheck the menu option Debug/Exclude Browser Files. Note that if you open more than one debugger window, the app crashes with a nasty segfault. My toOpenWindowByType stub should keep this from happening, but I haven’t gotten to adding any logic for that.
I packaged the glue for these things up into an xulrunnerdev.jar that also adds a menu item to open the JavaScript Console (in lieu of having to pass the -jsconsole command line). Here are the exact steps to get it working in your XULRunner app:
- Download the xulrunnerdev.zip file from below and extract it to your application chrome directory.
- Add a line to your application chrome.manifest for each of your application windows you would