PhantomJS has a bunch of useful functionality that probably will never be exposed via the base Selenium WebDriver wire protocol. Access to the PhantomJS scripting language from GhostDriver would be useful for a number of reasons:
WebDriver has a nice automation interface and but is lacking in the browser configuration and setup department. For example, PhantomJS allows the viewport and 'clipping rect' to be setup, allowing screenshots that may be closer to what a user would see in a real browser. WebDriver always gives the full page size.
It would make it easier to migrate between PhantomJS and WebDriver scripts. As in there would be an out, if some part of WebDriver functionality didn't match the PhantomJS functionality.
The downside of allowing PhantomJS to be called from WebDriver is that user scripts may interfere with the GhostDriver code. Like resetting callbacks for example. I think this can be mitigated with some documented warnings though.
I have an example implementation working with GhostDriver & the Java WebDriver bindings. It seems to work well, I'll clean it up and add it here.
I filed here with a patch:
So that issue can probably be closed, if this is a better place for it.
Referred here as well: ariya/phantomjs#11126
Patch can be found at: https://code.google.com/p/phantomjs/issues/detail?id=1126
Btw, setting Custom-Headers is now part of GhostDriver 1.0.4.
But I still want to add support for this feature: it's general and can be extremely useful.
A pull request?
+1 for this patch. It looks pretty clean and straightforward (only 200 lines).
Another great use case: AJAX frameworks. This patch would allow me to track AJAX requests and continue my test when I see that the server replied to a request. It would even allow me to test content of AJAX requests.
Mark (@watsonmw), if you think your patch is still perfectly valid, I'll allocate sometime to port it into.
But if you want to make changes (since I made half a century pass by and things might have evolved...), and provide a pull request off the latest code, be my guest.
I'll wait a day or two for reply.
Implemented by #262