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 same-URL navigation session history handling #6476

Merged
merged 1 commit into from
Mar 12, 2021
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
107 changes: 51 additions & 56 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -84549,6 +84549,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 @@ -85531,9 +85540,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 @@ -85544,28 +85558,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 @@ -85574,63 +85589,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