Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the entry settings object for promise callbacks #5212

Merged
merged 1 commit into from
Feb 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 34 additions & 13 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -3008,6 +3008,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-promisereactionjob">PromiseReactionJob</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-regexpbuiltinexec">RegExpBuiltinExec</dfn> abstract operation</li>
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-regexpcreate">RegExpCreate</dfn> abstract operation</li>
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-runjobs">RunJobs</dfn> abstract operation</li>
Expand Down Expand Up @@ -91021,15 +91023,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 @@ -91084,15 +91103,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 @@ -91124,7 +91144,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