Skip to content

Commit

Permalink
[e] (0) Rejigger how scripts are described. Work in progress.
Browse files Browse the repository at this point in the history
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 ee5dbf7
Show file tree
Hide file tree
Showing 3 changed files with 196 additions and 158 deletions.
118 changes: 65 additions & 53 deletions complete.html
Expand Up @@ -71259,35 +71259,58 @@ <h5 id=definitions-0><span class=secno>7.1.3.1 </span>Definitions</h5>

<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>

Expand Down Expand Up @@ -71371,16 +71394,6 @@ <h5 id=definitions-0><span class=secno>7.1.3.1 </span>Definitions</h5>

</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>


Expand Down Expand Up @@ -71409,8 +71422,7 @@ <h5 id=calling-scripts><span class=secno>7.1.3.2 </span>Calling scripts</h5>
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>
Expand Down Expand Up @@ -71473,21 +71485,20 @@ <h5 id=creating-scripts><span class=secno>7.1.3.3 </span>Creating scripts</h5>
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
Expand All @@ -71496,18 +71507,18 @@ <h5 id=creating-scripts><span class=secno>7.1.3.3 </span>Creating scripts</h5>
<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>

Expand Down Expand Up @@ -72070,7 +72081,7 @@ <h4 id=javascript-protocol><span class=secno>7.1.5 </span><dfn title="javascript
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
Expand All @@ -72091,7 +72102,7 @@ <h4 id=javascript-protocol><span class=secno>7.1.5 </span><dfn title="javascript
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>
Expand Down Expand Up @@ -72309,8 +72320,7 @@ <h5 id=event-handler-attributes><span class=secno>7.1.6.1 </span>Event handlers<

<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>

Expand Down Expand Up @@ -72421,7 +72431,7 @@ <h5 id=event-handler-attributes><span class=secno>7.1.6.1 </span>Event handlers<

<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,
Expand All @@ -72436,12 +72446,15 @@ <h5 id=event-handler-attributes><span class=secno>7.1.6.1 </span>Event handlers<

<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>

Expand Down Expand Up @@ -80386,7 +80399,7 @@ <h4 id=processing-model-6><span class=secno>9.2.4 </span>Processing model</h4>
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>

Expand All @@ -80395,8 +80408,7 @@ <h4 id=processing-model-6><span class=secno>9.2.4 </span>Processing model</h4>

<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>

Expand Down Expand Up @@ -80437,7 +80449,7 @@ <h4 id=processing-model-6><span class=secno>9.2.4 </span>Processing model</h4>

<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>

Expand Down

0 comments on commit ee5dbf7

Please sign in to comment.