globals
Globals in this section are subject to change in the future and/or are likely to be of interest to SDK module developers, rather than add-on developers.
Components
To access the infamous and powerful Components
object, see the
Chrome Authority documentation.
__url__
The __url__
global is a string identifying the URL from which the code has
been retrieved. If the code has no identifiable URL, this value may be null
.
packaging
For more information on packaging, see the Package Specification appendix.
The packaging
global contains methods and metadata related to
the packages available in the current environment.
packaging.getURLForData(path)
Given a unix-style path relative to the calling package's data
directory, returns an absolute URL to the file or directory.
By "calling package", we mean the package in which the caller's source code resides.
Thus, for example, if a package contains a resource at
data/mydata.dat
and a module at lib/foo.js
, the module at
lib/foo.js
may make the following call to retrieve an absolute URL
to data/mydata.dat
:
var myDataURL = packaging.getURLForData("/mydata.dat");
If the calling package has no data
directory, an exception is
thrown.
memory
memory
is an object that exposes functionality to track
objects of interest and help diagnose and prevent memory leaks.
memory.track(object, [bin])
Marks object for being tracked, and categorizes it with the given
bin name. If bin isn't specified, the memory tracker attempts to
infer a bin name by first checking the object's
constructor.name
; if that fails or results in the generic
Object
, the stack is inspected and the name of the current
function being executed—which is assumed to be a constructor
function—is used. If that fails, then the object is placed in a
bin named generic
.
memory.getObjects([bin])
Returns an Array
containing information about tracked objects
that have been categorized with the given bin name. If bin isn't
provided, information about all live tracked objects are returned.
Each element of the array is an object with the following keys:
weakref |
A weak reference to the object being tracked. Call
get() on this object to retrieve its strong reference; if
a strong reference to the object no longer exists, get()
will return null . |
created |
A Date representing the date and time that
memory.track() was called on the object being
tracked. |
filename |
The name of the file that called memory.track() on
the object being tracked. |
lineNo |
The line number of the file that called
memory.track() on the object being tracked. |
memory.getBins()
Returns an Array
containing the names of all bins that aren't
currently empty.