Components.utils 编辑
Components.utils
is a collection of various useful XPConnect features. Its interface is defined at js/xpconnect/idl/xpccomponents.idl
.
The object currently has the following members:
EDITORS! please keep this list in sync with the Components object page
Methods
Method | Description |
---|---|
cloneInto() | Create a structured clone of an object in a different JavaScript context. |
createArrayIn() | Removed in Gecko 31 Returns an array created in specified compartment. |
createObjectIn() | Creates a new object, created in the scope of the specified object's compartment. |
dispatch() | Dispatches a runnable to the current/main thread. If the parameter is passed, the runnable will be dispatch in the compartment of the parameter, which affects which error reporter gets called. |
evalInSandbox() | Runs JavaScript code in a sandbox, usually used to run code with restricted privileges. |
evalInWindow() | Removed in Gecko 34. Evaluate JavaScript code in a less-privileged JavaScript context. |
exportFunction() | Export a JavaScript function from a more-privileged to a less-privileged scope, allowing it to be called in the less-privileged scope. |
forceGC() | Forces a garbage collection cycle. |
forceCC() | Forces a cycle collection cycle. |
forceShrinkingGC() | Forces a shrinking garbage collection cycle. |
getComponentsForScope() | This seemingly-paradoxical API allows privileged code to explicitly give unprivileged code a reference to its own Components object (whereas it's normally hidden away on a scope chain visible only to XBL methods). See also SpecialPowers.getComponents. |
getGlobalForObject() | Returns the global object with which a given object is associated (through its prototype chain at birth, for example). |
getJSTestingFunctions() | |
getObjectPrincipal() | Gets the nsIPrincipal for the given JavaScript object. |
getWeakReference() | Gets a weak reference for the object passed in. |
import() | Loads a JS module into the current script, without sharing a scope. |
importGlobalProperties() | Specify a list of constructors to import into the scope. |
isXrayWrapper() | Test whether a given object is an Xray or not. |
unload() | Unloads a JS module loaded with import(). |
isDeadWrapper() | Determines whether this object is backed by a DeadObjectProxy. |
lookupMethod() | Looks up a native (i.e. declared in the interface) method or property of an XPCOM object. Serves the same purpose as XPCNativeWrapper. |
makeObjectPropsNormal() | Ensures that all functions come from the specified object's scope, and aren't cross-compartment wrappers. May only be called from JavaScript code. |
nondeterministicGetWeakMapKeys() | Return the keys in a weak map. This operation is non-deterministic because it is affected by the scheduling of the garbage collector and the cycle collector. This should only be used to write tests of the interaction of the GC and CC with weak maps. Obsolete since Gecko 45 the function was moved to |
nukeSandbox() | |
recomputeWrappers() | To be called from JS only. This is for Gecko internal use only, and may disappear at any moment. |
reportError() | Reports a JavaScript Error object to the Error Console. |
setWantXrays() | To be called from JS only. This is for Gecko internal use only, and may disappear at any moment. |
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. |
setGCZeal() | Sets the level of garbage collection level for full garbage collection. See JS_SetGCZeal for details; this method calls through to that with the specified value as the zeal value. |
unwaiveXrays() | Undoes waiveXrays() : reapplies the Xray filtering protection. |
waiveXrays() | Removes the filtering provided by an Xray. |
Properties
Property | Type | Description |
Sandbox | nsIXPCComponents_utils_Sandbox | Creates sandbox objects for use with evalInSandbox() . |
ion | Boolean | Read only. |
strict | Boolean | Strict mode is enabled. This reflects the value of the JavaScript environment's option by the same name. Read only. |
strict_mode | Boolean | Read only. |
werror | Boolean | Warnings should be treated as errors. This reflects the value of the JavaScript environment's option by the same name. Read only. |
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论