mozilla

Revision 60365 of Components.utils

  • Revision slug: Components.utils
  • Revision title: Components.utils
  • Revision id: 60365
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment update for bug 661927 - add schedulePreciseGC; 46 words added

Revision Content

Components.utils is a collection of various useful XPConnect features. Its interface is defined at {{ Source("js/src/xpconnect/idl/xpccomponents.idl") }}. The object currently has the following members:

EDITORS! please keep this list in sync with the Components object page

Property Description
evalInSandbox Runs JavaScript code in a sandbox, usually used to run code with restricted privileges.
forceGC {{ Gecko_minversion_inline("1") }} Forces a garbage collection cycle.
getGlobalForObject {{ Gecko_minversion_inline("1.9.3") }} Returns the global object with which a given object is associated (through its prototype chain at birth, for example).
getWeakReference {{ Gecko_minversion_inline("1") }} Gets a weak reference for the object passed in.
import {{ Gecko_minversion_inline("1") }} Loads a JS module into the current script, without sharing a scope.
lookupMethod

Looks up a native (i.e. declared in the interface) method or property of an XPCOM object. Serves the same purpose as XPCNativeWrapper.

reportError Reports a JavaScript Error object to the Error Console.
Sandbox Creates sandbox objects for use with evalInSandbox.
schedulePreciseGC Schedules a garbage collection cycle for some time in the future at which no JavaScript code is running. This lets you specify a callback so you can be notified once the garbage collection cycle has been performed. {{ gecko_minversion_inline("7.0") }}

{{ languages( { "fr": "fr/Components.utils", "ja": "ja/Components.utils", "pl": "pl/Components.utils" } ) }}

Revision Source

<p><code>Components.utils</code> is a collection of various useful XPConnect features. Its interface is defined at {{ Source("js/src/xpconnect/idl/xpccomponents.idl") }}. The object currently has the following members:</p>
<p><span class="comment">EDITORS! please keep this list in sync with the <a href="/en/Components_object" title="en/Components object">Components object</a> page</span></p>
<table class="fullwidth-table"> <tbody> <tr> <th>Property</th> <th>Description</th> </tr> <tr> <td><code><a href="/en/Components.utils.evalInSandbox" title="en/Components.utils.evalInSandbox">evalInSandbox</a></code></td> <td>Runs JavaScript code in a sandbox, usually used to run code with restricted privileges.</td> </tr> <tr> <td><code><a href="/en/Components.utils.forceGC" title="en/Components.utils.forceGC">forceGC</a></code></td> <td>{{ Gecko_minversion_inline("1") }} Forces a garbage collection cycle.</td> </tr> <tr> <td><code><a href="/en/Components.utils.getGlobalForObject" title="en/Components.utils.getGlobalForObject">getGlobalForObject</a></code></td> <td>{{ Gecko_minversion_inline("1.9.3") }} Returns the global object with which a given object is associated (through its prototype chain at birth, for example).</td> </tr> <tr> <td><code><a href="/en/Components.utils.getWeakReference" title="en/Components.utils.getWeakReference">getWeakReference</a></code></td> <td>{{ Gecko_minversion_inline("1") }} Gets a weak reference for the object passed in.</td> </tr> <tr> <td><code><a href="/en/Components.utils.import" title="en/Components.utils.import">import</a></code></td> <td>{{ Gecko_minversion_inline("1") }} Loads a JS module into the current script, without sharing a scope.</td> </tr> <tr> <td><code><a href="/en/Components.utils.lookupMethod" title="en/Components.utils.lookupMethod">lookupMethod</a></code></td> <td> <p>Looks up a native (i.e. declared in the interface) method or property of an XPCOM object. Serves the same purpose as <a href="/en/XPCNativeWrapper" title="en/XPCNativeWrapper">XPCNativeWrapper</a>.</p> </td> </tr> <tr> <td><code><a href="/en/Components.utils.reportError" title="en/Components.utils.reportError">reportError</a></code></td> <td>Reports a JavaScript Error object to the <a href="/en/Error_Console" title="en/Error_Console">Error Console</a>.</td> </tr> <tr> <td><code><a href="/en/Components.utils.Sandbox" title="en/Components.utils.Sandbox">Sandbox</a></code></td> <td>Creates sandbox objects for use with <code>evalInSandbox</code>.</td> </tr> <tr> <td><a href="/en/Components.utils.schedulePreciseGC" title="en/Components.utils.schedulePreciseGC"><code>schedulePreciseGC</code></a></td> <td>Schedules a garbage collection cycle for some time in the future at which no JavaScript code is running. This lets you specify a callback so you can be notified once the garbage collection cycle has been performed. {{ gecko_minversion_inline("7.0") }}</td> </tr> </tbody>
</table>
<p>{{ languages( { "fr": "fr/Components.utils", "ja": "ja/Components.utils", "pl": "pl/Components.utils" } ) }}</p>
Revert to this revision