Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging extension code in firefox (javascript debugger/venkman)

I'm currently working on a simple extension for Firefox. Now I would like to be able to issue some commands in a console in the extensions context.

I have installed the Javascript Debugger addon (venkman) but following the instructions:

  • uncheck "Exclude Application Files"
  • choose file and right-click "Set as Evaluation Object"

never sets the context, I always end up (or rather stay) in the venkman.xul context.

I would switch to another debugger, but so far had no luck with chromebug either:

  • installed chromebug 1.08a2 and matching firebug
  • started firefox with -chromebug -P dev (as a seperate 'firefox' for development)

then chromebug on its own window doesn't let me choose a context, in fact it doesn't even show ANY context, all panels are deactivated.

I really don't have any idea where to look any more and would love to have a solution. For now I don't even need all the 'fancy' debugger stuff like setting breakpoints, just need to issue commands at chrome level.

like image 827
Daniel Bachmann Avatar asked Dec 04 '12 11:12

Daniel Bachmann


1 Answers

Firefox now has a built-in debugger that easy rivals, and perhaps surpasses firebug, chromebug or venkman.

You need to enable (or create) 2 particular options in about:config for extension debugging to work:

devtools.chrome.enabled: true
devtools.debugger.remote-enabled: true

And then click the new "Browser Debugger" entry in the Web Developer menu. The "Browser Console" is also very useful.

The official documentation mentions that this will work from Firefox 19, but actually it will only work well on all extension code from Firefox 23 onwards. (If you try this before Firefox 22 is released, just install the latest nightly build.)

Also note that if you're editing extension code directly you will need get Firefox to refresh e.g. by using the reload all chrome extension using the tips mentioned in this answer before the debugger will list the updated code.

Update: Firefox v32 and later has built-in debugging support for restartless and SDK-based add-ons. As stated in Mozilla's documentation, the "remote debug" mentioned above now has a checkbox in the Web Developer pane's settings:

enter image description here

You can then go to the add-ons -> extensions tab and click "debug" alongside the name of you extension.

like image 118
Motti Strom Avatar answered Sep 23 '22 23:09

Motti Strom