Confirmed users
497
edits
([master fe5d673] Formatting tweaks for Debugger.Source merge.) |
([master ed515ef] Rework source introduction metadata; add access for script's global.) |
||
| Line 553: | Line 553: | ||
<dt>sourceLength | <dt>sourceLength | ||
<dd>The length, in characters, of this script's code within the <code>Debugger.Source</code> instance given by <code>source</code>. | <dd>The length, in characters, of this script's code within the <code>Debugger.Source</code> instance given by <code>source</code>. | ||
<dt>global | |||
<dd>A <code>Debugger.Object</code> instance referring to the global object in whose scope this script runs. The result refers to the global directly, not via a wrapper or a <code>WindowProxy</code> ("outer window", in Firefox). | |||
<dt>staticLevel | <dt>staticLevel | ||
| Line 944: | Line 947: | ||
<dt>getVariable(<i>name</i>) | <dt>getVariable(<i>name</i>) | ||
<dd>Return the value of the variable bound to <i>name</i> in this environment, or <code>undefined</code> if this environment does not bind <i>name</i>. <i>Name</i> must be a string that is a valid ECMAScript identifier name. The result is a debuggee value. | <dd>Return the value of the variable bound to <i>name</i> in this environment, or <code>undefined</code> if this environment does not bind <i>name</i>. <i>Name</i> must be a string that is a valid ECMAScript identifier name. The result is a debuggee value. | ||
JavaScript engines often omit variables from environments, to save space and reduce execution time. If the given variable should be in scope, but <code>getVariable</code> is unable to produce its value, it returns an ordinary JavaScript object (not a <code>Debugger.Object</code> instance) whose <code>optimizedOut</code> property is <code>true</code>. | |||
This is not an [[#Invocation_Functions_and_.22debugger.22_Frames|invocation function]]; if this call would cause debuggee code to run (say, because the environment is a <code>"with"</code> environment, and <i>name</i> refers to an accessor property of the <code>with</code> statement's operand), this call throws a [[#The_Debugger.DebuggeeWouldRun_Exception|<code>Debugger.DebuggeeWouldRun</code>]] exception. | This is not an [[#Invocation_Functions_and_.22debugger.22_Frames|invocation function]]; if this call would cause debuggee code to run (say, because the environment is a <code>"with"</code> environment, and <i>name</i> refers to an accessor property of the <code>with</code> statement's operand), this call throws a [[#The_Debugger.DebuggeeWouldRun_Exception|<code>Debugger.DebuggeeWouldRun</code>]] exception. | ||
| Line 1,042: | Line 1,047: | ||
<dd>If this source belongs to a DOM element because it is an event handler content attribute or an event handler IDL attribute, this is the name of that attribute, a string. Otherwise, this is <code>undefined</code>. | <dd>If this source belongs to a DOM element because it is an event handler content attribute or an event handler IDL attribute, this is the name of that attribute, a string. Otherwise, this is <code>undefined</code>. | ||
<dt> | <dt>introductionType <i>(not yet implemented)</i> | ||
<dd> | <dd>A string indicating how this source code was introduced into the system. This accessor returns one of the following values: | ||
<ul> | <ul> | ||
<li> | <li><code>"eval"</code>, for code passed to <code>eval</code>. | ||
<li> | <li><code>"Function"</code>, for code passed to the <code>Function</code> constructor. | ||
<li> | <li><code>"Worker"</code>, for code loaded by calling the Web worker constructor—the worker's main script. | ||
<li> | <li><code>"importScripts"</code>, for code by calling <code>importScripts</code> in a web worker. | ||
<li><code>"handler"</code>, for code assigned to DOM elements' event handler IDL attributes. | |||
<li><code>"scriptElement"</code>, for code belonging to <code><script></code> elements. | |||
<li><code>undefined</code>, if the implementation doesn't know how the code was introduced. | |||
</ul> | </ul> | ||
<dt>introductionScript <i>(not yet implemented)</i> | |||
<dt>introductionScriptOffset <i>(not yet implemented)</i> | <dt>introductionScriptOffset <i>(not yet implemented)</i> | ||
<dd>If <code>introductionScript</code> is | <dd>If this source was introduced by calling a function from debuggee code, then <code>introductionScript</code> is the <code>Debugger.Script</code> instance referring to the script containing that call, and <code>introductionScriptOffset</code> is the call's bytecode offset within that script. Otherwise, these are both <code>undefined</code>. Taken together, these properties indicate the location of the introducing call. | ||
For the purposes of these accessors, assignments to accessor properties are treated as function calls. Thus, setting a DOM element's event handler IDL attribute by assigning to the corresponding JavaScript property creates a source whose <code>introductionScript</code> and <code>introductionScriptOffset</code> refer to the property assignment. | |||
Since a <code><script></code> element parsed from a web page's original HTML was not introduced by any scripted call, its source's <code>introductionScript</code> and <code>introductionScriptOffset</code> accessors both return <code>undefined</code>. | |||
If a <code><script></code> element was dynamically inserted into a document, then these accessors refer to the call that actually caused the script to run—usually the call that made the element part of the document. Thus, they do <i>not</i> refer to the call that created the element; stored the source as the element's text child; made the element a child of some uninserted parent node that was later inserted; or the like. | |||
< | |||
</ | |||
Although the main script of a worker thread is introduced by a call to <code>Worker</code> or <code>SharedWorker</code>, these accessors always return <code>undefined</code> on such script's sources. A worker's main script source and the call that created the worker are always in separate threads, but <code>Debugger</code> is an inherently single-threaded facility: its debuggees must all run in the same thread. Since the global that created the worker is in a different thread, it is guaranteed not to be a debuggee of the <code>Debugger</code> instance that owns this source; and thus the creating call is never "in debuggee code". Relating a worker to its creator, and other multi-threaded debugging concerns, are out of scope for <code>Debugger</code>. | |||
</dl> | </dl> | ||