Skip to content
Permalink
Browse files

[e] (0) Rejigger how scripts are described. Work in progress.

Fixing https://www.w3.org/Bugs/Public/show_bug.cgi?id=22863
Affected topics: HTML, Workers

git-svn-id: http://svn.whatwg.org/webapps@8124 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information...
Hixie committed Aug 2, 2013
1 parent c7399b5 commit ee5dbf7d471eaf996aa2a0d86888d99801b01d9f
Showing with 196 additions and 158 deletions.
  1. +65 −53 complete.html
  2. +65 −53 index
  3. +66 −52 source

<hr><p>A <dfn id=concept-script title=concept-script>script</dfn> has:</p>

<dl><dt>A <dfn id=script-execution-environment>script execution environment</dfn></dt>
<dl><dt>A <dfn id=code-entry-point>code entry-point</dfn></dt>

<dd>

<p>The characteristics of the script execution environment depend on the language, and are not
defined by this specification.</p>
<p>A code entry-point represents a block of executable code that the script exposes to other
scripts and to the user agent. Typically, the code corresponding to the code entry-point is
executed immediately after the script is parsed, but for event handlers, it is called each time
the handler is invoked.</p>

<p class=example>In JavaScript, the script execution environment consists of the interpreter,
the stack of <i>execution contexts</i>, the <i>global code</i> and <i>function code</i> and the
<code>Function</code> objects resulting, and so forth.</p>
<p class=example>In JavaScript <code><a href=#the-script-element>script</a></code> blocks, this corresponds to the execution
context of the global code.</p>

</dd>

<dt>A <dfn id=list-of-code-entry-points>list of code entry-points</dfn></dt>
<dt>Optionally, a <dfn id=muted-errors>muted errors</dfn> flag</dt>

<dd>

<p>Each code entry-point represents a block of executable code that the script exposes to other
scripts and to the user agent.</p>
<p>A flag which, if set, means that error information will not be provided for errors in this
script (used to mute errors for cross-origin scripts, since that can leak private
information).</p>

</dd>
<!--
<dt>A relationship with a <span>script settings object</span></dt>

<dd>

<p>An object (defined below) that describes various settings that can be shared with other
scripts.</p>

</dd>

</dl>

<hr>

<p>Each global object has a <dfn>script settings object</dfn> shared by the scripts that use that
global object. A <span>script settings object</span> consists of the following:</p>

<dl>
-->
<dt>A <dfn id=script-execution-environment>script execution environment</dfn></dt>

<p class=example>Each <code>Function</code> object in a JavaScript <a href=#script-execution-environment>script execution
environment</a> has a corresponding code entry-point, for instance.</p>
<dd>

<p>The main program code of the script, if any, is the <dfn id=initial-code-entry-point><i>initial code
entry-point</i></dfn>. Typically, the code corresponding to this entry-point is executed
immediately after the script is parsed.</p>
<p>The characteristics of the script execution environment depend on the language, and are not
defined by this specification.</p>

<p class=example>In JavaScript, this corresponds to the execution context of the global
code.</p>
<p class=example>In JavaScript, the script execution environment consists of the interpreter,
the stack of <i>execution contexts</i>, the <i>global code</i> and <i>function code</i> and the
<code>Function</code> objects resulting, and so forth.</p>

</dd>


</dd>

<dt>Optionally, a <dfn id=muted-errors>muted errors</dfn> flag</dt>

<dd>

<p>A flag which, if set, means that error information will not be provided for errors in this
script (used to mute errors for cross-origin scripts, since that can leak private
information).</p>

</dd>

</dl></div>


script</a>.</li>

<li><p>Make the <a href=#script-execution-environment title="script execution environment">script execution environment</a>
for the <a href=#concept-script title=concept-script>script</a> execute the code for the given code
entry-point.</li>
for the <a href=#concept-script title=concept-script>script</a> execute the <a href=#concept-script title=concept-script>script</a>'s <a href=#code-entry-point>code entry-point</a>.</li>

