Skip to content

Commit

Permalink
Always fire popstate and restore persisted state sync
Browse files Browse the repository at this point in the history
Closes #1792 by aligning with Gecko. The alternative model involved delaying popstate until after the load event, which is what WebKit and Blink do. But the Gecko model is simpler, more deterministic (since the load event depends on network timing), and has fewer edge cases around multiple consecutive state changes.
  • Loading branch information
domenic authored Apr 27, 2022
1 parent 60a9ea1 commit 3db5bb0
Showing 1 changed file with 19 additions and 27 deletions.
46 changes: 19 additions & 27 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -90415,9 +90415,8 @@ new PaymentRequest(…); // Allowed to use
mode</span>.</p></li>

<li><p><span>Traverse the history</span> to the new entry, with <var
data-x="traverse-history-hh">historyHandling</var> set to <var>historyHandling</var> and with
<var><span>nonBlockingEvents</span></var> set to true. This will <span>scroll to the
fragment</span> given in what is now the document's <span
data-x="traverse-history-hh">historyHandling</var> set to <var>historyHandling</var>. This will
<span>scroll to the fragment</span> given in what is now the document's <span
data-x="concept-document-url">URL</span>.</p></li>

<li><p><p>Invoke <span>WebDriver BiDi fragment navigated</span> with <var>browsingContext</var>,
Expand Down Expand Up @@ -90559,9 +90558,8 @@ new PaymentRequest(&hellip;); // Allowed to use
<p>To <dfn>traverse the history</dfn> to a <span>session history entry</span> <var>entry</var>,
with an optional <span>history handling behavior</span> <dfn
data-x="traverse-history-hh"><var>historyHandling</var></dfn> (default "<code
data-x="hh-default">default</code>"), an optional boolean <dfn><var>nonBlockingEvents</var></dfn>
(default false), and an optional boolean <dfn><var>explicitHistoryNavigation</var></dfn> (default
false):</p>
data-x="hh-default">default</code>"), and an optional boolean
<dfn><var>explicitHistoryNavigation</var></dfn> (default false):</p>

<p class="note">This algorithm is not just invoked when <span data-x="traverse the history by a
delta">explicitly going back or forwards in the session history</span> &mdash; it is also invoked
Expand Down Expand Up @@ -90773,28 +90771,22 @@ new PaymentRequest(&hellip;); // Allowed to use

<li><p>Set <var>newDocument</var>'s <span>latest entry</span> to <var>entry</var>.</p></li>

<li>
<p>If <var>nonBlockingEvents</var> is false, then run the following steps
<span>immediately</span>. Otherwise, <span>queue a global task</span> on the <span>DOM
manipulation task source</span> given <var>newDocument</var>'s <span>relevant global
object</span> to run the following steps instead.</p>
<li><p>If <var>stateChanged</var> is true, then <span data-x="concept-event-fire">fire an
event</span> named <code data-x="event-popstate">popstate</code> at <var>newDocument</var>'s
<span>relevant global object</span>, using <code>PopStateEvent</code>, with the <code
data-x="dom-PopStateEvent-state">state</code> attribute initialized to
<var>state</var>.</p></li>

<ol>
<li><p>If <var>stateChanged</var> is true, then <span data-x="concept-event-fire">fire an
event</span> named <code data-x="event-popstate">popstate</code> at <var>newDocument</var>'s
<span>relevant global object</span>, using <code>PopStateEvent</code>, with the <code
data-x="dom-PopStateEvent-state">state</code> attribute initialized to <var>state</var>.</p></li>

<li><p><span>Restore persisted state</span> from <var>entry</var>.</p></li>

<li><p>If <var>hashChanged</var> is true, then <span data-x="concept-event-fire">fire an
event</span> named <code data-x="event-hashchange">hashchange</code> at the <span>browsing
context</span>'s <span>active window</span>, using <code>HashChangeEvent</code>, with the <code
data-x="dom-HashChangeEvent-oldURL">oldURL</code> attribute initialized to <var>oldURL</var>
and the <code data-x="dom-HashChangeEvent-newURL">newURL</code> attribute initialized to
<var>newURL</var>.</p></li>
</ol>
</li>
<li><p><span>Restore persisted state</span> from <var>entry</var>.</p></li>

<li><p>If <var>hashChanged</var> is true, then <span>queue a global task</span> on the <span>DOM
manipulation task source</span> given <var>newDocument</var>'s <span>relevant global
object</span> to <span data-x="concept-event-fire">fire an event</span> named <code
data-x="event-hashchange">hashchange</code> at <var>newDocument</var>'s <span>relevant global
object</span>, using <code>HashChangeEvent</code>, with the <code
data-x="dom-HashChangeEvent-oldURL">oldURL</code> attribute initialized to <var>oldURL</var> and
the <code data-x="dom-HashChangeEvent-newURL">newURL</code> attribute initialized to
<var>newURL</var>.</p></li>
</ol>


Expand Down

0 comments on commit 3db5bb0

Please sign in to comment.