Dragorn421
Dragorn421

Reputation: 184

How do I debug a firefox extension, it seemingly crashes silently

I cannot figure out how to debug my simple extension. Script (a content script) loads (because the first console.log call shows in the tab's console) but then nothing. There's no error what so ever and no second console.log call.

My question is not about solving my code issue (there surely is one, if only firefox would tell me where), it's about finding the place where warnings/errors about the add-on are in firefox (like 'sdfsdf has no object property ...')

about:debugging is no help, the console it can open shows some errors (example: 'Error: Service "domainInfo" is not available. Make sure it appears in the "requiresServices" property of the module's background where is it used.') that have nothing to do with what I'm trying to do (I can tell from the source and nature of errors)

// start of file
console.log('I AM LOADING');
// simple DOM manipulation code here...
console.log('I AM LOADED');
// end of file

Upvotes: 4

Views: 1275

Answers (1)

Nickolay
Nickolay

Reputation: 32063

The content scripts are supposed to be debugged with the DevTools instance attached to the web page.

However, as you noticed, the errors in the content script are not reported in the tab's Web Console due to a bug. (As of Firefox 70.)

As a workaround you can:

  • use try..catch with logging,
  • check the Browser Console (which does show error in the content script)
  • use the Debugger's "pause on exceptions" option.

Upvotes: 5

Related Questions