Skip to content

Commit

Permalink
Fix the entry settings object for promise callbacks
Browse files Browse the repository at this point in the history
Closes #1426.
  • Loading branch information
domenic committed Jan 15, 2020
1 parent f9708d6 commit 325bff9
Showing 1 changed file with 34 additions and 13 deletions.
47 changes: 34 additions & 13 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -3098,6 +3098,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-objectcreate">ObjectCreate</dfn> abstract operation</li>
<li>The <dfn data-x="js-ParseModule" data-x-href="https://tc39.es/ecma262/#sec-parsemodule">ParseModule</dfn> abstract operation</li>
<li>The <dfn data-x="js-ParseScript" data-x-href="https://tc39.es/ecma262/#sec-parse-script">ParseScript</dfn> abstract operation</li>
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-promiseresolvethenablejob">PromiseResolveThenableJob</dfn> abstract operation</li>
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-promisereactionjob">PromiseReactionJob</dfn> abstract operation</li>
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-runjobs">RunJobs</dfn> abstract operation</li>
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-samevalue">SameValue</dfn> abstract operation</li>
<li>The <dfn data-x="js-ScriptEvaluation" data-x-href="https://tc39.es/ecma262/#sec-runtime-semantics-scriptevaluation">ScriptEvaluation</dfn> abstract operation</li>
Expand Down Expand Up @@ -90968,15 +90970,32 @@ document.querySelector("button").addEventListener("click", bound);
<li><p>Assert: <var>queueName</var> is <code data-x="">"PromiseJobs"</code>. (<code
data-x="">"ScriptJobs"</code> must not be used by user agents.)</p></li>

<li><p>Assert: <var>job</var> is either <span>PromiseResolveThenableJob</span> or
<span>PromiseReactionJob</span>. (The following steps would need to be updated if another type of
promise job were introduced.)</p></li>

<li>
<p>Let <var>job settings</var> be some appropriate <span>environment settings object</span>.</p>
<p>Let <var>job settings</var> be determined by switching on <var>job</var>:</p>

<dl class="switch">
<dt><span>PromiseResolveThenableJob</span></dt>
<dd>
<p>The <span data-x="concept-realm-settings-object">settings object</span> for
<var>arguments</var>[2].[[Realm]]. (I.e., the <span data-x="JavaScript realm">Realm</span> of
the <code data-x="">then</code> function.)</p>
</dd>

<p class="warning">It is not yet clear how to specify the <span>environment settings
object</span> that should be used here. In practice, this means that the <span
data-x="concept-entry-everything">entry</span> concept is not correctly specified while
executing a job. See <a
href="https://github.com/whatwg/html/pull/1189#issuecomment-224950188">discussion in issue
#1189</a>.</p>
<dt><span>PromiseReactionJob</span></dt>
<dd>
<p>If <var>arguments</var>[0].[[Handler]] is not undefined, then the <span
data-x="concept-realm-settings-object">settings object</span> of
<var>arguments</var>[0].[[Handler]].[[Realm]]; otherwise, null.</p>

<p class="note">If the handler is undefined, then we are in a case like <code
data-x="">promise.then(null, null)</code>. In this case, no author code will run, so all of
the steps below that would otherwise use <var>job settings</var> get skipped.</p>
</dd>
</dl>
</li>

<li><p>Let <var>incumbent settings</var> be the <span>incumbent settings object</span>.</p></li>
Expand Down Expand Up @@ -91031,15 +91050,16 @@ document.querySelector("button").addEventListener("click", bound);
</li>

<li>
<p><span>Queue a microtask</span>, on <var>job settings</var>'s <span>responsible event
loop</span>, to perform the following steps:</p>
<p><span>Queue a microtask</span> on the <span>surrounding agent</span>'s <span>event
loop</span> to perform the following steps:</p>

<ol>
<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>If <var>job settings</var> is not null, then <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>
<p>If <var>job settings</var> is not null, then <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>
Expand Down Expand Up @@ -91071,7 +91091,8 @@ document.querySelector("button").addEventListener("click", bound);
<li><p><span>Clean up after running a callback</span> with <var>incumbent
settings</var>.</p></li>

<li><p><span>Clean up after running script</span> with <var>job settings</var>.</p></li>
<li><p>If <var>job settings</var> is not null, then <span>clean up after running script</span>
with <var>job settings</var>.</p></li>

<li><p>If <var>result</var> is an <span>abrupt completion</span>, then <span>report the
exception</span> given by <var>result</var>.[[Value]].</p></li>
Expand Down

0 comments on commit 325bff9

Please sign in to comment.