0

I know:

  • For a content script, I just need to reload the web page, and the content scripts will be reloaded
  • For add-ons loaded as a temporary add-on, there is a Reload button in about:debugging: a click on the button will cause the background scripts to be reloaded.

But, I want to reload background scripts for an installed Firefox WebExtensions to debug it. The Reload button for installed add-ons is disabled. I'm using Firefox v51.

I want to do this, because the part of script that I want to debug, is loaded at the startup of extension loading.

How can I do that?

Makyen
  • 31,849
  • 12
  • 86
  • 121
zhm
  • 3,513
  • 3
  • 34
  • 55

1 Answers1

1

You will need to go to about:addons (Ctrl-Shift-A or Cmd-Shift-A on OSX). On the "Extensions" tab (tabs are along the left) there will be a line for your extension. On that line will be a Disable button and a Remove button. If you click the Disable button, your add-on will be disabled. That button will then change to Enable. You can then click the Enable button to re-enable your add-on.

Performing that process will unload and reload your background scripts.

Makyen
  • 31,849
  • 12
  • 86
  • 121
  • When I disable the add-on, the Developer Tool for background scripts becomes blank, and my breakpoints are lost. I want to reload the background scripts to trigger my breakpoints. Is it possible? – zhm Feb 06 '17 at 08:16
  • If the break points are ones which you have set after the scripts are loaded, i.e. not [`debugger`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/debugger) statements, then, no. I suspect that even with using `debugger` it might be tricky. You may need to resort to `console.log()` debugging. – Makyen Feb 06 '17 at 08:26