Metabrowsing! (Or, custom interactors for MozRepl)

First guy: “So how would an object inspector look like in MozRepl?”

(Flashback: MozRepl is an interactive shell for Firefox and other Mozilla apps. You connect to Firefox with telnet or similar, type some JavaScript code, and it gets executed on the fly.)

I patiently explained how a command line inspector would look like. More or less like:

First guy: “Well, and how do you get this in MozRepl?”

I (im)pantietly explained that there was no inspector yet.

First guy: “Why not?”

I (im)patiently…

Second guy, out of nowhere: “Yeah, why not?”

You know that you’re in trouble when even the nicest guy in the place teams up to nag you.

Then I spent some time not to write an inspector, but to make it possible (and easy) for third parties to write new interaction modes for MozRepl, so that the onus of writing the damn inspector would be on the above guys. :) (The best thing you can do with challenges isn’t winning them, it’s turning them upside down.)

However things quickly got fancier while I explored, because the same request/response pattern interactive interpreters are built around is common to a lot of applications. Object inspectors, sure. Even text adventures (“You’re in a dimly-lit browser, surrounded by menacing angled brackets and curly braces”).

But also HTTP.

One custom interactor later, there it was: Firefox understanding HTTP and browsing itself. :)

Where to go from here? Once there’s a halfway decent implementation of HTTP (hint: mine isn’t), you may be able to drive Firefox with XML-RPC, JSON-RPC, REST-style manipulation of resources, and who knows what else. (Oh, yeah, I guess server-side long-timers in the audience will know what-else very well.)

Support is available in the new stand-alone MozRepl package. To try out the http-inspect mode, just go to about:config and set the “extensions.mozrepl.defaultInteractor” pref to “http-inspect”, then point the browser to http://localhost:4242. Documentation on how to write custom interactors is on the wiki.

Credits to Sergi for coming up with the “metabrowsing” title!

4 thoughts on “Metabrowsing! (Or, custom interactors for MozRepl)

  1. Sergi

    Kudos for the idea! And although the whole metabrowsing concept still boggles my mind a little bit (can we browse the browser metabrowser? REST manipulation of resources??), I have the feeling that this opens up a lot of unexpected possibilities to firefox development, or at least lots of fun hours of experimentation…

    By the way, I switched to MozRepl-based coding and debugging and I am never looking back again, thanks!!

    (I am sure that Abelson and Sussman are very honored that you introduced such a ‘recursive’ MozRepl feature with their lectures page in the background) 😉

  2. bard Post author

    Well, Firebug is a tool, the custom interactors feature of MozRepl is a tiny framework… Examples of usage/features depends on what you create with the framework.

    For example, with the sample http-inspect interactor I can inspect the internal state of XULRunner applications running on my coworkers’ machines. Like with all programmable tools the rest is up to your creativity. 😉

  3. Pingback: Turning Firefox into a screenshot server with MozRepl | hyperstruct

Comments are closed.