Confirmed users
497
edits
m (→Properties of the Debug.Object prototype: formatting) |
(→Debug.Object: Add function access.) |
||
| Line 226: | Line 226: | ||
=== Properties of the <code>Debug.Object</code> prototype === | === Properties of the <code>Debug.Object</code> prototype === | ||
The functions described below may only be called with a <code>this</code> value referring to a <code>Debug.Object</code> instance; they may not be used as methods of other kinds of objects. The descriptions use "referent" to mean "the referent of this <code>Debug.Object</code> instance". | |||
<dl> | <dl> | ||
<dt>getPrototype() | <dt>getPrototype() | ||
<dd>Return the | <dd>Return the referent's prototype (as a new <code>Debug.Object</code> instance), or <code>null</code> if it has no prototype. | ||
<dt>getClass() | |||
<dd>Return a string naming the ECMAScript <code><nowiki>[[Class]]</nowiki></code> of the referent. | |||
<dt>hasOwnProperty(<i>name</i>) | |||
<dd>Return true if the referent has an own property named <i>name</i>. | |||
<dt>getOwnPropertyDescriptor(<i>name</i>) | <dt>getOwnPropertyDescriptor(<i>name</i>) | ||
<dd>Return a property descriptor for the property named <i>name</i> of the | <dd>Return a property descriptor for the property named <i>name</i> of the referent. (This function behaves like the standard <code>Object.getOwnPropertyDescriptor</code> function, except that the object being inspected is implicit; the property descriptor returned is in the debugger's compartment; and its <code>value</code>, <code>get</code>, and <code>set</code> properties, if present, are debuggee values.) | ||
<dt>getOwnPropertyNames() | <dt>getOwnPropertyNames() | ||
<dd>Return an array of strings naming all the own properties | <dd>Return an array of strings naming all the referent's own properties, as if <code>Object.getOwnPropertyNames(<i>referent</i>)</code> had been called in the debuggee, and the result copied to the debugger's compartment. | ||
<dt>defineProperty(<i>name</i>, <i>attributes</i>) | <dt>defineProperty(<i>name</i>, <i>attributes</i>) | ||
<dd>Define a property on | <dd>Define a property on the referent named <i>name</i>, as described by the property descriptor <i>descriptor</i>. Any <code>value</code>, <code>get</code>, and <code>set</code> properties of <i>attributes</i> must be debuggee values. (This function behaves like <code>Object.defineProperty</code>, except that the target object is implicit, and in a different compartment from the function and descriptor.) | ||
<dt>defineProperties(<i>properties</i>) | <dt>defineProperties(<i>properties</i>) | ||
<dd> | <dd>Add the properties given by <i>properties</i> to the referent. (This function behaves like <code>Object.defineProperties</code>, except that the target object is implicit, and in a different compartment from the <i>properties</i> argument.) | ||
<dt>deleteProperty(<i>name</i>) | <dt>deleteProperty(<i>name</i>) | ||
<dd>Remove the property named <i>name</i> | <dd>Remove the referent's property named <i>name</i>. Return true if the property was successfully removed, or if the referent has no such property. Return false if the property is non-configurable. | ||
<dt>seal() | <dt>seal() | ||
<dd>Prevent properties from being added or deleted from | <dd>Prevent properties from being added to or deleted from the referent. Return this <code>Debug.Object</code> instance. (This function behaves like the standard <code>Object.seal</code> function, except that the object to be sealed is implicit and in a different compartment from the caller.) | ||
<dt>freeze() | <dt>freeze() | ||
<dd>Prevent properties from being added or deleted from | <dd>Prevent properties from being added to or deleted from the referent, and mark each property as non-writable. Return this <code>Debug.Object</code> instance. (This function behaves like the standard <code>Object.freeze</code> function, except that the object to be sealed is implicit and in a different compartment from the caller.) | ||
<dt>preventExtensions() | <dt>preventExtensions() | ||
<dd>Prevent properties from being added to | <dd>Prevent properties from being added to the referent. (This function behaves like the standard <code>Object.preventExtensions</code> function, except that the object to operate on is implicit and in a different compartment from the caller.) | ||
<dt>isSealed() | <dt>isSealed() | ||
<dd>Return true if | <dd>Return true if the referent is sealed—that is, if it is not extensible, and all its properties have been marked as non-configurable. (This function behaves like the standard <code>Object.isSealed</code> function, except that the object inspected is implicit and in a different compartment from the caller.) | ||
<dt>isFrozen() | <dt>isFrozen() | ||
<dd>Return true if | <dd>Return true if the referent is frozen—that is, if it is not extensible, and all its properties have been marked as non-configurable and read-only. (This function behaves like the standard <code>Object.isFrozen</code> function, except that the object inspected is implicit and in a different compartment from the caller.) | ||
<dt>isExtensible() | <dt>isExtensible() | ||
<dd>Return true if | <dd>Return true if the referent is extensible—that is, if it can have new properties defined on it. (This function behaves like the standard <code>Object.isExtensible</code> function, except that the object inspected is implicit and in a different compartment from the caller.) | ||
<dt>isFunction() | |||
<dd>Return true if the referent has a <code><nowiki>[[Call]]</nowiki></code> internal method. | |||
<dt>functionName() | |||
<dd>If the referent is a named function, return its name. If the referent is an anonymous function, return <code>null</code>. If the referent is not a function, return undefined. | |||
<dt>functionParameterNames() | |||
<dd>If the referent is a function, return the names of its parameters as an array of strings. If the referent is not a function, return undefined. | |||
<dt> | <dt>functionScript() | ||
<dd> | <dd>If the referent is a function, return its script, as a <code>Debug.Script</code> instance. If the referent is not a function, return undefined. | ||
<dt>functionScope() | |||
<dd>If the referent is a function, return a <code>Debug.Object</code> instance referring to the lexical scope that enclosed the function when it was created. If the referent is not a function, return undefined. | |||
<dt>decompileFunction() | |||
<dd>If the referent is a function, return its decompiled source code. If the referent is not a function, return undefined. | |||
<dt>parent() | |||
<dd>If the referent is part of a chain of lexical scopes, return a <code>Debug.Object</code> instance referring to its enclosing lexical scope, or <code>null</code> if it is the outermost scope. If the referent is not part of such a chain, return undefined. | |||
<dt>referentToString() | <dt>referentToString() | ||
<dd>Return a string representing | <dd>Return a string representing the referent, showing its class and any other useful information, without invoking its <code>toString</code> or <code>toSource</code> members, or running any other debuggee code. The specific string returned is unspecified. (It is better to add functions to <code>Debug.Object.prototype</code> that retrieve the information you need about the object than to depend on details of <code>safeToString</code>'s behavior.) | ||
(Note that simply calling the <code>toString</code> method of a <code>Debug.Object</code> instance applies to instance itself, not its referent, and thus returns something like <code>"[Object Debug.Object]"</code>.) | (Note that simply calling the <code>toString</code> method of a <code>Debug.Object</code> instance applies to instance itself, not its referent, and thus returns something like <code>"[Object Debug.Object]"</code>.) | ||
</dl> | </dl> | ||