headless gecko

slanning on 2007-06-21T09:03:49

For several years I've wanted to be able to process HTML documents through a real web browser's HTML renderer (like Gecko in Mozilla/Firefox; one that can handle JavaScript), but without opening up a browser window. This is mainly for testing, since an invisible web browser doesn't really allow you to "browse" much.

Ben Hutchings had pointed me to his VideoLink project (was called WebDVD), where he embeds Mozilla using Xvfb to avoid opening a window. Great, I wanted to do something like that and integrate it with Mozilla::Mechanize (I really need to get a new version released....), but my C++/Mozilla/Xvfb skills weren't up to it (although his code is very nicely written, I still didn't understand how it all worked).

Yesterday I came across a shell script, xvfb-run (apparently packaged in several distros, but I got it with the xvfb package in Ubuntu), that handles all the details of running X clients in a virtual X server. It works, and finally my problem is nearly solved!