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
Den tisdagen den 11:e februari 2014 kl. 07:05:22 UTC+1 skrev Tajkia Rahman
Toma:
>
> 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
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Firebug" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/firebug.
To view this discussion on the web visit
https://groups.google.com/d/msgid/firebug/92c37e7b-9331-42a3-a802-0693065e9fb2%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.