Skip to content

Commit 2062a68

Browse files
committed
Fix same-URL navigation session history handling
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.
1 parent d26cee5 commit 2062a68

File tree

1 file changed

+51
-56
lines changed

1 file changed

+51
-56
lines changed

source

Lines changed: 51 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -84575,6 +84575,15 @@ interface <dfn>Location</dfn> { // but see also <a href="#the-location-interface
8457584575
</ol>
8457684576
</li>
8457784577

84578+
<li><p>If <var>historyHandling</var> is "<code data-x="hh-default">default</code>",
84579+
<var>resource</var> is a <span data-x="concept-request">request</span>, and either
84580+
<var>resource</var>'s <span data-x="concept-request-url">url</span> <span
84581+
data-x="concept-url-equals">equals</span> <var>browsingContext</var>'s <span>active
84582+
document</span>'s <span data-x="concept-document-url">URL</span> or <var>resource</var>'s <span
84583+
data-x="concept-request-url">url</span>'s <span data-x="concept-url-scheme">scheme</span> is
84584+
"<code data-x="javascript protocol">javascript</code>"', then set <var>historyHandling</var> to
84585+
"<code data-x="hh-replace">replace</code>".</li>
84586+
8457884587
<li><p>Let <var>activeDocumentNavigationOrigin</var> be the <span
8457984588
data-x="concept-document-origin">origin</span> of the <span>active document</span> of
8458084589
<var>browsingContext</var>.</p></li>
@@ -85557,9 +85566,14 @@ new PaymentRequest(&hellip;); // Allowed to use
8555785566
following steps:</p>
8555885567

8555985568
<ol>
85569+
<li><p>Let <var>sessionHistory</var> be <var>navigationParams</var>'s <span
85570+
data-x="navigation-params-browsing-context">browsing context</span>'s <span>session
85571+
history</span>.</p></li>
85572+
8556085573
<li>
85561-
<p><span data-x="unload a document">Unload</span> the <span
85562-
data-x="she-document">document</span> of the <span>current entry</span>.</p>
85574+
<p><span data-x="unload a document">Unload</span> <var>sessionHistory</var>'s <span>current
85575+
entry</span>'s <span
85576+
data-x="she-document">document</span>.</p>
8556385577

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

8557285586
<li>
85573-
<dl>
85574-
<dt>If <var>navigationParams</var>'s <span data-x="navigation-params-hh">history
85575-
handling</span> is "<code data-x="hh-entry-update">entry update</code>" or "<code
85576-
data-x="hh-reload">reload</code>"</dt>
85577-
85587+
<p>Switch on <var>navigationParams</var>'s <span data-x="navigation-params-hh">history
85588+
handling</span>:</p>
85589+
<dl class="switch">
85590+
<dt>"<code data-x="hh-entry-update">entry update</code>"</dt>
85591+
<dt>"<code data-x="hh-reload">reload</code>"</dt>
8557885592
<dd>
8557985593
<ol>
85580-
<li><p>Replace the <span data-x="she-document">document</span> of the <span>current
85581-
entry</span>, and of any other entries that reference the same <span
85582-
data-x="she-document">document</span> as that entry, with <var>newDocument</var>.</p></li>
85583-
85584-
<li><p><span>Traverse the history</span> to the <span>current entry</span> with <var
85585-
data-x="traverse-history-hh">historyHandling</var> set to <var>navigationParams</var>'s <span
85586-
data-x="navigation-params-hh">history handling</span>.</p></li>
85594+
<li><p>Let <var>oldDocument</var> be <var>sessionHistory</var>'s <span>current entry</span>'s
85595+
<span data-x="she-document">document</span>.</p></li>
85596+
85597+
<li><p><span data-x="list iterate">For each</span> <var>entry</var> of
85598+
<var>sessionHistory</var>: if <var>entry</var>'s <span data-x="she-document">document</span>
85599+
is <var>oldDocument</var>, then set <var>entry</var>'s <span
85600+
data-x="she-document">document</span> to <var>newDocument</var>.</p></li>
85601+
85602+
<li><p><span>Traverse the history</span> to <var>sessionHistory</var>'s <span>current
85603+
entry</span> with <var data-x="traverse-history-hh">historyHandling</var> set to
85604+
<var>navigationParams</var>'s <span data-x="navigation-params-hh">history
85605+
handling</span>.</p></li>
8558785606
</ol>
8558885607
</dd>
8558985608

85590-
<dt>Otherwise, if the navigation was initiated with a <span>URL</span> that <span
85591-
data-x="concept-url-equals">equals</span> <var>navigationParams</var>'s <span
85592-
data-x="navigation-params-browsing-context">browsing context</span>'s <span>active
85593-
document</span>'s <span data-x="concept-document-url">URL</span></dt>
85594-
85609+
<dt>"<code data-x="hh-replace">replace</code>"</dt>
8559585610
<dd>
8559685611
<ol>
8559785612
<li>
@@ -85600,63 +85615,43 @@ new PaymentRequest(&hellip;); // Allowed to use
8560085615
data-x="concept-document-url">URL</span> and <span data-x="she-document">document</span> is
8560185616
<var>newDocument</var>.</p>
8560285617

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

85608-
<li><p>Insert <var>newEntry</var> after the <span>current entry</span> in
85609-
<var>navigationParams</var>'s <span data-x="navigation-params-browsing-context">browsing
85610-
context</span>'s <span>session history</span>.</p></li>
85611-
85612-
<li><p><span>Traverse the history</span> to <var>newEntry</var> with <var
85613-
data-x="traverse-history-hh">historyHandling</var> set to "<code
85614-
data-x="hh-replace">replace</code>".</p></li>
85615-
</ol>
85616-
</dd>
85617-
85618-
<dt>Otherwise, if <var>navigationParams</var>'s <span data-x="navigation-params-hh">history
85619-
handling</span> is "<code data-x="hh-replace">replace</code>"</dt>
85620-
85621-
<dd>
85622-
<ol>
85623-
<li><p>Let <var>newEntry</var> be a new <span>session history entry</span> whose <span
85624-
data-x="she-url">URL</span> is <var>newDocument</var>'s <span
85625-
data-x="concept-document-url">URL</span> and <span data-x="she-document">document</span> is
85626-
<var>newDocument</var>.</p></li>
85627-
85628-
<li><p>Insert <var>newEntry</var> after the <span>current entry</span> in
85629-
<var>navigationParams</var>'s <span data-x="navigation-params-browsing-context">browsing
85630-
context</span>'s <span>session history</span>.</p></li>
85625+
<li><p>Insert <var>newEntry</var> into <var>sessionHistory</var> after its <span>current
85626+
entry</span>.</p></li>
8563185627

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

85638-
<dt>Otherwise</dt>
85639-
85634+
<dt>"<code data-x="hh-default">default</code>"</dt>
8564085635
<dd>
8564185636
<ol>
85642-
<li><p>Assert: <var>navigationParams</var>'s <span data-x="navigation-params-hh">history
85643-
handling</span> is "<code data-x="hh-default">default</code>".</p></li>
85644-
8564585637
<li>
85646-
<p>Remove all the entries in the <span>session history</span> after the <span>current
85647-
entry</span>. If the <span>current entry</span> is the last entry in the session history,
85648-
then no entries are removed.</p>
85638+
<p>Remove all the entries in <var>sessionHistory</var> after its <span>current entry</span>.
85639+
(If the <span>current entry</span> is the last entry in the session history, then no entries
85640+
are removed.)</p>
8564985641

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

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

85659-
<li><p><span>Traverse the history</span> to the new entry.</p></li>
85651+
<li><p><span data-x="list append">Append</span> <var>newEntry</var> to
85652+
<var>sessionHistory</var>.</p></li>
85653+
85654+
<li><p><span>Traverse the history</span> to <var>newEntry</var>.</p></li>
8566085655
</ol>
8566185656
</dd>
8566285657
</dl>

0 commit comments

Comments
 (0)