I am trying to access global variables in my addons entry point in the debugger. Since this is not a web application there is no window object and the functions I define globally are not directly accessible in the debugger's console. Any help would be appreciated.
1 Answers
SDK addons do not have have a no shared global object. Each module has its own global into which shared functionality is injected, most prominently the require()
function which then provides access to exported objects from other modules.
For debugging you could console.log(this)
in some module and then access the logged object from the about:debugging console for that addon via rightclick -> store as global variable on the console output.
Also note that the global object is not the same as the top level scope in a file. var
declarations, this.foo = ...
assignments and and function bar() {}
statements get attached to the global object, let
, const
or anything in a IIFE are not.
So getting access to an object is not the same as having a console run in the same scope.
Simply logging the objects you need to access and then binding the logged objects to the current console usually does the trick for me.

- 40,999
- 5
- 70
- 122
-
Thanks. Oddly store as global variable doesn't seem to be working for me. My current solution is to add a debug point in my code and then just use the local context, but this seems kind of hackish. Is there no standard way of accessing the context of the "main" javascript file of the addon? – curious Aug 02 '16 at 22:03
-
i think there's a bug for that somewhere on bugzilla, but ultimately each module runs with a separate global and scope anyway, so you will never have access to all of them at once. – the8472 Aug 02 '16 at 23:22