Browse files

Ensure there is an active script while running JS jobs

"Fixes" tc39/ecma262#871, at least for HTML,
given that we have our own version of EnqueueJob. Important for #3117.
  • Loading branch information...
domenic committed Nov 17, 2017
1 parent 8b055c0 commit cc3fcc87a7c6f8783efa327b449d7381a0e0303d
Showing with 48 additions and 2 deletions.
  1. +48 −2 source
50 source
@@ -3014,6 +3014,7 @@ a.setAttribute('href', ''); // change the content attribute
<li>The <dfn data-x-href="">EnumerableOwnProperties</dfn> abstract operation</li>
<li>The <dfn data-x="js-FunctionCreate" data-x-href="">FunctionCreate</dfn> abstract operation</li>
<li>The <dfn data-x="js-Get" data-x-href="">Get</dfn> abstract operation</li>
<li>The <dfn data-x-href="">GetActiveScriptOrModule</dfn> abstract operation</li>
<li>The <dfn data-x-href="">GetFunctionRealm</dfn> abstract operation</li>
<li>The <dfn data-x-href="">HasOwnProperty</dfn> abstract operation</li>
<li>The <dfn data-x="js-HostEnsureCanCompileStrings" data-x-href="">HostEnsureCanCompileStrings</dfn> abstract operation</li>
@@ -3056,6 +3057,7 @@ a.setAttribute('href', ''); // change the content attribute
<li>The <dfn data-x-href=""><code>SharedArrayBuffer</code></dfn> class</li>
<li>The <dfn data-x-href=""><code>TypeError</code></dfn> class</li>
<li>The <dfn data-x="js-RangeError" data-x-href=""><code>RangeError</code></dfn> class</li>
<li>The <dfn data-x-href=""><code>eval()</code></dfn> function</li>
<li>The <dfn data-x-href="">[[IsHTMLDDA]]</dfn> internal slot</li>
<li>The <dfn data-x="js-typeof" data-x-href=""><code>typeof</code></dfn> operator</li>
<li><dfn data-x-href="">The <var>TypedArray</var> Constructors</dfn> table</li>
@@ -86195,6 +86197,16 @@ interface <dfn>NavigatorOnLine</dfn> {
data-x="concept-script">script</span>. It has no additional <span data-x="struct
<p>The <dfn>active script</dfn> is determined by the following algorithm:</p>
<li><p>Let <var>record</var> be <span>GetActiveScriptOrModule</span>().</p></li>
<li><p>If <var>record</var> is null, return null.</p></li>
<li><p>Return <var>record</var>.[[HostDefined]].</p></li>
<p>An <dfn data-export="">environment</dfn> is an object that identifies the settings of a
@@ -87942,6 +87954,17 @@ document.querySelector("button").addEventListener("click", bound);
<li><p>Let <var>incumbent settings</var> be the <span>incumbent settings object</span>.</p></li>
<li><p>Let <var>active script</var> be the <span>active script</span>.</p></li>
<li><p>Assert: <var>active script</var> is not null, as jobs are only enqueued by the JavaScript
specification while a script is active.</p></li>
<li><p>Let <var>script execution context</var> be a new <span>JavaScript execution
context</span>, with its Function field set to null, its Realm field set to <var>active
script</var>'s <span>settings object</span>'s <span data-x="environment settings object's
Realm">Realm</span>, and its ScriptOrModule set to <var>active script</var>'s <span
<p><span>Queue a microtask</span>, on <var>job settings</var>'s <span>responsible event
loop</span>, to perform the following steps:</p>
@@ -87950,13 +87973,36 @@ document.querySelector("button").addEventListener("click", bound);
<li><p><span>Check if we can run script</span> with <var>job settings</var>. If this returns
"do not run" then return.</p></li>
<li><p><span>Prepare to run script</span> with <var>job settings</var>.</p></li>
<p><span>Prepare to run script</span> with <var>job settings</var>.</p>
<p class="note">This affects the <span data-x="concept-entry-everything">entry</span> concept
while the job runs.</p>
<p><span>Prepare to run a callback</span> with <var>incumbent settings</var>.</p>
<li><p><span>Prepare to run a callback</span> with <var>incumbent settings</var>.</p></li>
<p class="note">This affects the <span data-x="concept-incumbent-everything">incumbent</span>
concept while the job runs.</p>
<p><span data-x="stack push">Push</span> <var>script execution context</var> onto the
<span>JavaScript execution context stack</span>.</p>
<p class="note">This affects the <span>active script</span> while the job runs, in cases like
<code data-x="">Promise.resolve("...").then(eval)</code> where there would otherwise be no
active script since <code>eval()</code> is a built-in function that does not originate from
any particular <span data-x="concept-script">script</span>.</p>
<li><p>Let <var>result</var> be the result of performing the abstract operation specified by
<var>job</var>, using the elements of <var>arguments</var> as its arguments.</p></li>
<li><p><span data-x="stack pop">Pop</span> <var>script execution context</var> from the
<span>JavaScript execution context stack</span>.</p></li>
<li><p><span>Clean up after running a callback</span> with <var>incumbent

0 comments on commit cc3fcc8

Please sign in to comment.