<li><p>Pop the <a href=#concept-script title=concept-script>script</a> being invoked from the <a href=#stack-of-incumbent-scripts>stack of
incumbent scripts</a>.</li>
character encoding, a base URL, and optionally a <var title="">muted errors</var> flag, the user
agent must run the following steps:</p>

<ol><li><p>If <a href=#concept-bc-noscript title=concept-bc-noscript>scripting is
<ol><!--CLEANUP--><li><p>Let <var title="">script</var> be a new <a href=#concept-script title=concept-script>script</a> that
this algorithm will subsequently initialize.</li>

<li><p>If <a href=#concept-bc-noscript title=concept-bc-noscript>scripting is
disabled</a> for <a href=#browsing-context>browsing context</a> passed to this
algorithm, then abort these steps, as if the script did nothing but
algorithm, then abort these steps, as if the script source described a program that did nothing but
return void.</p>

<li><p>Set up a <a href=#script-execution-environment>script execution environment</a> as
appropriate for the scripting language.</li>
appropriate for the given scripting language.</li>

<li><p>Parse/compile/initialize the source of the script using the
<a href=#script-execution-environment>script execution environment</a>, as appropriate for the
scripting language, and thus obtain the <a href=#list-of-code-entry-points>list of code
entry-points</a> for the script. If the semantics of the
scripting language and the given source code are such that there is
executable code to be immediately run, then the <i><a href=#initial-code-entry-point>initial code
entry-point</a></i> is the entry-point for that code.</li>
scripting language, and thus obtain <var title="">script</var>'s <a href=#code-entry-point>code entry-point</a>.</li>

<li><p>Set up the <a href="#script's-global-object">script's global object</a>, the
<a href="#script's-browsing-context">script's browsing context</a>, the <a href="#script's-document">script's
<a href="#script's-base-url">script's base URL</a> from the settings passed to this
algorithm.</li>

<li><p>If the <var title="">muted errors</var> flag was set, then set the script's <a href=#muted-errors>muted
errors</a> flag also.</li>
<li><p>If the <var title="">muted errors</var> flag was set, then set <var title="">script</var>'s <a href=#muted-errors>muted
errors</a> flag.</li>

<li>

<p>If all the steps above succeeded (in particular, if the script
was compiled successfully), <a href=#jump-to-a-code-entry-point title="jump to a code
entry-point">Jump</a> to the <a href=#concept-script title=concept-script>script</a>'s <i><a href=#initial-code-entry-point>initial code
entry-point</a></i>.</p>
entry-point">Jump</a> to <var title="">script</var>'s <a href=#code-entry-point>code
entry-point</a>.</p>

<p>Otherwise, <a href=#report-the-error>report the error</a> for the <a href=#concept-script title=concept-script>script</a>,
with the problematic position (line number and column number), using <a href="#script's-global-object">script's global object</a> as the target. If the
<p>Otherwise, <a href=#report-the-error>report the error</a> for <var title="">script</var>,
with the problematic position (line number and column number), using the <a href="#script's-global-object">script's global object</a> as the target. If the
error is still <i title=concept-error-nothandled><a href=#concept-error-nothandled>not handled</a></i> after this, then the error
may be reported to the user.</p>

script source, the <a href=#url>URL</a> of the resource where the <code>javascript:</code> URL,
was found, and assuming the scripting language is JavaScript.</p>

<p>Let <var title="">result</var> be the return value of the <i><a href=#initial-code-entry-point>initial code entry-point</a></i>
<p>Let <var title="">result</var> be the return value of the <a href=#code-entry-point>code entry-point</a>
of this <a href=#concept-script title=concept-script>script</a>. If an exception was thrown, let <var title="">result</var> be void instead. (The result will be void also if <a href=#concept-bc-noscript title=concept-bc-noscript>scripting is disabled</a>.)</p>

<p>When it comes time to <a href="#set-the-document's-address">set the document's address</a> in the <a href=#navigate title=navigate>navigation algorithm</a>, use <var title="">address</var> as the
scripting language set to JavaScript, and with the <code>Document</code>'s object's
<span>browsing context</span> as the browsing context.</p>

