Search code examples
debuggingfirefoxfirefox-addoncompilation

Fastest way to debug Firefox addons during development


Debugging a Firefox addon is a slow process: (1) edit source code in a JS editor (2) package into XPI using a build script (3) drag into Firefox to install (4) restart Firefox (5) open the JavaScript Debugger

Can we speeden up the process? Like install it into Firefox without a restart, or configure the build script to install it into Firefox as well?


Solution

  • You'll want to locate your profile folder. Once you find it, go into the folder called 'extensions', and then locate the folder for the add-on you are working on. Replace that folder with a file of the same name (minus .xpi if that's part of the name), and inside the file place the full path to your source directory of the add-on.

    In Linux and Mac, that'll look like:

    /full/path/to/yourExtension/
    

    And on Windows:

    C:\full\path\to\yourExtension\
    

    Remember the trailing slash and beware of extra whitespace.

    As long as you don't use jar files inside your add-on, you will no longer have to rebuild (this is covered in a bit more depth here).

    Additionally, you'll want to set nglayout.debug.disable_xul_cache to true. For edits to xul or js files, you'll just have to open up a new window to see your changes instead of restarting the application. There are other preferences here that you may find useful as well.

    Extra tips:

    • Starting firefox with a certain profile (dev), while other firefox profile is open and with the debugger already on:

      "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" -no-remote -P dev -jsconsole

    • Check out the restart addon (saves time).