Skip to content

Commit 380763b

Browse files
committed
Fix the entry settings object for promise callbacks
Closes #1426.
1 parent fdbd2bd commit 380763b

File tree

1 file changed

+34
-13
lines changed

1 file changed

+34
-13
lines changed

source

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3008,6 +3008,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
30083008
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-objectcreate">ObjectCreate</dfn> abstract operation</li>
30093009
<li>The <dfn data-x="js-ParseModule" data-x-href="https://tc39.es/ecma262/#sec-parsemodule">ParseModule</dfn> abstract operation</li>
30103010
<li>The <dfn data-x="js-ParseScript" data-x-href="https://tc39.es/ecma262/#sec-parse-script">ParseScript</dfn> abstract operation</li>
3011+
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-promisereactionjob">PromiseReactionJob</dfn> abstract operation</li>
3012+
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-promiseresolvethenablejob">PromiseResolveThenableJob</dfn> abstract operation</li>
30113013
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-regexpbuiltinexec">RegExpBuiltinExec</dfn> abstract operation</li>
30123014
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-regexpcreate">RegExpCreate</dfn> abstract operation</li>
30133015
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-runjobs">RunJobs</dfn> abstract operation</li>
@@ -91021,15 +91023,32 @@ document.querySelector("button").addEventListener("click", bound);
9102191023
<li><p>Assert: <var>queueName</var> is <code data-x="">"PromiseJobs"</code>. (<code
9102291024
data-x="">"ScriptJobs"</code> must not be used by user agents.)</p></li>
9102391025

91026+
<li><p>Assert: <var>job</var> is either <span>PromiseResolveThenableJob</span> or
91027+
<span>PromiseReactionJob</span>. (The following steps would need to be updated if another type of
91028+
promise job were introduced.)</p></li>
91029+
9102491030
<li>
91025-
<p>Let <var>job settings</var> be some appropriate <span>environment settings object</span>.</p>
91031+
<p>Let <var>job settings</var> be determined by switching on <var>job</var>:</p>
91032+
91033+
<dl class="switch">
91034+
<dt><span>PromiseResolveThenableJob</span></dt>
91035+
<dd>
91036+
<p>The <span data-x="concept-realm-settings-object">settings object</span> for
91037+
<var>arguments</var>[2].[[Realm]]. (I.e., the <span data-x="JavaScript realm">Realm</span> of
91038+
the <code data-x="">then</code> function.)</p>
91039+
</dd>
9102691040

91027-
<p class="warning">It is not yet clear how to specify the <span>environment settings
91028-
object</span> that should be used here. In practice, this means that the <span
91029-
data-x="concept-entry-everything">entry</span> concept is not correctly specified while
91030-
executing a job. See <a
91031-
href="https://github.com/whatwg/html/pull/1189#issuecomment-224950188">discussion in issue
91032-
#1189</a>.</p>
91041+
<dt><span>PromiseReactionJob</span></dt>
91042+
<dd>
91043+
<p>If <var>arguments</var>[0].[[Handler]] is not undefined, then the <span
91044+
data-x="concept-realm-settings-object">settings object</span> of
91045+
<var>arguments</var>[0].[[Handler]].[[Realm]]; otherwise, null.</p>
91046+
91047+
<p class="note">If the handler is undefined, then we are in a case like <code
91048+
data-x="">promise.then(null, null)</code>. In this case, no author code will run, so all of
91049+
the steps below that would otherwise use <var>job settings</var> get skipped.</p>
91050+
</dd>
91051+
</dl>
9103391052
</li>
9103491053

9103591054
<li><p>Let <var>incumbent settings</var> be the <span>incumbent settings object</span>.</p></li>
@@ -91084,15 +91103,16 @@ document.querySelector("button").addEventListener("click", bound);
9108491103
</li>
9108591104

9108691105
<li>
91087-
<p><span>Queue a microtask</span>, on <var>job settings</var>'s <span>responsible event
91088-
loop</span>, to perform the following steps:</p>
91106+
<p><span>Queue a microtask</span> on the <span>surrounding agent</span>'s <span>event
91107+
loop</span> to perform the following steps:</p>
9108991108

9109091109
<ol>
91091-
<li><p><span>Check if we can run script</span> with <var>job settings</var>. If this returns
91092-
"do not run" then return.</p></li>
91110+
<li><p>If <var>job settings</var> is not null, then <span>check if we can run script</span>
91111+
with <var>job settings</var>. If this returns "do not run" then return.</p></li>
9109391112

9109491113
<li>
91095-
<p><span>Prepare to run script</span> with <var>job settings</var>.</p>
91114+
<p>If <var>job settings</var> is not null, then <span>prepare to run script</span> with
91115+
<var>job settings</var>.</p>
9109691116

9109791117
<p class="note">This affects the <span data-x="concept-entry-everything">entry</span> concept
9109891118
while the job runs.</p>
@@ -91124,7 +91144,8 @@ document.querySelector("button").addEventListener("click", bound);
9112491144
<li><p><span>Clean up after running a callback</span> with <var>incumbent
9112591145
settings</var>.</p></li>
9112691146

91127-
<li><p><span>Clean up after running script</span> with <var>job settings</var>.</p></li>
91147+
<li><p>If <var>job settings</var> is not null, then <span>clean up after running script</span>
91148+
with <var>job settings</var>.</p></li>
9112891149

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

0 commit comments

Comments
 (0)