How come I get this message from Firefox Web Console
The Web Console logging API (console.log, console.info, console.warn, console.error) has been disabled by a script on this page
The same webpage can print messages in Chrome Console but not Firefox. I opened the same webpage in another computers' Firefox (don't know what version) Web Console can print messages. My Firefox version is the latest, 8.0.
This happens when the page itself defines a global variable called console, for example. If the page is browser-sniffing to decide whether to define it, the behavior could differ in different browsers.
In the case of Firefox it also happens when Firebug is installed and its console is enabled, since that overrides the default window.console.
I had the same exact error message, and once I removed firebug, it went away.
I'm not saying you should remove firebug, I love firebug, but that is most probably the source of the error for you as well. One more note, the error was still there even if firebug was turned off (disabled) for that particular page.
Here is a JavaScript workaround I used to restore console API after it was set to empty function by a script on the page (works in Firefox 46, tested in Firebug and in greasemonkey script):
function restoreConsole() {
var i = document.createElement('iframe');
i.style.display = 'none';
document.body.appendChild(i);
window.console = i.contentWindow.console;
i.parentNode.removeChild(i);
}
More info and credentials: Restoring console.log()
Right click over firebug console tab and uncheck "enabled" option (the first one).
Related
I know that to debug content script use normal web developer tools (https://developer.mozilla.org/en/docs/Mozilla/Add-ons/WebExtensions/Debugging#Debugging_content_scripts), and this works perfect. debugger keyword works as intended.
But in this exact situation things get broken:
addon.id = "123-568-485"; // I never define `addon` before this line, so this cause: ReferenceError: "addon is not defined". We aren't aware of this mistake.
// Some more code
// Some more code
// Some more code
// Some more code
debugger; // Here we want to stop execution and inspect, some other stuff. Remember that we aren't aware of earlier mistake.
What we would expect, that in console error about Reference error will appear, but it doesn't. Console get silent, and we don't know why our debugger keyword doesn't work.
This kind of silent error, happened to me when I misspell variable name. In result couldn't figure out what's wrong.
The errors in the content script are not reported in the tab's Web Console due to Firefox bug 1410932, which is not fixed (as of Firefox 79, released on 2020-07-28).
I listed possible workarounds in another answer:
use try..catch with logging,
check the Browser Console (which does show errors from the content script)
use the Debugger's "pause on exceptions" option.
Content scripts are executed in webpage, So as you know to see it's output you should open up console menu in that specific web page (ctrl+shift+e then go to console).
But if something is wrong with content script and cause it to throw exception, The error log would be shown in debug area of your extension in: about:debugging
I think the reason is content scripts are treated like extra frame for webpage and their error is shown there.
I have a problem with console.log in regular mode in Google Chrome. The same code logs correctly in Opera and in incognito mode in Chrome.
Here I've read recommendations to turn off Firebug extention but I don't have it.
Console.log messages not showing up in Chrome's javascript console?
I tried to turn off all extentions and then tested console.log (and alert) again with no success. in incognito mode it works fine, also levels filter is set to All levels (why is it disabled btw?) so nothing is hidden.
the same code
$("#turnOffAll").click(function(){
var filterId=$('#filterId').val();
console.log('clicked on filter'+filterId);
});
in regular mode in Chrome outputs nothing.
what can cause this behavior?
Deleting the cache worked for me. Open 3-dot-menu -> more tools -> delete browser data -> select cache.
You may not have enabled a correct level in your console:
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.
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.
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
So I need to check some results in a Firefox add-on I'm working on, however the console.log() does not work. I've tried simply putting,console.log("Hello World"); in the main.js file and loading it, but it doesn't log anything.
By default the minimum log level is error. Everything else is not printed, and that includes console.log(). Please see the Log Levels for more information on how to use and configure logging and associated levels.
If you are working on an extension/addon (not SDK), simply import the Console.jsm and then the console.log() will work normally. That is what I do.
Components.utils.import('resource://gre/modules/devtools/Console.jsm');
Update: As of Firefox 44+
Components.utils.import('resource://gre/modules/Console.jsm');
You can use Firebug for your firefox extension development. If you install this add-on, you can use its console with "Firebug.Console.log();" command. Please be careful, in this command you should not type "Console" with a small letter!
In addition, you can use Firefox "Browser Console" (not Web Console) by the following command:
Application.console.log();
Using the Addon SDK? You must set the Log level for your extension:
var self = require("sdk/self");
var prefService = require("sdk/preferences/service");
prefService.set('extensions.'+ self.id +'.sdk.console.logLevel','all');
I have a strange problem in Internet Explorer with JavaScript. In every browser I did the test the JavaScript is enabled, but it seems to run only after I press the F12, running it in debug mode. And what is more confusing, after starting the IE debugger everything is working as suppose to.
Any ideas what it could be?
If you're calling:
console.log('...some text here...');
or any related method of console without having checked if window.console exists, the script will fail silently. Opening the console leads to window.console existing, which allows the script to continue execution.
Add "window.console && " before your calls to console:
window.console && console.log('works');