I was very impressed by this tools and I began to use it to do some tests on my PHP framework, Jelix [1].

But what is PhantomJS? This is a scriptable and an headless web browser. It means that it is browser which you can interact with a web site, only through a javascript script. No user interface, no window, no button. You write a script which call some functions like open() to open a web page, sendEvent() to "click" or "type a key" on the web page and so on. You can retrieve the content of the web page, you can take screenshots, listen all loading events etc. At the end, with PhantomJS, you can do automatic processing like functionnal tests or network monitoring. You already have many scripts to do many things, and one of them is CasperJS, which is a testing framework.

The advantage of PhantomJS over similar tools like ZombieJS, is that it is powered by a well known and a true web engine. Here, this is Webkit (with JavascriptCore). It means that it has almost the same behavior of Safari (or Google chrome), and so you can test your web site as if you were into Safari or Chrome.

In this tweet discussion, Anthony, a friend at Mozilla, has pointed out to me that with PhantomJS, I could not test with Gecko, the rendering engine of Firefox. And Nicolas, the author of CasperJS (I already met him in the past in some conferences) confirmed to me that some of his users would like to use CasperJS to test their web sites with Firefox.

At the end ot the discussion, these following conclusions appears to me:

On a one side:

  • Because PhantomJS is only built on top of Webkit, some web developers cannot launch their tests on Gecko although they would like to use these great tools to test their projects with Firefox-like browser.
  • PhantomJS and CasperJS have a great success, and are more and more used by web developers. It's great but it as a negative side-effect from my point of view: it increases the "webkit monoculture". I began to contribute to the Mozilla project, ten years ago, by doing tech evangelism, (and before, I did web standards evangelism with Tristan Nitot and others passionnate). So, you understand that these last months, I was very annoyed by this growing "webkit monoculture". I think this is bad for the Web.

On the other side:

  • The API of PhantomJS is not really complex, and there are not many API: it could be easy to implement a such API in a similar tool (well, it was I thought :)), even if some features would not be there, like the "headless" behavior, because Gecko needs a graphical interface to display web content.
  • I played with Mozilla technologies (XUL, XulRunner, Gecko internals) for many years, in personal and professional projects.

So it was clear to me that something should be done. I was be able to create a PhantomJS-like tools base on Gecko. I could do a concrete thing to fight this webkit monoculture. Am I The One for this work? :-)

Ok, so, let's try, let's go. Two days later, I started the project. I found a name, SlimerJS, [2], I bought a domain name slimerjs.org, I opened a new project on Github, and I created the first commit.

I then developed SlimerJS during my spare time. I released two versions, SlimerJS 0.6 and SlimerJS 0.7. It was pretty usable if you did not search to have a full compatibility with PhantomJS. The goal for SlimerJS 0.8 was to be able to launch CasperJS. With its tests suites, I have fixed many compatibility issues, and implemented all needed API that was not implemented yet. I had also improved CasperJS so it "knows" SlimerJS, and it can react correctly to some specifics behaviors. The result is a full compatibility with CasperJS, a new version of CapserJS, 1.1 beta and of course SlimerJS 0.8, released 7 months after the first line of code !

These developments were not easy in fact. Webkit and Gecko have some different behaviors. I had to find some solutions to match behaviors of some PhantomJS API. But sometimes I couldn't, because there was no internal API in Gecko to do what I wanted (example: no possibility to indicate an exit code in Gecko), or because if I hack Gecko in some areas, it wouldn't match behaviors of Firefox, and this is not that I wanted in fact. I listed some differences I found during the development of SlimerJS.

However, even if it is not yet a true headless browser, SlimerJS has some advantages over PhantomJS, like using promises when opening a web page, the benefit of a better javascript engine (unfortunately, it seems that PhantomJS does not use V8), the strictly same rendering as in Firefox since SlimerJS uses XulRunner or Firefox itself etc.

Some few things are still missing, like configuration options, the webdriver mode, the http authentication feature etc. I plan to implement them in a future release. And if I have enough time and help (this will be a huge development!), I will hack Gecko to have a true headless mode, by trying to fix this bug in Gecko (Hello Mozilla, if you are interested... ;-) ).

Enjoy! download SlimerJS, follow its developments on twitter, ask your questions on the forum/mailing list, or even contribute!

Notes

[1] unfortunately, I temporarely stopped these tests, because of the SlimerJS history :-)

[2] See the FAQ to know why this name;-)