During an extension development, I noticed that the Firefox debugger console doesn’t display any errors while injecting content scripts, for example, a syntax error, which I reckon would be quite common during development. To test this, I injected pure garbage as a script, and console had no indication of failure. Chrome, on the other hand, would correctly point out errors.
Am I missing something? Normal console.log messages are output as expected.
Iirc load errors of the script (which includes syntax errors) are logged to the browser console/add-on debugger since the script is never actually injected. I’m sure others will correct me if I’m wrong on that.
I think the Firefox console only reports uncaught errors. Syntax errors in content scripts injected with tabs.executeScript() are reported to the background page, and are thus not uncaught.
@jeenuv, could you be more specific as to what you mean by “the browser console”? I have the same problem now and can’t find the error outputs anywhere. Thanks!
There is multiple console windows - sometimes some webextension errors are not logged into Web Console (the one you see when you press F12 or Ctrl + Shift + K), but only in Browser Console (Ctrl + Shift + J). You can find it also through the Firefox main menu / Web Developer.
Related bugreport for missing errors in content scripts:
And currently the errors are shown in the browser console instead of the web console.
I noticed the console.log messages show in the web console but not in the browser console. This can be annoying. If you want to show the console.log messages in the browser console, you’ll have to select “Show Content Messages” in the settings. This way you have your console.log and error messages in one place.
For anyone who, like me, opened the Browser Console with Ctrl+Shift+J, and still didn’t see any error messages there:
You have to switch the Browser Console Mode from “Parent process only” to “Multiprocess”. Only there did I start seeing error messages from my content script (and also logs of event handlers of background script).
On Ubuntu Linux, I see the switch as a radio selector at the top of the browser console window: