Skip to content

Commit

Permalink
Fix importScripts() script execution
Browse files Browse the repository at this point in the history
This fixes #193, which notes that importScripts() previously sent errors down the "report an exception" path instead of rethrowing them. It also makes a slight change of rethrowing any early errors that are not SyntaxErrors, instead of converting early ReferenceErrors into SyntaxErrors.
  • Loading branch information
domenic committed Dec 18, 2015
1 parent f509fb6 commit 71e7699
Showing 1 changed file with 41 additions and 22 deletions.
63 changes: 41 additions & 22 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -85776,8 +85776,8 @@ interface <dfn>NavigatorOnLine</dfn> {
<h5>Calling scripts</h5>

<p>When a user agent is to <dfn>jump to a code entry-point</dfn> for a <span
data-x="concept-script">script</span> <var>s</var>, the user agent must run the
following steps:</p>
data-x="concept-script">script</span> <var>s</var>, given an optional <var>rethrow errors</var>
flag, the user agent must run the following steps:</p>

<ol>

Expand All @@ -85792,15 +85792,40 @@ interface <dfn>NavigatorOnLine</dfn> {
<li><p>Let <var>result</var> be <span data-x="js-ParseScript">ParseScript</span>(<var>s</var>'s
code entry-point, <var>s</var>).</p></li>

<li><p>If <var>result</var> is a List of errors, <span>report the exception</span> given by the
first element in <var>result</var> for the script <var>s</var>, and go to the step labeled
<i>cleanup</i>.</p></li>
<li>
<p>If <var>result</var> is a List of errors, then:</p>

<ol>
<li><p>If the <var>rethrow errors</var> flag is set and <var>s</var>'s <var>muted errors</var>
flag is not set, rethrow the error given by the first element of <var>result</var>.</p></li>

<li><p>If the <var>rethrow errors</var> flag is set and <var>s</var>'s <var>muted
errors</var> flag is set, throw a <code>NetworkError</code> exception.</p></li>

<li><p>If the <var>rethrow errors</var> flag is not set, <span>report the exception</span>
given by the first element in <var>result</var> for the script <var>s</var>.</p></li>

<li><p>In all cases, go to the step labeled <i>cleanup</i>.</p></li>
</ol>
</li>

<li><p>Let <var>status</var> be <span
data-x="js-ScriptEvaluation">ScriptEvaluation</span>(<var>result</var>).</p></li>

<li><p>If <var>status</var> is an abrupt completion, <span>report the exception</span> given by
<var>result</var>.[[value]] for the script <var>s</var>.</p></li>
<li>
<p>If <var>status</var> is an abrupt completion, then:</p>

<ol>
<li><p>If the <var>rethrow errors</var> flag is set and <var>s</var>'s <var>muted errors</var>
flag is not set, rethrow the error given by <var>result</var>.[[value]].</p></li>

<li><p>If the <var>rethrow errors</var> flag is set and <var>s</var>'s <var>muted
errors</var> flag is set, throw a <code>NetworkError</code> exception.</p></li>

<li><p>If the <var>rethrow errors</var> flag is not set, <span>report the exception</span>
given <var>result</var>.[[value]] for the script <var>s</var>.</p></li>
</ol>
</li>

<li><p><i>Cleanup</i>: <span>Clean up after running a callback</span> with
<var>settings</var>.</p></li>
Expand Down Expand Up @@ -85955,8 +85980,8 @@ interface <dfn>NavigatorOnLine</dfn> {

<p>When the specification says that a <span data-x="concept-script">script</span> is to be <dfn
data-x="create a script">created</dfn>, given some script source, a script source URL, an
<span>environment settings object</span>, and optionally a <var>muted errors</var> flag, the user
agent must run the following steps:</p>
<span>environment settings object</span>, and optionally <var>muted errors</var> and <var>rethrow
errors</var> flag, the user agent must run the following steps:</p>

<ol>

Expand All @@ -85977,7 +86002,7 @@ interface <dfn>NavigatorOnLine</dfn> {
errors</span> flag.</p></li>

<li><p><span data-x="jump to a code entry-point">Jump</span> to <var>script</var>'s <span>code
entry-point</span>.</p></li>
entry-point</span>, passing the <var>rethrow errors</var> flag if it was given.</p></li>

</ol>

Expand Down Expand Up @@ -95497,24 +95522,18 @@ interface <dfn>SharedWorker</dfn> : <span>EventTarget</span> {
<li>

<p><span>Create a script</span> using <var>source</var> as the script source, the
<span>URL</span> from which <var>source</var> was obtained, and <var>settings object</var> as
the <span>environment settings object</span>.</p>
<span>URL</span> from which <var>source</var> was obtained, <var>settings object</var> as
the <span>environment settings object</span>, and passing the <var>rethrow errors</var>
flag.</p>

<p>If <var>response</var> is <span>CORS-cross-origin</span>, pass the <var>muted errors</var>
flag to the <span>create a script</span> algorithm as well.</p>

<p>Let the newly created <span data-x="concept-script">script</span> run until it either
returns, fails to parse, fails to catch an exception, or gets prematurely aborted by the
"<span>kill a worker</span>" or "<span>terminate a worker</span>" algorithms defined
<p class="note">The newly created <span data-x="concept-script">script</span> will run until
it either returns, fails to parse, fails to catch an exception, or gets prematurely aborted
by the "<span>kill a worker</span>" or "<span>terminate a worker</span>" algorithms defined
above.</p>

<p>If <var>response</var> is <span>CORS-cross-origin</span> and either it failed to parse or
an exception was thrown, then throw a <code>NetworkError</code> exception and abort all these
steps.</p>

<p>If it failed to parse, then throw an ECMAScript <code
data-x="js-SyntaxError">SyntaxError</code> exception and abort all these steps. <ref spec=ECMA262></p>

<p>If an exception was thrown or if the script was prematurely aborted, then abort all these
steps, letting the exception or aborting continue to be processed by the calling <span
data-x="concept-script">script</span>.</p>
Expand Down

0 comments on commit 71e7699

Please sign in to comment.