Posted

tl;dr Firefox Nightly on Linux supports running SlimerJS headlessly. More platforms and full headless Firefox are coming soon.

Over the last couple of years, I’ve worked on a few big web projects like PDF.js and PluotSorbet where I’ve wanted a better way to run automated tests in Firefox. My usual workflow would either involve opening a test page in Firefox manually, using a homegrown automation script that would pop open Firefox and steal focus as it ran tests, or fighting with XVFB to run Firefox in the background. I missed the days of running C++ or Node unit tests directly from the command line and not having some new window open. If only Firefox supported a headless mode…

Headless Firefox had been in the back of my mind for awhile, so when January rolled around this year and my previous project was winding down, I was happy to hear I’d be working on headless Firefox. It also turns out, I wasn’t the only person who wanted a headless mode for Firefox. We heard from multiple organizations and developers that they wanted an easier way to test Firefox and there was even a feature request nine years ago with quite a bit of following. For the first phase of headless browsing we decided to target SlimerJS, since it is a simpler application based on Firefox, it comes with an API for controlling the browser, and developers are already using it for testing. Fast forward a few months, and I’m happy to announce the I’ve finished the first big milestone by getting SlimerJS to run completely headlessly with Firefox Nightly on Linux.

If you’re on Linux and want to try it out:

  1. Download and install Firefox Nightly.
  2. Get the SlimerJS source. Note: once the changes land in a stable release you can just follow the regular download instructions for SlimerJS.
  3. Modify src/application.ini to bump the version of Firefox supported.
  4. Create a SlimerJS test script. For example snapshot.js:
  5. Test it out. Make sure to set the MOZ_HEADLESS environment variable and change the SLIMERJSLAUNCHER path to point to wherever you installed Firefox nightly

 

Next up, I’ll be working on getting Firefox to run headlessly without SlimerJS and instead being controlled by either WebDriver (Selenium) or maybe a devtools protocol (to be decided) and on getting headless working on MacOS and Windows. For more updates, follow along in the headless browsing meta bug and in SlimerJS’s bug.

Comments

  1. Simon

    Definitely interested in seeing a more generalised headless support for testing, avoiding the need for dummy X servers to run stuff in. This is especially true for WebDriver, but also for any test framework that can be invoked simply by starting a browser instance pointed at a URL…

    Reply

Trackbacks/Pingbacks

  1.  Headless Firefox | Mykzilla
  2.  Headless SlimerJS with Firefox – Javascript World

Leave a Reply

Your email address will not be published. Required fields are marked *