<p>Let <var title="">result</var> be the return value of the <i>initial code entry-point</i>
<p>Let <var title="">result</var> be the return value of the <span>code entry-point</span>
of this <span title="concept-script">script</span>. If an exception was thrown, let <var
title="">result</var> be void instead. (The result will be void also if <span
title="concept-bc-noscript">scripting is disabled</span>.)</p>

<dd>The value of <var title="">strict</var>.</dd>

</dl><p>Let this new function be the only entry in the script's <a href=#list-of-code-entry-points>list of code
entry-points</a>.</p>
</dl><p>Let this new function be the script's <a href=#code-entry-point>code entry-point</a>.</p>

</li>


<dd>

<p>Invoke <var title="">callback</var> with five arguments,
<p><a href=#concept-invoke-event-handler title=concept-invoke-event-handler>Invoke</a> <var title="">callback</var> with five arguments,
the first one having the value of <var title="">E</var>'s <code title=dom-ErrorEvent-message><a href=#dom-errorevent-message>message</a></code> attribute,
the second having the value of <var title="">E</var>'s <code title=dom-ErrorEvent-filename><a href=#dom-errorevent-filename>filename</a></code> attribute,
the third having the value of <var title="">E</var>'s <code title=dom-ErrorEvent-lineno><a href=#dom-errorevent-lineno>lineno</a></code> attribute,

<dd>

<p>Invoke <var title="">callback</var> with one argument, the value of which is the
<p><a href=#concept-invoke-event-handler title=concept-invoke-event-handler>Invoke</a> <var title="">callback</var> with one argument, the value of which is the
<code><a href=#event>Event</a></code> object <var title="">E</var>, with the <i title=dfn-callback-this-value>callback this value</i> set to <var title="">E</var>'s <code title=dom-Event-currentTarget>currentTarget</code>. Let <var title="">return value</var> be the callback's return value. <a href=#refsWEBIDL>[WEBIDL]</a></p>

</dd>

</dl></li>
</dl><p>In this step, <dfn id=concept-invoke-event-handler title=concept-invoke-event-handler>invoke</dfn> means to run the
<a href=#jump-to-a-code-entry-point>jump to a code entry-point</a> alorithm.</p>

</li>

<li>

environment</a>. (In either case, by definition, it is a <a href=#worker-environment>worker
environment</a>.)</li>

<li>
<li><!-- SCRIPT EXEC -->

<p>A new <a href=#concept-script title=concept-script>script</a> is now created, as follows.</p>


<p>Parse/compile/initialize <var title="">source</var> using that <a href=#script-execution-environment>script execution
environment</a>, as appropriate for <var title="">language</var>, and thus obtain a
<a href=#list-of-code-entry-points>list of code entry-points</a>; set the <i><a href=#initial-code-entry-point>initial code entry-point</a></i> to the
entry-point for any executable code to be immediately run.</p>
<a href=#code-entry-point>code entry-point</a>.</p>

<p>Set the <a href="#script's-global-object">script's global object</a> to <var title="">worker global scope</var>.</p>


<li>

<p><a href=#jump-to-a-code-entry-point title="jump to a code entry-point">Jump</a> to the <a href=#concept-script title=concept-script>script</a>'s <i><a href=#initial-code-entry-point>initial code entry-point</a></i>, and let that run until
<p><a href=#jump-to-a-code-entry-point title="jump to a code entry-point">Jump</a> to the <a href=#concept-script title=concept-script>script</a>'s <a href=#code-entry-point>code entry-point</a>, and let that run until
it either returns, fails to catch an exception, or gets prematurely aborted by the "<a href=#kill-a-worker>kill a
worker</a>" or "<a href=#terminate-a-worker>terminate a worker</a>" algorithms defined below.</p>

0 comments on commit ee5dbf7

Please sign in to comment.
You can’t perform that action at this time.