Aspects of Javascript

A problem that I come upon with Firefox Extension Development is that often it is close to impossible to find out, which object / function provided by Firefox is called when certain Events occur. For example: in spite of my all-day taking quest to find a central piece of code to detect changes of bookmarks I still don’t know exactly what functions are called when a Bookmark is created / deleted / changed1.

But thanks to Google and some Python background (Decorators) I found Beppu’s Decorator / AOP snippet for Javascript that is incredibly useful for finding out what exactly is happening without needing to alter Firefox’s source code2. This code allows to execute a script before or after some miscellaneous code is executed. Even wrapping a function is possible without any problem… check it out!

  1. note: this is not exactly true. There is the infamous DataSource "rdf:bookmarks" of Mozillas nsIRDFService. But recognizing exact acts seems to be too tedious to really start trying… So this approach stays my last resort! 

  2. doesn’t work for native XPCOM code, only for Javascript objects / functions. 

Discussion Area - Leave a Comment