Reputation: 143
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.
Upvotes: 0
Views: 421
Reputation: 43042
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.
Upvotes: 1