• Skip to main content
  • Select language
  • Skip to search
MDN Web Docs
  • Technologies
    • HTML
    • CSS
    • JavaScript
    • Graphics
    • HTTP
    • APIs / DOM
    • WebExtensions
    • MathML
  • References & Guides
    • Learn web development
    • Tutorials
    • References
    • Developer Guides
    • Accessibility
    • Game development
    • ...more docs
Add-ons
  1. MDN
  2. Mozilla
  3. Add-ons
  4. Setting up an extension development environment

Setting up an extension development environment

In This Article
    1. Overview
    2. Development profile
    3. Download Firefox
    4. Development command flags
    5. Development preferences
      1. Accessing Firefox development preferences
      2. Accessing Thunderbird development preferences
      3. Recommended development preferences
      4. Development extensions
    6. Firefox extension proxy file
    7. Using directories rather than JARs

This article provides suggestions for how to set up your Mozilla application for extension development. These details apply to Firefox, Thunderbird, and SeaMonkey (version 2.0 and above).

Overview

  • You'll create a new user profile to run your development specific Firefox session. This will utilize distinctive development preferences in about:config.
  • Install Firefox development extensions specifically for this new developer user profile.
  • Edit files in the extensions folder of this profile, and restart the application as this new developer profile.

Development profile

The use of a separate user profile for development can be advantageous, averting performance degradation from development related settings, and further isolating personal data (such as bookmarks, extensions, and settings) from your testing environment. You could be running two instances of Firefox simultaneously.

Note: For an extended guide on how to set up even more user profiles, take a look at Multiple Firefox profiles. This particularly comes in handy for the use of all currently available Firefox versions: Firefox, Beta, Developer Edition, and Nightly. It even allows the running of simultaneous versions, at the same time.

To quickly achieve our task of creating just a developer profile, we will start the application with the parameters:

/path/to/Firefox -no-remote -P ProfileName

Without these parameters, the default behavior of your Mozilla applications is to only open the everyday user profile: named default. As we are specifically defining the user profile dev, If you don't have the dev profile already created, the profile selection window opens, where you can create it.

In the following example, the described command starts a new instance of Firefox, with a profile called dev; even if an instance of Firefox is already running.

On Ubuntu (and many other Linux distributions):

/usr/bin/firefox -no-remote -P dev

On other distributions of Linux/Unix:

/usr/local/bin/firefox -no-remote -P dev

On MacOS Mavericks (10.9) and newer:

/Applications/Firefox.app/Contents/MacOS/firefox-bin -no-remote -P dev &

On Windows:

Start -> Run "%ProgramFiles%\Mozilla Firefox\firefox.exe" -no-remote -P dev

On Windows 64 bit:

Start -> Run "%ProgramFiles(x86)%\Mozilla Firefox\firefox.exe" -no-remote -P dev

To start Thunderbird or SeaMonkey instead of Firefox, substitute thunderbird, or seamonkey for the firefox used in our examples.

Note: you could run Firefox using your regular profile while developing. However, you won't enjoy the benefits of isolated resources, which we discussed earlier.

The Parameter -P ProfileName doesn't imply -no-remote, therefore use them together. If you are already running a Firefox instance without -no-remote, and you attempt to start another instance with -P ProfileName (but without the -no-remote parameter), that second invocation would ignore its -P ProfileName parameter, instead opening a new window for the already running instance; sharing all its profile, sessions etc.

Download Firefox

Download your desired version of Firefox. For example, Nightly and/or Developer Edition. Unpack them in your user home directory, and name folders for easy navigation to firenightly and firedevedition or similar. You do not have to install these unstable versions, if you do not wish.

Make a symbolic link (also referred to as a shortcut) to the firefox binary (firefox.exe on Windows), then move the link to your desktop, or your preferred location. To run this version of Firefox, simply double click on this file. Explore this profile a little: change some settings, install any additional extensions, and finally close this instance of Firefox.

Now run your Firefox Profile Manager. (Linux, Mac OS X, Windows instructions.) You'll see the list of available user profiles one which is default (stable) and other (unstable) profile(s) created automatically when you run other versions of Firefox earlier. Choose default and uncheck "Don't ask at startup" checkbox. Click "Start Firefox". Now when you start any version of Firefox you may choose any profile you like.

Development command flags

As of Gecko 2 (Firefox 4), JavaScript files are cached ("fastload"). The -purgecaches command-line flag disables this behavior. Alternatively, you can set the MOZ_PURGE_CACHES environment variable. See this bug for more information.

Development preferences

There is a set of development preferences that, when enabled, allows you to view more information about application activity, thus making debugging easier. However,  these preferences can degrade performance, so you may want to use a separate development profile when you enable these preferences.

Accessing Firefox development preferences

