How to use Command line functions in my own firebug extension

58 views
Skip to first unread message

Tajkia Rahman Toma

unread,
Feb 11, 2014, 1:05:22 AM2/11/14
to fir...@googlegroups.com
I want to use command line commands like getEventListeners()
http://www.softwareishard.com/blog/planet-mozilla/firebug-tip-geteventlisteners-command/

monitor() used in "Log Calls to ..."
http://www.softwareishard.com/blog/firebug/firebug-tip-log-function-calls/

How can I use such commands in my extension?


Tajkia Rahman Toma
IIT, DU


Simon Lindholm

unread,
Feb 13, 2014, 2:57:49 PM2/13/14
to fir...@googlegroups.com
There are three reasonable ways to do this:
- Use Firebug's underlying code. For monitor() this is rather in flux (completely rewritten between 1.12 and jsd2 branch, as with most of the Script panel) but located in console/functionMonitor.js; for getEventListeners it's in console/commands/getEventListeners.js (slightly less in flux, but somewhat inflexible API). Probably not really recommended for those two functions, but in general it's a powerful method.
- Run code, just like the command line. You can use CommandLine.evaluate for this, see commandLine.js. The advantage is that you get exactly the same result as a user would when calling the function, the disadvantages is that it can be somewhat inflexible, and that the command line API could potentially change in the future (not terrible likely though). E.g. you can extract a command line API method through `var getEventListeners = null; CommandLine.evaluate("getEventListeners", context, null, null, function(res) { getEventListeners = res; })`, or call it in a similar manner.
- Do the same as Firebug. A good idea in case of getEventListeners, because you only care about the functionality, not Firebug's wrapper around it. In this case you can look at Firebug's implementation and copy it. (For getEventListeners the code of interest would be Events.getEventListenersForTarget in lib/events.js.)

Hope that helps,
- Simon
Reply all
Reply to author
Forward
0 new messages