1

For Mozilla WebExtensions, how do I get Javascript errors to show up in the console log?

I'm opening the developer tools for the appropriate tab. I run the code below in a WebExtension content script.

"use strict"
console.log("Load start."); 
foofoofoo; // ***TEMP*** force error

The message "Load start." appears in the console for that tab, but there's no message for the error from the next line. I never seem to get any Javascript error messages from add-ons in the console. I can see them if I step through in the debugger, but can't just get an ordinary Javascript error message.

John Nagle
  • 1,530
  • 1
  • 14
  • 15
  • Firefox documentation says that the "Error console" is obsolete [https://developer.mozilla.org/en-US/docs/Archive/Mozilla/Error_console], but if I bring it up with CTL-SHIFT-J, the Javascript error messages appear. – John Nagle Jul 15 '17 at 18:58
  • DId you tryed looking at the browser's toolbox console? https://developer.mozilla.org/en-US/docs/Tools/Browser_Toolbox – gal007 Jul 15 '17 at 23:36
  • Have you enabled display of JavaScript errors (drop-down in the DevTools on the left just above the area where the messages display. It's opened from "JS" in which you can select "Errors" and "Warnings")? – Makyen Jul 16 '17 at 08:28
  • Related/duplicate: [Google Chrome / Firefox do not see extension output in console](https://stackoverflow.com/a/38920982) – Makyen Jul 16 '17 at 08:28
  • Re "tryed looking at the browser's toolbox console?" Yes. Doesn't help. – John Nagle Jul 17 '17 at 01:24
  • Re "enabled display of JavaScript errors". Yes. Doesn't help. Only the global browser console, not the tab-local developer console, seems to get errors from content scripts. – John Nagle Jul 17 '17 at 01:26

2 Answers2

1

The "Browser console" (CTL-SHIFT-J) shows the Javascript error messages from a content script, but the Developer Tools console, even though it will show log messages from an add-on content script, does not.

This does not appear to be documented.

John Nagle
  • 1,530
  • 1
  • 14
  • 15
0

In addition to the browser console that you already discovered and the browser toolbox you can find addon-specific debuggers under about:debugging.

Which debugger to use for which context is documented on the MDN article WebExtensions/Debugging

the8472
  • 40,999
  • 5
  • 70
  • 122
  • Documented, but in a misleading way. "You'll see any output from console.log() statements in your content scripts. You will also see your content scripts listed in the Debugger, where you'll be able to set breakpoints, step through the code, and so on." Yes, you see those. But not Javascript errors from the content script. – John Nagle Jul 17 '17 at 01:28