1

I just started getting into Mozilla Firefox extensions, and I'm sure I'll do a lot of mistakes, but I am unable to find errors nor logs from my extension's javascript.

My main.js:

var pageMod = require("sdk/page-mod");
var self = require("sdk/self");

pageMod.PageMod({
    include: "https://www.google.ee/*",
    contentScriptFile: self.data.url("popup.js")
});

where in popup.js I tried Application.console.log("message"); Firebug.Console.log("message"); console.log("message"); Components.utils.reportError(e); randomly deleted some semicolons and tried calling for object properties that do not exist (document.body.asdasdasd="asd"; etc.)
[popup.js also inserted message into page body, so I can confirm the code was executed]

I have checked Ctrl+Shift+k; Ctrl+Shift+j; Firebug's console, all of them are empty or show errors from webpage only. In my about:config extensions.logging.enabled=true and javascript.options.showInConsole=true.

What could I be missing or where do extension javascript logs appear?

3 Answers3

4

There are a few ways this can be set

  1. define JPM preferences

create firefox-prefs.json with your defined preferences.

{
  "extensions.sdk.console.logLevel": "all"
}

then include it with your command line call

jpm --prefs=./firefox-prefs.json test
  1. Define the preference in your code

using the preferences service include the following at the top of your index.js, lib/main.js or test/helper.js

require("sdk/preferences/service").set('extensions.sdk.console.logLevel', 'all');
  1. Manually configure the preference in your browser about:config.

    1. visit about:config
    2. right click > New > String
    3. enter preference name 'extensions.sdk.console.logLevel' with value 'all'

enter image description here

Source:

kylewelsby
  • 4,031
  • 2
  • 29
  • 35
3

Make sure you don't have your logging level turned off:

extensions.sdk.console.logLevel

Logging Levels

Filipe Silva
  • 21,189
  • 5
  • 53
  • 68
  • Thanks, this was what i was missing, didn't even have extensions.sdk.console.logLevel, added it manually –  Jul 16 '13 at 16:54
1

You have to enable addons logging and make sure you read logs on the Browser Console instead of the Web Console (see my answer here).

Community
  • 1
  • 1
mindrones
  • 1,173
  • 11
  • 15