Tuesday, January 26, 2010

How to run Firefox 3.7a in headless mode

This post is inspired by a need to get Selenium testsuites running faster. This is done on Ubuntu Linux x86_64 platform.
I will assume you have Firefox 3.7a from the daily repositories installed on your system.
First you have to get the sources for a incubator project called 'Offscreen':
  • wget http://hg.mozilla.org/incubator/offscreen/archive/tip.zip
Unzip them:
  • unzip tip.zip
Download compile configurations for Offscreen and put them in the newly created directory:
  • wget -O mozconfig https://bug446591.bugzilla.mozilla.org/attachment.cgi?id=350162
Inside the new directory, run:
  • make -f client.mk build
You might need some dependencies. Make will tell you what you are missing, I will not describe how to get the dependencies needed, except this:
  • apt-get install autoconf2.13
If everything went correctly, you should now be able to do:
  • ../obj-x86_64-unknown-linux-gnu/dist/bin/xulrunner /usr/lib/firefox-3.7a1pre/application.ini
You should now be presented with lots of output from your newly compiled Xulrunner, most notably when it stops:
  • [url = chrome://ubufox/content/startpage.html]
Congratulations, you now have your very own headless Firefox!