To change preference settings in Firefox or SeaMonkey, type about:config in the Location Bar. You can also use the Extension Developer's Extension, which provides a menu interface for Firefox settings.

Accessing Thunderbird development preferences

To change preference settings in Thunderbird, open the "Preferences" (Unix) or "Options" (Windows) interface. On the "Advanced" page, select the "General" tab then click the "Config Editor" button.

Recommended development preferences

Not all preferences are defined by default, and are therefore not listed by default. You will have to create new (boolean) entries for them. For more information about Mozilla preferences, refer to the mozillaZine article on "about:config".

Tip: You can install either the Developer Profile or DevPrefs add-ons to handle setting these preferences automatically, and skip the rest of this section.

  • javascript.options.showInConsole = true. Logs errors in chrome files to the Error Console.
  • nglayout.debug.disable_xul_cache = true. Disables the XUL cache so that changes to windows and dialogs do not require a restart. This assumes you're using directories rather than JARs. Changes to XUL overlays will still require reloading of the document overlaid.
  • browser.dom.window.dump.enabled = true. Enables the use of the dump() statement to print to the standard console. See window.dump for more info. You can use nsIConsoleService instead of dump() from a privileged script.
  • javascript.options.strict = true. Enables strict JavaScript warnings in the Error Console. Note that since many people have this setting turned off when developing, you will see lots of warnings for problems with their code in addition to warnings for your own extension. You can filter those with Console2.
  • devtools.chrome.enabled = true. This enables to run JavaScript code snippets in the chrome context of the Scratchpad from the Tools menu. Don't forget to switch from content to browser as context.
  • devtools.debugger.remote-enabled = true. This adds a "Browser Debugger" entry to the "Web Developer" submenu of the "Tools" menu.  The Browser Debugger can be used to debug the JavaScript code of extensions. The devtools.chrome.enabled preference must also be set to true for the Browser Debugger to be enabled.
  • devtools.debugger.prompt-connection = false. This prevents the Browser Debugger from prompting for connection permission every time.
  • extensions.logging.enabled = true. This will send more detailed information about installation and update problems to the Error Console. (Note that the extension manager automatically restarts the application at startup sometimes, which may mean you won't have time to see the messages logged before the automatic restart happens. To see them, prevent the automatic restart by setting the environment NO_EM_RESTART to 1 before starting the application.)
  • nglayout.debug.disable_xul_fastload = true. For Gecko 2.0+ (Firefox 4.0+). See this bug for more information. Although the bug has been closed, it is believed that this pref is still relevant.
  • You might also want to set dom.report_all_js_exceptions = true. See Exception logging in JavaScript for details.
  • devtools.errorconsole.deprecation_warnings = true. Detect deprecated code use.

Warning: Never set nglayout.debug.disable_xul_fastload to true in a production environment; it exists solely to aid in debugging. In particular, add-ons should never change this preference.
.

Note: The Error Console is disabled by default starting in Gecko 2.0. You can re-enable it by changing the devtools.errorconsole.enabled preference to true and restarting the browser. With this, javascript.options.showInConsole is also set to true by default.

Development extensions

These extensions may help you with your development.

  • DOM Inspector, used to inspect and edit the live DOM of any web document or XUL application (Firefox and Thunderbird)
  • Venkman, a JavaScript Debugger (Firefox version, Thunderbird version)
  • Thunderbird Developer Tools, enables debugging Thunderbird remotely using using Firefox developer tools
  • Extension Developer's Extension a suite of tools for extension development (Firefox)
  • Extension Test an add-on which makes it easier to detect problems which will lead to rejection by addons.mozilla.org
  • Console² enhanced JavaScript console (Firefox version, Thunderbird version)
  • Javascript Command for writing/testing javascript on Firefox windows
  • Inspect Context Open DOM Inspector at this node from Inspect on context menu.
  • Chrome List navigate and view files in chrome:// (Firefox version, Thunderbird version)
  • Chrome Edit Plus a user file editor (Firefox and Thunderbird)
  • Firebug a variety of development tools (Firefox)
  • Pentadactyl, a general purpose extension with builtin tools for extension development, including a command line with chrome JavaScript evaluation (including property and function argument completion) and the ability to demand-load external JavaScript and CSS files into window chrome.
  • Chromebug combines elements of a JavaScript debugger and DOM (Firefox, "kinda works for Thunderbird")
  • MozRepl explore and modify Firefox and other Mozilla apps while they run (Firefox, Thunderbird version is not working)
  • ExecuteJS an enhanced JavaScript console (Firefox version, Thunderbird version is not working)
  • XPCOMViewer an XPCOM inspector (Firefox and Thunderbird)
  • JavaScript shells to test snippets of JavaScript (Firefox and Thunderbird)
  • SQLite Manager to manage the SQLite database (Firefox and Thunderbird)
  • ViewAbout enables access to various about: dialogs from the View menu (Firefox version, Thunderbird version )
  • Crash Me Now! useful for testing debug symbols and the crash reporting system (Firefox and Thunderbird)
  • Javascript Object Examiner displays JavaScript object methods and properties for any available scope
  • Developer Profile and DevPrefs sets up the development environment described above when installed (Firefox and Fennec)

Firefox extension proxy file

Extension files are normally installed in the user profile. However, it is usually easier to place extension files in a temporary location, which also protects source files from accidental deletion. This section explains how to create a proxy file that points to an extension that is installed in a location other than the user profile.

  1. Get the extension ID from the extension's install.rdf file.
  2. Create a file in the "extensions" directory under your profile directory with the extension's ID as the file name (for example "your_profile_directory/extensions/{46D1B3C0-DB7A-4b1a-863A-6EE6F77ECB58}"). (How to find your profile directory) Alternatively, rather than using a GUID, create a unique ID using the format "name@yourdomain" (for example chromebug@mydomain.com) - then the proxy filename will be same as that ID, with no curly brackets {}.
  3. The contents of this file should be the path to the directory that contains your install.rdf file, for example /full/path/to/yourExtension/ on Mac and Linux, and C:\full\path\to\yourExtension\ on Windows. Remember to include the closing slash and remove any trailing whitespace.

    • Note: If you already installed the extension via XPI, you should uninstall it first before creating the pointer file.
    • Also note that the use of proxy files requires that the extension's chrome.manifest defines its chrome urls using traditional directories, rather than a JARed structure. See below.
  4. Place the file in the extensions folder of your profile and restart the application.

Using directories rather than JARs

Regardless of whether you choose to eventually package your extension's chrome in a JAR or in directories, developing in directories is simpler. If you choose a JARed structure for releasing, you can still develop with a directory structure by editing your chrome.manifest. For example, rather than having

content	myExtension	jar:chrome/myExtension.jar!/content/

use

content	myExtension	chrome/content/

Preventing the first launch extension selector

Requires Gecko 8.0(Firefox 8.0 / Thunderbird 8.0 / SeaMonkey 2.5)

Starting in Firefox 8, on the first launch of a new version of Firefox, it presents user interface letting users select which third party add-ons to keep. This lets them weed out add-ons that were installed without their knowledge, or that are no longer needed.

However, this interface can be disruptive when debugging add-ons. You can avoid this by setting the preference extensions.autoDisableScopes to 14.

Document Tags and Contributors

Tags: 
  • Add-ons
  • Extensions
  • Guide
 Contributors to this page: bunnybooboo, wbamberg, wesleyvandekerckhove, Druzion, drugan, groovecoder, maymay, jsx, narmatha.k, reap3r119, peter.kehl, Brettz9, wakka27, Noitidart, wsha, JoachimSchipper, kscarfone, reesd, Gerv, Nfroidure, Sheppy, xertoz, Shadoefax, 4lex11s, ratcliffe_mike, eric.slosser, Nickolay, Max1million, Aryx, mozjonathan, wellington7, jwm, kmaglione, seanp33, Naesten, waldir, coredumperror, maratbn, DaveG, ericjung, scotmanaher, Whimboo, rutsky, Gryllida, MattBrubeck, Tyyppi, Sjjung, codeghost_aj, Mossop, tito, davelester, ozgurcemsen, al maghi, mead, Sadik Khalid, MarkFinkle, penguin_traveller, jenzed, Philip Chee, Jesse, GavinSharp, Johnjbarton, krmartin, Hipe, Cuimingda, Nduthoit, Brianherman, Yozh88, Shastrakar, Jules Papillon, CrazyEyE, Bang zippy, Bhashem, Shaver, Efree, Dustin.m.gartner, Kinger, Tristram, Rudolf.noe, Mgjbot, Davidnqd, RickMeasham, ReorX, Blisskinny, Timcharper, Haloway13, Engmark, SylvainPasche, Bdouglas, Shoot, Np
 Last updated by: bunnybooboo, Apr 29, 2017, 2:59:55 AM
See also
  1. WebExtensions
  2. Getting started
    1. What are WebExtensions?
    2. Your first WebExtension
    3. Your second WebExtension
    4. Anatomy of a WebExtension
    5. Example WebExtensions
  3. How to
    1. Intercept HTTP requests
    2. Modify a web page
    3. Add a button to the toolbar
    4. Implement a settings page
  4. Concepts
    1. Using the JavaScript APIs
    2. User interface components
    3. Content scripts
    4. Match patterns
    5. Internationalization
    6. Content Security Policy
    7. Native messaging
  5. Porting
    1. Porting a Google Chrome extension
    2. Porting a legacy Firefox add-on
    3. Embedded WebExtensions
    4. Comparison with the Add-on SDK
    5. Comparison with XUL/XPCOM extensions
    6. Chrome incompatibilities
  6. Firefox workflow
    1. Temporary Installation in Firefox
    2. Debugging
    3. Getting started with web-ext
    4. web-ext command reference
    5. WebExtensions and the Add-on ID
    6. Publishing your WebExtension
  7. JavaScript APIs
    1. Browser support for JavaScript APIs
    2. alarms
    3. bookmarks
    4. browserAction
    5. browsingData
    6. commands
    7. contextMenus
    8. contextualIdentities
    9. cookies
    10. devtools.inspectedWindow
    11. devtools.network
    12. devtools.panels
    13. downloads
    14. events
    15. extension
    16. extensionTypes
    17. history
    18. i18n
    19. identity
    20. idle
    21. management
    22. notifications
    23. omnibox
    24. pageAction
    25. privacy
    26. runtime
    27. sessions
    28. sidebarAction
    29. storage
    30. tabs
    31. topSites
    32. webNavigation
    33. webRequest
    34. windows
  8. Manifest keys
    1. applications
    2. author
    3. background
    4. browser_action
    5. chrome_settings_overrides
    6. chrome_url_overrides
    7. commands
    8. content_scripts
    9. content_security_policy
    10. default_locale
    11. description
    12. developer
    13. devtools_page
    14. homepage_url
    15. icons
    16. manifest_version
    17. name
    18. omnibox
    19. options_ui
    20. page_action
    21. permissions
    22. protocol_handlers
    23. short_name
    24. sidebar_action
    25. version
    26. web_accessible_resources
  9. Add-on SDK
  10. Getting started
    1. Installation
    2. Getting started
    3. Troubleshooting
  11. High-Level APIs
    1. addon-page
    2. base64
    3. clipboard
    4. context-menu
    5. hotkeys
    6. indexed-db
    7. l10n
    8. notifications
    9. page-mod
    10. page-worker
    11. panel
    12. passwords
    13. private-browsing
    14. querystring
    15. request
    16. selection
    17. self
    18. simple-prefs
    19. simple-storage
    20. system
    21. tabs
    22. timers
    23. ui
    24. url
    25. webextension
    26. widget
    27. windows
  12. Low-Level APIs
    1. /loader
    2. chrome
    3. console/plain-text
    4. console/traceback
    5. content/content
    6. content/loader
    7. content/mod
    8. content/symbiont
    9. content/worker
    10. core/heritage
    11. core/namespace
    12. core/promise
    13. dev/panel
    14. event/core
    15. event/target
    16. frame/hidden-frame
    17. frame/utils
    18. fs/path
    19. io/byte-streams
    20. io/file
    21. io/text-streams
    22. lang/functional
    23. lang/type
    24. loader/cuddlefish
    25. loader/sandbox
    26. net/url
    27. net/xhr
    28. places/bookmarks
    29. places/favicon
    30. places/history
    31. platform/xpcom
    32. preferences/event-target
    33. preferences/service
    34. remote/child
    35. remote/parent
    36. stylesheet/style
    37. stylesheet/utils
    38. system/child_process
    39. system/environment
    40. system/events
    41. system/runtime
    42. system/unload
    43. system/xul-app
    44. tabs/utils
    45. test/assert
    46. test/harness
    47. test/httpd
    48. test/runner
    49. test/utils
    50. ui/button/action
    51. ui/button/toggle
    52. ui/frame
    53. ui/id
    54. ui/sidebar
    55. ui/toolbar
    56. util/array
    57. util/collection
    58. util/deprecate
    59. util/list
    60. util/match-pattern
    61. util/object
    62. util/uuid
    63. window/utils
  13. Firefox for Android
  14. Getting started
    1. Walkthrough
    2. Debugging
    3. Code snippets
  15. APIs
    1. Accounts.jsm
    2. BrowserApp
    3. HelperApps.jsm
    4. Home.jsm
    5. HomeProvider.jsm
    6. JavaAddonManager.jsm
    7. NativeWindow
    8. Notifications.jsm
    9. PageActions.jsm
    10. Prompt.jsm
    11. RuntimePermissions.jsm
    12. Snackbars.jsm
    13. Sound.jsm
    14. Tab
  16. Legacy
  17. Restartless extensions
    1. Overview
  18. Overlay extensions
    1. Overview
  19. Themes
  20. Lightweight themes
    1. Overview
  21. Complete themes
    1. Overview
  22. Publishing add-ons
  23. Guides
    1. Signing and distribution overview
    2. Submit an add-on
    3. Review policies
    4. Developer agreement
    5. Featured add-ons
    6. Contact addons.mozilla.org
  24. Community and support
  25. Channels
    1. Add-ons blog
    2. Add-on forums
    3. Stack Overflow
    4. Development newsgroup
    5. IRC Channel