Friday, November 12, 2010

that 'headless'' firefox - not this way

Yesterday I mentioned that when distributing Selenium RC workers about the shop I stumbled across a configuration where a RC ran Firefox w/out a display:
[java] 16:43:43.770 INFO - creating new remote session
[java] 16:43:43.771 INFO - Allocated session f01c7e0b83304b429bbff24ea5710742 for http://3akai.sakaiproject.org/dev/index.html/dev/, launching...
[java] 16:43:43.906 INFO - Preparing Firefox profile...
[java] Wed Nov 10 16:43:43 kitchen.local firefox-bin[3537] : kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch errors as they are logged.
[java] _RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.
[java] Wed Nov 10 16:43:44 kitchen.local firefox-bin[3537] : Window Server is not available.
[java] Wed Nov 10 16:43:44 kitchen.local firefox-bin[3537] : Window Server is not available.
[java] Wed Nov 10 16:43:44 kitchen.local firefox-bin[3539] : kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch errors as they are logged.
[java] _RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.
[java] Wed Nov 10 16:43:44 kitchen.local firefox-bin[3539] : Window Server is not available.
[java] Wed Nov 10 16:43:44 kitchen.local firefox-bin[3539] : Window Server is not available.
[java] 16:43:47.026 INFO - Launching Firefox...
[java] 16:43:49.873 INFO - Got result: OK,f01c7e0b83304b429bbff24ea5710742 on session f01c7e0b83304b429bbff24ea5710742
[java] 16:43:49.884 INFO - Command request: setTimeout[300000, ] on session f01c7e0b83304b429bbff24ea5710742
[java] 16:43:49.902 INFO - Got result: OK on session f01c7e0b83304b429bbff24ea5710742
[java] 16:43:49.909 INFO - Command request: setSpeed[1000, ] on session f01c7e0b83304b429bbff24ea5710742
[java] 16:43:49.909 INFO - Got result: OK on session f01c7e0b83304b429bbff24ea5710742
[java] 16:43:49.916 INFO - Command request: open[/dev/index.html, ] on session f01c7e0b83304b429bbff24ea5710742
[java] 16:44:05.704 INFO - Checking connection to hub...
[java] 16:44:05.704 INFO - Ping Hub at http://octo.local:4444/heartbeat?host=192.168.0.10&port=5555
[java] 16:44:10.416 INFO - Got result: OK on session f01c7e0b83304b429bbff24ea5710742
The test continues at a slightly faster pace, logging into Sakai 3. At first I thought this was totally cool, and might of been a way to increase the number of workers which could be run on a single box.  Selenium RC launches each Firefox with an individual anonymous profile, so running a few simultaneously isn't going to hurt anything. And it might be, with caution.

What's happening here is that I started the RC as a user different than the user who is, in Apple's terms, the 'console user.' That's the userid who's in charge of the windows on that machine - take a look at the permissions on /dev/console and you'll see what I mean.

Firefox, or at least the version on that box, must be using the OS X global window server service at launch so it can lurch into this odd state and continue running w/out displaying any UI.

Apple gives a warning about this, and infact it looks like the recent OS X Server has proceeded down that path.

There are XUL based headless Firefox builds available and they may be much more useful.

OK so back to the meat of this :)

No comments: