Custom CSS

Monday, May 10, 2010

Peeking inside Components.classes for Firefox 3.5.8

For the longest time, I had wondered what kind of magical smurfs, krakens, and leprechauns lived inside of Components.classes; but today I felt like sort of an idiot because I realized I could just do this:

echo "for(var p in Components.classes){print(p)}" | xpcshell | sort > cc.txt
echo "for(var p in Components.interfaces){print(p)}" | xpcshell | sort > ci.txt

The xpcshell function is just a little bash function I have for running XPCShell (on Debian, XULRunner binaries are located in /usr/lib/xulrunner-1.9.1; they may vary for the reader):

function xpcshell {
  local DIR=/usr/lib/xulrunner-1.9.1
  $DIR/ $DIR/xpcshell $@

This is a pretty good tool for testing extension code out, as long as you don't want to do anything with a ChromeWindow; it'll crash if you try to get fresh with it like that!

$ xpcshell
[loading 'xpcshell.js'...]
js> var app = Components.classes[";1"].
js> var uri = Components.classes[";1"].
  newURI("", null, null);
js> app.createTopLevelWindow(null, uri, 0, 0, 0, null);

(process:8032): Gdk-CRITICAL **: gdk_screen_get_rgb_visual: assertion `GDK_IS_SCREEN (screen)' failed
/usr/lib/xulrunner-1.9.1/ line 131:  8032 Segmentation fault      "$prog" ${1+"$@"}

Post a Comment