I’m reading the Firefox source code and I would like to know how to create some global functions.
I can’t find where the window object is created or how to define some global objects to be accessed by scripts.
I would like to know where to begin or at least where the window object is defined and created, thanks!
The
windowobject is mostly defined in nsGlobalWindow.cpp. The public methods/properties belong to nsIDOMWindow, nsIDOMJSWindow, nsIDOMEventTarget, nsIDOMStorageIndexedDB and some other interfaces (look forNS_INTERFACE_MAP_ENTRYmacros but not all of them refer to public interfaces).In addition, as any DOM object it can have expando properties (properties set by script). Some of these expando properties are set automatically when the DOM wrapper is created (nsWindowSH class). In particular, components implementing nsIDOMGlobalPropertyInitializer can set properties at that stage, or components listening to content-document-global-created notification.