Skip to content

Commit

Permalink
Fix same-URL navigation session history handling
Browse files Browse the repository at this point in the history
Closes #6202. Also tidies up the "update the session history with the new page" algorithm more generally, e.g. to be explicit about what session history is being accessed.
  • Loading branch information
domenic committed Mar 12, 2021
1 parent d26cee5 commit 2062a68
Showing 1 changed file with 51 additions and 56 deletions.
107 changes: 51 additions & 56 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -84575,6 +84575,15 @@ interface <dfn>Location</dfn> { // but see also <a href="#the-location-interface
</ol>
</li>

<li><p>If <var>historyHandling</var> is "<code data-x="hh-default">default</code>",
<var>resource</var> is a <span data-x="concept-request">request</span>, and either
<var>resource</var>'s <span data-x="concept-request-url">url</span> <span
data-x="concept-url-equals">equals</span> <var>browsingContext</var>'s <span>active
document</span>'s <span data-x="concept-document-url">URL</span> or <var>resource</var>'s <span
data-x="concept-request-url">url</span>'s <span data-x="concept-url-scheme">scheme</span> is
"<code data-x="javascript protocol">javascript</code>"', then set <var>historyHandling</var> to
"<code data-x="hh-replace">replace</code>".</li>

<li><p>Let <var>activeDocumentNavigationOrigin</var> be the <span
data-x="concept-document-origin">origin</span> of the <span>active document</span> of
<var>browsingContext</var>.</p></li>
Expand Down Expand Up @@ -85557,9 +85566,14 @@ new PaymentRequest(&hellip;); // Allowed to use
following steps:</p>

<ol>
<li><p>Let <var>sessionHistory</var> be <var>navigationParams</var>'s <span
data-x="navigation-params-browsing-context">browsing context</span>'s <span>session
history</span>.</p></li>

<li>
<p><span data-x="unload a document">Unload</span> the <span
data-x="she-document">document</span> of the <span>current entry</span>.</p>
<p><span data-x="unload a document">Unload</span> <var>sessionHistory</var>'s <span>current
entry</span>'s <span
data-x="she-document">document</span>.</p>

<p>If this instance of the <span data-x="navigate">navigation</span> algorithm is canceled while
this step is running the <span>unload a document</span> algorithm, then the <span>unload a
Expand All @@ -85570,28 +85584,29 @@ new PaymentRequest(&hellip;); // Allowed to use
</li>

<li>
<dl>
<dt>If <var>navigationParams</var>'s <span data-x="navigation-params-hh">history
handling</span> is "<code data-x="hh-entry-update">entry update</code>" or "<code
data-x="hh-reload">reload</code>"</dt>

<p>Switch on <var>navigationParams</var>'s <span data-x="navigation-params-hh">history
handling</span>:</p>
<dl class="switch">
<dt>"<code data-x="hh-entry-update">entry update</code>"</dt>
<dt>"<code data-x="hh-reload">reload</code>"</dt>
<dd>
<ol>
<li><p>Replace the <span data-x="she-document">document</span> of the <span>current
entry</span>, and of any other entries that reference the same <span
data-x="she-document">document</span> as that entry, with <var>newDocument</var>.</p></li>

<li><p><span>Traverse the history</span> to the <span>current entry</span> with <var
data-x="traverse-history-hh">historyHandling</var> set to <var>navigationParams</var>'s <span
data-x="navigation-params-hh">history handling</span>.</p></li>
<li><p>Let <var>oldDocument</var> be <var>sessionHistory</var>'s <span>current entry</span>'s
<span data-x="she-document">document</span>.</p></li>

<li><p><span data-x="list iterate">For each</span> <var>entry</var> of
<var>sessionHistory</var>: if <var>entry</var>'s <span data-x="she-document">document</span>
is <var>oldDocument</var>, then set <var>entry</var>'s <span
data-x="she-document">document</span> to <var>newDocument</var>.</p></li>

<li><p><span>Traverse the history</span> to <var>sessionHistory</var>'s <span>current
entry</span> with <var data-x="traverse-history-hh">historyHandling</var> set to
<var>navigationParams</var>'s <span data-x="navigation-params-hh">history
handling</span>.</p></li>
</ol>
</dd>

<dt>Otherwise, if the navigation was initiated with a <span>URL</span> that <span
data-x="concept-url-equals">equals</span> <var>navigationParams</var>'s <span
data-x="navigation-params-browsing-context">browsing context</span>'s <span>active
document</span>'s <span data-x="concept-document-url">URL</span></dt>

<dt>"<code data-x="hh-replace">replace</code>"</dt>
<dd>
<ol>
<li>
Expand All @@ -85600,63 +85615,43 @@ new PaymentRequest(&hellip;); // Allowed to use
data-x="concept-document-url">URL</span> and <span data-x="she-document">document</span> is
<var>newDocument</var>.</p>

<p class="XXX">Some browsers copy over the serialized state of <span>current entry</span>,
but this is inconsistent. See <a href="https://github.com/whatwg/html/issues/6213">issue
#6213</a> for more discussion on this.</p>
<p class="XXX">Some browsers copy over the serialized state <var>sessionHistory</var>'s
<span>current entry</span> in cases where its <span data-x="she-URL">URL</span> <span
data-x="concept-url-equals">equals</span> that of <var>newDocument</var>, but this is
inconsistent. See <a href="https://github.com/whatwg/html/issues/6213">issue #6213</a> for
more discussion on this.</p>
</li>

<li><p>Insert <var>newEntry</var> after the <span>current entry</span> in
<var>navigationParams</var>'s <span data-x="navigation-params-browsing-context">browsing
context</span>'s <span>session history</span>.</p></li>

<li><p><span>Traverse the history</span> to <var>newEntry</var> with <var
data-x="traverse-history-hh">historyHandling</var> set to "<code
data-x="hh-replace">replace</code>".</p></li>
</ol>
</dd>

<dt>Otherwise, if <var>navigationParams</var>'s <span data-x="navigation-params-hh">history
handling</span> is "<code data-x="hh-replace">replace</code>"</dt>

<dd>
<ol>
<li><p>Let <var>newEntry</var> be a new <span>session history entry</span> whose <span
data-x="she-url">URL</span> is <var>newDocument</var>'s <span
data-x="concept-document-url">URL</span> and <span data-x="she-document">document</span> is
<var>newDocument</var>.</p></li>

<li><p>Insert <var>newEntry</var> after the <span>current entry</span> in
<var>navigationParams</var>'s <span data-x="navigation-params-browsing-context">browsing
context</span>'s <span>session history</span>.</p></li>
<li><p>Insert <var>newEntry</var> into <var>sessionHistory</var> after its <span>current
entry</span>.</p></li>

<li><p><span>Traverse the history</span> to <var>newEntry</var> with
<var data-x="traverse-history-hh">historyHandling</var> set to "<code
data-x="hh-replace">replace</code>".</p></li>
</ol>
</dd>

<dt>Otherwise</dt>

<dt>"<code data-x="hh-default">default</code>"</dt>
<dd>
<ol>
<li><p>Assert: <var>navigationParams</var>'s <span data-x="navigation-params-hh">history
handling</span> is "<code data-x="hh-default">default</code>".</p></li>

<li>
<p>Remove all the entries in the <span>session history</span> after the <span>current
entry</span>. If the <span>current entry</span> is the last entry in the session history,
then no entries are removed.</p>
<p>Remove all the entries in <var>sessionHistory</var> after its <span>current entry</span>.
(If the <span>current entry</span> is the last entry in the session history, then no entries
are removed.)</p>

<p class="note">This <a href="#history-notes">doesn't necessarily have to affect</a> the
user agent's user interface.</p>
</li>

<li><p>Append a new <span>session history entry</span> to the <span>session history</span>,
whose <span data-x="she-url">URL</span> is <var>newDocument</var>'s <span
<li><p>Let <var>newEntry</var> be a new <span>session history entry</span> whose <span
data-x="she-url">URL</span> is <var>newDocument</var>'s <span
data-x="concept-document-url">URL</span> and <span data-x="she-document">document</span> is
<var>newDocument</var>.</p></li>

<li><p><span>Traverse the history</span> to the new entry.</p></li>
<li><p><span data-x="list append">Append</span> <var>newEntry</var> to
<var>sessionHistory</var>.</p></li>

<li><p><span>Traverse the history</span> to <var>newEntry</var>.</p></li>
</ol>
</dd>
</dl>
Expand Down

0 comments on commit 2062a68

Please sign in to comment.