Skip to content

Commit 93634ae

Browse files
authored
Navigation API: fix an ordering issue
Because navigatesuccess/navigateerror events can run JavaScript code, they can change the "ongoing API method tracker" pointer. Thus, it's better to resolve/reject the finished promise for the API method tracker before firing the event. This does not change the observable order in normal cases: it remains the case that JavaScript event handlers for navigatesuccess/navigateerror run before promise reactions, because promise resolution is always delayed by a microtask. However, it fixes some tricky reentrant cases, which would otherwise cause spec assertion fails.
1 parent e9ccb97 commit 93634ae

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

source

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96401,15 +96401,15 @@ const p2 = navigation.navigate(url2).finished;</code></pre>
9640196401
0.</p>
9640296402
</li>
9640396403

96404+
<li><p>If <var>navigation</var>'s <span>ongoing API method tracker</span> is non-null, then
96405+
<span>reject the finished promise</span> for <var>apiMethodTracker</var> with
96406+
<var>error</var>.</p></li>
96407+
9640496408
<li><p><span data-x="concept-event-fire">Fire an event</span> named <code
9640596409
data-x="event-navigateerror">navigateerror</code> at <var>navigation</var> using
9640696410
<code>ErrorEvent</code>, with additional attributes initialized according to
9640796411
<var>errorInfo</var>.</p></li>
9640896412

96409-
<li><p>If <var>navigation</var>'s <span>ongoing API method tracker</span> is non-null, then
96410-
<span>reject the finished promise</span> for <var>apiMethodTracker</var> with
96411-
<var>error</var>.</p></li>
96412-
9641396413
<li>
9641496414
<p>If <var>navigation</var>'s <span data-x="concept-Navigation-transition">transition</span> is
9641596415
not null, then:</p>
@@ -97265,7 +97265,7 @@ interface <dfn interface>NavigationDestination</dfn> {
9726597265
</ol>
9726697266

9726797267
<div class="note">
97268-
<p>If there is an ongoing cross-document navigation, this means it will signaled to the
97268+
<p>If there is an ongoing cross-document navigation, this means it will be signaled to the
9726997269
navigation API as aborted, e.g., by firing <code
9727097270
data-x="event-navigateerror">navigateerror</code> events. This is somewhat accurate, since
9727197271
the next navigation the <code>Document</code> experiences will be this same-document
@@ -97743,12 +97743,12 @@ interface <dfn interface>NavigationDestination</dfn> {
9774397743
<li><p><span data-x="NavigateEvent-finish">Finish</span> <var>event</var> given
9774497744
true.</p></li>
9774597745

97746-
<li><p><span data-x="concept-event-fire">Fire an event</span> named <code
97747-
data-x="event-navigatesuccess">navigatesuccess</code> at <var>navigation</var>.</p></li>
97748-
9774997746
<li><p>If <var>apiMethodTracker</var> is non-null, then <span>resolve the finished
9775097747
promise</span> for <var>apiMethodTracker</var>.</p></li>
9775197748

97749+
<li><p><span data-x="concept-event-fire">Fire an event</span> named <code
97750+
data-x="event-navigatesuccess">navigatesuccess</code> at <var>navigation</var>.</p></li>
97751+
9775297752
<li><p>If <var>navigation</var>'s <span
9775397753
data-x="concept-Navigation-transition">transition</span> is not null, then resolve
9775497754
<var>navigation</var>'s <span data-x="concept-Navigation-transition">transition</span>'s
@@ -97782,14 +97782,14 @@ interface <dfn interface>NavigationDestination</dfn> {
9778297782
<li><p>Let <var>errorInfo</var> be the result of <span data-x="extract-error">extracting error
9778397783
information</span> from <var>rejectionReason</var>.</p></li>
9778497784

97785+
<li><p>If <var>apiMethodTracker</var> is non-null, then <span>reject the finished
97786+
promise</span> for <var>apiMethodTracker</var> with <var>rejectionReason</var>.</p></li>
97787+
9778597788
<li><p><span data-x="concept-event-fire">Fire an event</span> named <code
9778697789
data-x="event-navigateerror">navigateerror</code> at <var>navigation</var> using
9778797790
<code>ErrorEvent</code>, with additional attributes initialized according to
9778897791
<var>errorInfo</var>.</p></li>
9778997792

97790-
<li><p>If <var>apiMethodTracker</var> is non-null, then <span>reject the finished
97791-
promise</span> for <var>apiMethodTracker</var> with <var>rejectionReason</var>.</p></li>
97792-
9779397793
<li><p>If <var>navigation</var>'s <span
9779497794
data-x="concept-Navigation-transition">transition</span> is not null, then reject
9779597795
<var>navigation</var>'s <span data-x="concept-Navigation-transition">transition</span>'s

0 commit comments

Comments
 (0)