Remotely refreshing multiple browsers during web testing

| tags: web, programming

I'm working on the rewrite of Tar Heel Reader and testing it on desktop, iPad, iPod Touch, and IE6-8. I hate manual steps in my edit/test loop. The i* devices are particularly bothersome because I push my changes, pick up the device, hit the home button to wake it up, slide-to-unlock, and then hit the tiny refresh button. There had to be a better way.

I'm pretty sure I saw someone doing something that enabled them to force multiple browsers to refresh but when I went looking I couldn't find it. So, I decided it would be fun to try to write my own.

I inserted a script tag into the footer of my pages to load this javascript from remoteCommand.js.

And I added the following php code to my theme directory.

Now I keep a file command.js in the directory and update it as necessary. My Makefile for testing copies the theme files over to the server using rsync and then copies the command.js to /usr/tmp/command.js on the server. The php script notices the change and responds to requests from any browsers I have open on the testing site. They eval the javascript and force a reload or whatever else I needed to have happen.

I haven't seriously tested with it yet but I think this will allow me to have the iPad and iPod propped up on my desk (with autolock disabled), IE* running in a VM, and Firefox running on my desktop all reload each time I hit F7 to build in Sublime Text 2.

This approach is not scalable using Apache and php. Each connected browser is tying up a thread running that loop. Tornado would be a scalable solution but this was easy to hack out quickly and will meet my needs.