Console doesn't display content script errors

(Jeenu) #1

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.

(Martin Giger) #2

I assume you’re looking in the Web Developer Tools console of the page the script is injected in?

(Jeenu) #3

Yes, I’m. That’s where I’d expect all content script output anyway!

(Martin Giger) #4

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.

(Jeenu) #5

Well, the script is injected. I could see all console.log messages before a syntax error, for example.

(Niklas Gollenstede) #6

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.

(Which is similar to what Martin Giger said.)

(Jeenu) #7

I’m talking about a content script mentioned in the manifest, and not injected from a background page. For example,

  "content_scripts" : [{
      "matches": [ "<all_urls>", "file:///*/*" ],
      "js": [ "test.js" ],
      "run_at": "document_end"

with test.js containing:


Only the “before” will appear on the console, meaning the script terminated thereafter; yet, the console has no indication that it has!

Isn’t this a bug? And no, it’s not reported on the background page debugger either.

(Jeenu) #8

Just stumbled on this bug: The error was indeed displayed on the Browser Console!