Truly headless browser solution needed

I’m working on testing a complex web app that relies heavily on AJAX calls. Need to set up automated testing that can run continuously without any manual input. My main focus right now is load testing but I want to use the same test scripts for functional testing too.

Right now I’m using Grinder for load tests. We record the scripts and then spend tons of time editing them to handle async requests properly. This approach works okay but the scripts break easily and I can’t keep updating them as we develop new features.

What I really need is a way to control a browser through code that handles HTML and JavaScript automatically but runs without any GUI. If my test script fails it should mean the actual app is broken. I tried running Firefox with a virtual display but it still uses way too many system resources even on a server setup.

I spent several days trying to get HTMLUnit working since it seemed perfect for this. Been writing HTMLUnit scripts in Jython so I could integrate with Grinder. But I keep hitting JavaScript errors that don’t actually happen in real browsers like Firefox or Chrome. I think I’ve hit a dead end with HTMLUnit and need other options.

I’ve heard about some alternatives like EnvJS and Zombie.js but I’m not sure how stable they are. Don’t want to waste another week going down the wrong path.

How difficult would it be to modify Firefox or WebKit source code to remove all the display and GUI parts to make a real headless browser? Has anyone done this before? Which one would be easier to modify? I’m surprised this hasn’t been done already so maybe it’s way harder than I think.

If I could get a proper headless browser that performs well I think all my problems would be solved. I have plenty of servers available but not enough for full Firefox instances with rendering.