• 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. Add-on Debugger

Add-on Debugger

In This Article
  1. Opening the Add-on Debugger
  2. Using the Add-on Debugger
    1. The JavaScript Debugger
      1. Content scripts
    2. The Console
    3. The Scratchpad
  3. Debugging chrome: and about: pages

The Add-on Debugger lets you run a subset of the Firefox developer tools in the context of your add-on:

  • JavaScript Debugger, to set breakpoints and examine the internal state of your code
  • Console, to see logged messages and evaluate JavaScript in the add-on's context
  • Scratchpad, to conveniently evaluate multiline JavaScript in the add-on context and save it to a file.

The Add-on Debugger is not available for restart-required XUL overlay add-ons. To debug add-ons like that, use the Browser Toolbox instead.

For a quick introduction to the Add-on Debugger, see this screencast:

Opening the Add-on Debugger

This describes how to open the Add-on Debugger from Firefox 45 onwards. For earlier versions of Firefox, you need to:

  • enable add-on debugging by checking the "Enable browser chrome and add-on debugging toolboxes" and "Enable remote debugging" settings in the developer tools

  • find the add-on in about:addons (not about:debugging), and click the "Debug" button on that page.

To connect the Add-on Debugger to an add-on, open the about:debugging page in Firefox, make sure the "Enable add-on debugging" box is checked, and click the "Debug" button next to your add-on's entry in the page.

Next you'll see a dialog asking you to accept an incoming connection. Click "OK", and the debugger will start in a separate window. Note that sometimes the debugger window is hidden by the main Firefox window.

Using the Add-on Debugger

The Add-on Debugger looks and behaves very much like the Browser Toolbox, except that while the scope of the Browser Toolbox is the whole browser, the Add-on Debugger is focused on the specific add-on for which you launched it. Like the Browser Toolbox, a toolbar along the top lets you switch between a number of different tools. In Firefox 31 there's only one such tool, the JavaScript Debugger, but with Firefox 32 you also get the Console and Scratchpad.

The JavaScript Debugger

This behaves just like the normal JavaScript Debugger, except its scope is the add-on rather than a web page. On the left-hand side it lists JavaScript sources:

  • at the top is bootstrap.js: either the one you've written if your add-on is a manually written bootstrapped add-on, or the one included by the SDK if your add-on is an SDK add-on.
  • next, if your add-on is an SDK add-on, you'll find your add-on's main.js, any local modules shipping with your add-on, and any content scripts that are currently loaded
  • next, all the SDK modules used directly or indirectly by your add-on

Content scripts

Content scripts are only listed if and when they are loaded. So, if your Add-on loads a content script with contentScriptFile, the file will not appear in the debugger sources until you go to a page that loads the content script.

If you set a breakpoint in a content script, it will not be active for instances of the content script which are loaded after the breakpoint is set.

For example, suppose you have an add-on that attaches a content script to every tab the user loads. The content script adds a click handler to the page. As soon as you open a tab, this content script will be listed in the debugger. If you then set a breakpoint in the content script's click handler, then execution will pause whenever you click the page. But if you open a new tab, there are now two instances of the content script, and the breakpoint will not be enabled for the second instance You'll need to set a new breakpoint now if you want to it work for the second instance.

We're investigating improvements to this in bug 1016046.

The Console

The Console behaves just like the Web Console, but its scope is the add-on rather than the web page.

However, note that it actually runs in the context of the add-on's bootstrap.js, which may not be what you expect if your add-on uses the SDK: you won't see any objects defined in your add-on's main.js, and you won't see require() either. This issue is being tracked as bug 1005193.

You can execute Console statements in the context of main.js while execution is paused inside main.js.

The Scratchpad

The Scratchpad behaves just like the normal Scratchpad, but its scope is the add-on rather than the web page.

Like the Console, the add-on Scratchpad runs in the context of the add-on's bootstrap.js even if the add-on uses the SDK, and as with the Console you can execute Scratchpad code in the context of main.js while execution is paused inside main.js.

Debugging chrome: and about: pages

From Firefox 37 onwards, you can debug chrome: and about: pages using the normal Debugger, just as if they were ordinary content pages.

Document Tags and Contributors

Tags: 
  • add-on
  • Advanced
  • Debugging
  • Developer
  • Firefox
  • Guide
  • Howto
  • JavaScript
 Contributors to this page: wbamberg, bunnybooboo, groovecoder, dkocho4, chrisdavidmills, kdamball, jon-freed
 Last updated by: wbamberg, Apr 28, 2017, 9:01:56 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