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 updating the session history to activate new Documents #6199

Merged
merged 9 commits into from
Dec 11, 2020
103 changes: 73 additions & 30 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -84088,6 +84088,13 @@ interface <dfn>Location</dfn> { // but see also <a href="#the-location-interface
entry">current session history entry</span>.</dd>
</dl>

<p class="note">The values "<code data-x="hh-reload">reload</code>" and "<code
data-x="hh-replace">replace</code>" are nearly identical with two exceptions: "<code
data-x="hh-reload">reload</code>" is specifically used when we need to set a request's <span
data-x="concept-request-reload-navigation-flag">reload-navigation flag</span>, and to bypass the
<span data-x="navigate-fragid">Navigate to a fragment</span> algorithm in cases where it would
otherwise be triggered.</p>
domfarolino marked this conversation as resolved.
Show resolved Hide resolved

<p>Navigation always involves <dfn export>source browsing context</dfn>, which is the browsing
context which was responsible for starting the navigation.</p>

Expand Down Expand Up @@ -85127,16 +85134,13 @@ new PaymentRequest(&hellip;); // Allowed to use

<p>Some of the sections below, to which the above algorithm defers in certain cases, require the
user agent to <dfn>update the session history with the new page</dfn>, given some <span>navigation
params</span> <var>navigationParams</var>. When a user agent is required to do this, it must
<span>queue a global task</span> on the <span>networking task source</span>, given the
<span>relevant global object</span> of the <code>Document</code> object of the <span>current
entry</span> (not the new one), to run the following steps:</p>
params</span> <var>navigationParams</var> and a <code>Document</code> <var>newDocument</var>. When
a user agent is required to do this, it must <span>queue a global task</span> on the
<span>networking task source</span>, given the <span>relevant global object</span> of the
<code>Document</code> object of the <span>current entry</span> (not the new one), to run the
following steps:</p>

<ol>
<li><p>Let <var>newDocument</var> be <var>navigationParams</var>'s <span
data-x="navigation-params-browsing-context">browsing context</span>'s <span>active
document</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>
Expand All @@ -85152,38 +85156,75 @@ new PaymentRequest(&hellip;); // Allowed to use
<li>
<dl>
<dt>If <var>navigationParams</var>'s <span data-x="navigation-params-hh">history
handling</span> is "<code data-x="hh-reload">reload</code>" or "<code
data-x="hh-entry-update">entry update</code>"</dt>
handling</span> is "<code data-x="hh-entry-update">entry update</code>" or "<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 any other entries that reference the same <span
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>.</p></li>
<li><p><span>Traverse the history</span> to the <span>current entry</span> with
<span>sameEntryTraversal</span> set to true.</p></li>
domfarolino marked this conversation as resolved.
Show resolved Hide resolved
</ol>
</dd>

<dt>If the navigation was initiated with a <span>URL</span> that <span
domfarolino marked this conversation as resolved.
Show resolved Hide resolved
data-x="concept-url-equals">equals</span> <var>newDocument</var>'s <span
data-x="concept-document-url">URL</span></dt>
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>

<dd>
<ol>
<li><p>Replace the <span>current entry</span> with 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>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>

<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/6202">issue
#6202</a> for more discussion on this.</p>
domfarolino marked this conversation as resolved.
Show resolved Hide resolved
</li>

<li><p>Insert <var>newEntry</var> after <span>current entry</span> in
domfarolino marked this conversation as resolved.
Show resolved Hide resolved
<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 the <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>
domfarolino marked this conversation as resolved.
Show resolved Hide resolved
</ol>
</dd>

<dt>If <var>navigationParams</var>'s <span data-x="navigation-params-hh">history
domfarolino marked this conversation as resolved.
Show resolved Hide resolved
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 <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</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,
domfarolino marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -85273,7 +85314,8 @@ new PaymentRequest(&hellip;); // Allowed to use

<p>After creating the <code>Document</code> object, but before any script execution, certainly
before the parser <span data-x="stop parsing">stops</span>, the user agent must <span>update the
session history with the new page</span> given <var>navigationParams</var>.</p>
session history with the new page</span> given <var>navigationParams</var> and
<var>document</var>.</p>



Expand All @@ -85298,9 +85340,10 @@ new PaymentRequest(&hellip;); // Allowed to use
character encoding.</p>

<p>Then, with the newly created <code>Document</code>, the user agent must <span>update the
session history with the new page</span> given <var>navigationParams</var>. User agents may do
this before the complete document has been parsed (thus achieving <i>incremental rendering</i>),
and must do this before any scripts are to be executed.</p>
session history with the new page</span> given <var>navigationParams</var> and the newly-created
<code>Document</code>. User agents may do this before the complete document has been parsed (thus
achieving <i>incremental rendering</i>), and must do this before any scripts are to be
executed.</p>

<p>Error messages from the parse process (e.g., XML namespace well-formedness errors) may be
reported inline by mutating the <code>Document</code>.</p>
Expand Down Expand Up @@ -85347,7 +85390,7 @@ new PaymentRequest(&hellip;); // Allowed to use

<p>After creating the <code>Document</code> object, but potentially before the page has finished
parsing, the user agent must <span>update the session history with the new page</span> given
<var>navigationParams</var>.</p>
<var>navigationParams</var> and <var>document</var>.</p>
domfarolino marked this conversation as resolved.
Show resolved Hide resolved

<p>User agents may add content to the <code>head</code> element of the <code>Document</code>,
e.g., linking to a style sheet, providing script, or giving the document a <code>title</code>.</p>
Expand Down Expand Up @@ -85435,7 +85478,7 @@ new PaymentRequest(&hellip;); // Allowed to use

<p>After creating the <code>Document</code> object, but potentially before the page has finished
fully loading, the user agent must <span>update the session history with the new page</span> given
<var>navigationParams</var>.</p>
<var>navigationParams</var> and <var>document</var>.</p>

<p>User agents may add content to the <code>head</code> element of the <code>Document</code>, or
attributes to the element <var>host element</var>, e.g., to link to a style sheet, to provide a
Expand Down Expand Up @@ -85480,7 +85523,7 @@ new PaymentRequest(&hellip;); // Allowed to use

<p>After creating the <code>Document</code> object, but potentially before the page has finished
fully loading, the user agent must <span>update the session history with the new page</span> given
<var>navigationParams</var>.</p>
<var>navigationParams</var> and <var>document</var>.</p>

<p>User agents may add content to the <code>head</code> element of the <code>Document</code>, or
attributes to the <code>embed</code> element, e.g. to link to a style sheet or to give the
Expand Down Expand Up @@ -85536,7 +85579,7 @@ new PaymentRequest(&hellip;); // Allowed to use

<p>After creating the <code>Document</code> object, but potentially before the page has been
completely set up, the user agent must <span>update the session history with the new page</span>
given <var>navigationParams</var>.</p>
given <var>navigationParams</var> and <var>document</var>.</p>



Expand Down Expand Up @@ -85702,8 +85745,8 @@ new PaymentRequest(&hellip;); // Allowed to use
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>
(default false), an optional boolean <dfn><var>explicitHistoryNavigation</var></dfn> (default
false), and an optional boolean <dfn><var>sameEntryTraversal</var></dfn> (default false):</p>
domfarolino marked this conversation as resolved.
Show resolved Hide resolved

<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 @@ -85758,7 +85801,7 @@ new PaymentRequest(&hellip;); // Allowed to use
data-x="she-document">document</span>.</p></li>

<li><p>If <var>newDocument</var> is different than the <span>current entry</span>'s <span
data-x="she-document">document</span>, then:</p>
data-x="she-document">document</span> or <var>sameEntryTraversal</var> is true, then:</p>

<ol>
<li><p>Remove any <span data-x="concept-task">tasks</span> queued by the <span>history traversal
Expand Down