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

Navigation API : "activation info" #9856

Merged
merged 22 commits into from
Dec 13, 2023
Merged
Changes from 12 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
197 changes: 179 additions & 18 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -90170,6 +90170,7 @@ interface <dfn interface>Navigation</dfn> : <span>EventTarget</span> {
readonly attribute <span>NavigationHistoryEntry</span>? <span data-x="dom-Navigation-currentEntry">currentEntry</span>;
undefined <span data-x="dom-Navigation-updateCurrentEntry">updateCurrentEntry</span>(<span>NavigationUpdateCurrentEntryOptions</span> options);
readonly attribute <span>NavigationTransition</span>? <span data-x="dom-Navigation-transition">transition</span>;
readonly attribute <span>NavigationActivation</span>? <span data-x="dom-Navigation-activation">activation</span>;

readonly attribute boolean <span data-x="dom-Navigation-canGoBack">canGoBack</span>;
readonly attribute boolean <span data-x="dom-Navigation-canGoForward">canGoForward</span>;
Expand Down Expand Up @@ -92128,6 +92129,90 @@ interface <dfn interface>NavigationTransition</dfn> {
</div>


<h5 id="navigation-activation-interface">The <code>NavigationActivation</code> interface</h5>

<pre><code class="idl">[Exposed=Window]
interface <dfn interface>NavigationActivation</dfn> {
readonly attribute <span>NavigationHistoryEntry</span>? <span data-x="dom-NavigationActivation-from">from</span>;
readonly attribute <span>NavigationHistoryEntry</span> <span data-x="dom-NavigationActivation-entry">entry</span>;
readonly attribute <span>NavigationType</span> <span data-x="dom-NavigationActivation-navigationType">navigationType</span>;
domenic marked this conversation as resolved.
Show resolved Hide resolved
};</code></pre>

<dl class="domintro">
<dt><code data-x=""><span data-x="dom-navigation">navigation</span>.<span subdfn data-x="dom-Navigation-activation">activation</span></code></dt>
<dd>
<p>A <code>NavigationActivation</code> containing information about the most recent
cross-document navigation, the navigation that "activated" this <code>Document</code>.</p>

<p>While <code data-x="dom-Navigation-currentEntry">navigation.currentEntry</code> and the
<code>Document</code>'s <span data-x="concept-document-url">URL</span> can be updated regularly
due to same-document navigations, <code
data-x="dom-Navigation-activation">navigation.activation</code> stays constant, and its properties
are only updated if the <code>Document</code> is <span
data-x="reactivate a document">reactivated</span> from history.</p>
</dd>

<dt><code data-x=""><span data-x="dom-navigation">navigation</span>.<span data-x="dom-Navigation-activation">activation</span>.<span subdfn data-x="dom-NavigationActivation-entry">entry</span></code></dt>
<dd><p>A <code>NavigationHistoryEntry</code>, equivalent to the value of the <code
data-x="dom-Navigation-currentEntry">navigation.currentEntry</code> property at the moment the
<code>Document</code> was activated.</p></dd>

<dt><code data-x=""><span data-x="dom-navigation">navigation</span>.<span data-x="dom-Navigation-activation">activation</span>.<span subdfn data-x="dom-NavigationActivation-from">from</span></code></dt>
<dd>
<p>A <code>NavigationHistoryEntry</code>, representing the <code>Document</code> that was active
right before the current <code>Document</code>. This might have a value null in case the
previous <code>Document</code> was not <span>same origin</span> with this one.</p>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"might" is a bit confusing here. Is the value null or is it not when the previous document was cross origin?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's null in that case... will reword.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


<p>In case the <code>Document</code> was activated using <code
data-x="dom-location-replace">location.replace()</code>, the <code
data-x="dom-NavigationActivation-from">from</code> entry would not be a viable target for the
<code data-x="dom-Navigation-traverseTo">traverseTo()</code> function as it's not retained in
noamr marked this conversation as resolved.
Show resolved Hide resolved
history, however its <code data-x="dom-NavigationHistoryEntry-url">url</code> is still
noamr marked this conversation as resolved.
Show resolved Hide resolved
noamr marked this conversation as resolved.
Show resolved Hide resolved
noamr marked this conversation as resolved.
Show resolved Hide resolved
accessible.</p>
noamr marked this conversation as resolved.
Show resolved Hide resolved
</dd>
noamr marked this conversation as resolved.
Show resolved Hide resolved

<dt><code data-x=""><span data-x="dom-navigation">navigation</span>.<span data-x="dom-Navigation-activation">activation</span>.<span subdfn data-x="dom-NavigationActivation-navigationType">navigationType</span></code></dt>
<dd><p>One of "<code data-x="dom-NavigationType-push">push</code>", "<code
data-x="dom-NavigationType-replace">replace</code>", "<code
data-x="dom-NavigationType-reload">reload</code>", or "<code
data-x="dom-NavigationType-traverse">traverse</code>", indicating what type of navigation
activated this <code>Document</code>.</p></dd>
</dl>

<p>Each <code>Navigation</code> has an associated <dfn
data-x="navigation-activation">activation</dfn>, which is null or a
<code>NavigationActivation</code> object, initially null.</p>

<p>Each <code>NavigationActivation</code> has:</p>

<ul>
<li><p><dfn data-x="nav-activation-old-entry">old entry</dfn>, null or a
<code>NavigationHistoryEntry</code>.</p></li>

<li><p><dfn data-x="nav-activation-new-entry">new entry</dfn>, a
<code>NavigationHistoryEntry</code>.</p></li>

<li><p><dfn data-x="nav-activation-navigation-type">navigation type</dfn>, a
<span>NavigationType</span>.</p></li>
noamr marked this conversation as resolved.
Show resolved Hide resolved
</ul>

<p>The <dfn attribute for="Navigation"><code
data-x="dom-Navigation-activation">activation</code></dfn> getter steps are to return
<span>this</span>'s <span data-x="navigation-activation">activation</span>.</p>

<p>The <dfn attribute for="NavigationActivation"><code
data-x="dom-NavigationActivation-from">from</code></dfn> getter steps are to return
<span>this</span>'s <span data-x="nav-activation-old-entry">old entry</span>.</p>

<p>The <dfn attribute for="NavigationActivation"><code
data-x="dom-NavigationActivation-entry">entry</code></dfn> getter steps are to return
<span>this</span>'s <span data-x="nav-activation-new-entry">new entry</span>.</p>

<p>The <dfn attribute for="NavigationActivation"><code
data-x="dom-NavigationActivation-navigationType">navigationType</code></dfn> getter steps are to
return <span>this</span>'s <span
data-x="nav-activation-navigation-type">navigation type</span>.</p>


<h5>The <code data-x="event-navigate">navigate</code> event</h5>

Expand Down Expand Up @@ -96954,7 +97039,7 @@ location.href = '#foo';</code></pre>
</li>

<li><p><span>Apply the push/replace history step</span> <var>targetStep</var> to
<var>traversable</var>.</p></li>
<var>traversable</var> given <var>historyHandling</var>.</p></li>
</ol>


Expand Down Expand Up @@ -97326,7 +97411,8 @@ location.href = '#foo';</code></pre>
<li>
<p><span>Update document for history step application</span> given <var>navigable</var>'s
<span data-x="nav-document">active document</span>, <var>historyEntry</var>, true,
<var>scriptHistoryIndex</var>, and <var>scriptHistoryLength</var>.</p>
<var>scriptHistoryIndex</var>, <var>scriptHistoryLength</var>, and
<var>historyHandling</var>.</p>

<p class="note">This algorithm will be called twice as a result of a single fragment
navigation: once synchronously, where best-guess values <var>scriptHistoryIndex</var> and
Expand Down Expand Up @@ -97428,7 +97514,7 @@ location.href = '#foo';</code></pre>

<li>
<p><span>Apply the push/replace history step</span> <var>targetStep</var> to
<var>traversable</var>.</p>
<var>traversable</var> given <var>historyHandling</var>.</p>
noamr marked this conversation as resolved.
Show resolved Hide resolved

<p class="note">This is done even for "<code
data-x="NavigationHistoryBehavior-replace">replace</code>" navigations, as it resolves race
Expand Down Expand Up @@ -99323,15 +99409,18 @@ location.href = '#foo';</code></pre>
data-x="tn-current-session-history-step">current session history step</span>.</p></li>

<li><p>Return the result of <span data-x="apply the history step">applying the history
step</span> <var>step</var> to <var>traversable</var> given false, null, null, and null.</p></li>
step</span> <var>step</var> to <var>traversable</var> given false, null, null, null, and
null.</p></li>
</ol>

<p>To <dfn>apply the push/replace history step</dfn> given a non-negative integer <var>step</var>
to a <span>traversable navigable</span> <var>traversable</var>:</p>
and a <span>history handling behavior</span> <var>historyHandling</var> to a
<span>traversable navigable</span> <var>traversable</var>:</p>

<ol>
<li><p>Return the result of <span data-x="apply the history step">applying the history
step</span> <var>step</var> to <var>traversable</var> given false, null, null, and null.</p></li>
step</span> <var>step</var> to <var>traversable</var> given false, null, null, null, and
<var>historyHandling</var>.</p></li>
</ol>

<p class="note"><span>Apply the push/replace history step</span> never passes <span>source
Expand All @@ -99347,7 +99436,8 @@ location.href = '#foo';</code></pre>
data-x="tn-current-session-history-step">current session history step</span>.</p></li>

<li><p>Return the result of <span data-x="apply the history step">applying the history
step</span> <var>step</var> to <var>traversable</var> given true, null, null, and null.</p></li>
step</span> <var>step</var> to <var>traversable</var> given true, null, null, null,
and "<span data-x="dom-NavigationType-reload">reload</span>".</p></li>
noamr marked this conversation as resolved.
Show resolved Hide resolved
</ol>

<p class="note"><span>Apply the reload history step</span> never passes <span>source snapshot
Expand All @@ -99363,8 +99453,9 @@ location.href = '#foo';</code></pre>
<ol>
<li><p>Return the result of <span data-x="apply the history step">applying the history
step</span> <var>step</var> to <var>traversable</var> given true,
<var>sourceSnapshotParams</var>, <var>initiatorToCheck</var>, and
<var>userInvolvement</var>.</p></li>
<var>sourceSnapshotParams</var>, <var>initiatorToCheck</var>,
<var>userInvolvement</var>, and "<span
data-x="dom-NavigationType-traverse">traverse</span>".</p></li>
noamr marked this conversation as resolved.
Show resolved Hide resolved
</ol>

<hr>
Expand All @@ -99375,8 +99466,9 @@ location.href = '#foo';</code></pre>
non-negative integer <var>step</var> to a <span>traversable navigable</span>
<var>traversable</var>, with boolean <var>checkForCancelation</var>, <span>source snapshot
params</span>-or-null <var>sourceSnapshotParams</var>, <span>navigable</span>-or-null
<var>initiatorToCheck</var>, and <span>user navigation involvement</span>-or-null
<var>userInvolvementForNavigateEvents</var>, perform the following steps. They return "<code
<var>initiatorToCheck</var>, <span>user navigation involvement</span>-or-null
<var>userInvolvementForNavigateEvents</var>, and <code>NavigationType</code>-or-null
<var>navigationType</var>, perform the following steps. They return "<code
data-x="">initiator-disallowed</code>", "<code data-x="">canceled-by-beforeunload</code>", "<code
data-x="">canceled-by-navigate</code>", or "<code data-x="">applied</code>".</p>

Expand Down Expand Up @@ -99506,6 +99598,34 @@ location.href = '#foo';</code></pre>
data-x="nav-active-history-entry">active session history entry</span>.</p>
</li>

<li>
<p>Switch on <var>navigationType</var>:</p>

<dl class=switch>
<dt>"<span data-x="dom-NavigationType-reload">reload</span>"</dt>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<dt>"<span data-x="dom-NavigationType-reload">reload</span>"</dt>
<dt>"<code data-x="dom-NavigationType-reload">reload</code>"</dt>

here and for the other cases in the switch

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still to be done.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still to be done for the other three cases in the switch

<dd><p><span>Assert</span>: <var>targetEntry</var>'s <span
data-x="she-document-state">document state</span>'s <span
data-x="document-state-reload-pending">reload pending</span> is true.</p></dd>

<dt>"<span data-x="dom-NavigationType-traverse">traverse</span>"</dt>
<dd><p><span>Assert</span>: <var>targetEntry</var>'s
<span data-x="she-document-state">document state</span>'s <span
data-x="document-state-ever-populated">ever populated</span> is true.</p></dd>

<dt>"<span data-x="dom-NavigationType-replace">replace</span>"</dt>
<dd><p><span>Assert</span>: <var>targetEntry</var>'s <span data-x="she-step">step</span>
is <var>displayedEntry</var>'s <span data-x="she-step">step</span> and
<var>targetEntry</var>'s <span data-x="she-document-state">document state</span>'s <span
data-x="document-state-ever-populated">ever populated</span> is false.</p></dd>

<dt>"<span data-x="dom-NavigationType-push">push</span>"</dt>
<dd><p><span>Assert</span>: <var>targetEntry</var>'s <span data-x="she-step">step</span> is
<var>displayedEntry</var>'s <span data-x="she-step">step</span> + 1 and
<var>targetEntry</var>'s <span data-x="she-document-state">document state</span>'s <span
data-x="document-state-ever-populated">ever populated</span> is false.</p></dd>
</dl>
</li>

<li><p>Let <var>oldOrigin</var> be <var>targetEntry</var>'s <span
data-x="she-document-state">document state</span>'s <span
data-x="document-state-origin">origin</span>.</p></li>
Expand Down Expand Up @@ -99778,8 +99898,8 @@ location.href = '#foo';</code></pre>
data-x="she-document">document</span>, <var>targetEntry</var>,
<var>changingNavigableContinuation</var>'s <span
data-x="changing-nav-continuation-update-only">update-only</span>,
<var>scriptHistoryLength</var>, <var>scriptHistoryIndex</var>, and
<var>entriesForNavigationAPI</var>.</p></li>
<var>scriptHistoryLength</var>, <var>scriptHistoryIndex</var>, <var>navigationType</var>,
<var>entriesForNavigationAPI</var>, and <var>displayedEntry</var>.</p></li>
noamr marked this conversation as resolved.
Show resolved Hide resolved

<li><p>If <var>targetEntry</var>'s <span data-x="she-document">document</span> is equal to
<var>displayedDocument</var>, then perform <var>updateDocument</var>.</p></li>
Expand Down Expand Up @@ -100115,8 +100235,10 @@ location.href = '#foo';</code></pre>
<p>To <dfn>update document for history step application</dfn> given a <code>Document</code>
<var>document</var>, a <span>session history entry</span> <var>entry</var>, a boolean
<var>doNotReactivate</var>, integers <var>scriptHistoryLength</var> and
<var>scriptHistoryIndex</var>, and an optional <span>list</span> of <span data-x="session history
entry">session history entries</span> <var>entriesForNavigationAPI</var>:</p>
<var>scriptHistoryIndex</var>, <code>NavigationType</code> <var>navigationType</var>, an optional
<span>list</span> of <span data-x="session history entry">session history entries</span>
<var>entriesForNavigationAPI</var>, and an optional <span>session history entry</span>
<var>previousDisplayedEntry</var>:</p>
noamr marked this conversation as resolved.
Show resolved Hide resolved

<ol>
<li><p>Let <var>documentIsNew</var> be true if <var>document</var>'s <span>latest entry</span>
Expand All @@ -100131,6 +100253,9 @@ location.href = '#foo';</code></pre>
<li><p>Set <var>document</var>'s <span data-x="doc-history">history object</span>'s <span
data-x="concept-history-length">length</span> to <var>scriptHistoryLength</var>.</p></li>

<li><p>Let <var>navigation</var> be <var>history</var>'s <span>relevant global object</span>'s
<span data-x="window-navigation-api">navigation API</span>.</p></li>

<li>
<p>If <var>documentsEntryChanged</var> is true, then:</p>

Expand All @@ -100143,9 +100268,6 @@ location.href = '#foo';</code></pre>
<li><p><span>Restore the history object state</span> given <var>document</var> and
<var>entry</var>.</p></li>

<li><p>Let <var>navigation</var> be <var>history</var>'s <span>relevant global object</span>'s
<span data-x="window-navigation-api">navigation API</span>.</p></li>

<li>
<p>If <var>documentIsNew</var> is false, then:</p>

Expand Down Expand Up @@ -100196,6 +100318,45 @@ location.href = '#foo';</code></pre>
</ol>
</li>

<li>
<p>If <var>navigationType</var> is "<code data-x="dom-NavigationType-reload">reload</code>", or
if <var>previousDisplayedEntry</var> is given and its <span
data-x="she-document">document</span> is not <var>document</var>, then:</p>

<ol>
<li><p>If <var>navigation</var>'s <span
data-x="navigation-activation">activation</span> is null, then set <var>navigation</var>'s
<span data-x="navigation-activation">activation</span> to a new
noamr marked this conversation as resolved.
Show resolved Hide resolved
<code>NavigationActivation</code> object in <var>navigation</var>'s
<span data-x="concept-relevant-realm">relevant realm</span>.</p></li>

<li><p>Let <var>previousEntryIndex</var> be the result of
<span>getting the navigation API entry index</span> of <var>previousDisplayedEntry</var>
within <var>navigation</var>.</p></li>
noamr marked this conversation as resolved.
Show resolved Hide resolved

<li><p>If <var>previousEntryIndex</var> is non-negative, then set <var>activation</var>'s
<span data-x="nav-activation-old-entry">old entry</span> to <var>navigation</var>'s <span
data-x="navigation-entry-list">entry list</span>[<var>previousEntryIndex</var>].</p></li>

<li><p>Otherwise, if <var>navigationType</var> is "<code
data-x="dom-NavigationType-replace">replace</code>" and <var>previousDisplayedEntry</var>'s
<span data-x="she-document-state">document state</span>'s <span
data-x="document-state-origin">origin</span> is <span>same origin</span> with
<var>document</var>'s <span data-x="concept-document-origin">origin</span>, then set
<var>activation</var>'s <span data-x="nav-activation-old-entry">old entry</span> to a new
<code>NavigationHistoryEntry</code> whose <span data-x="nhe-she">session history entry</span>
is <var>previousDisplayedEntry</var>.</p></li>
noamr marked this conversation as resolved.
Show resolved Hide resolved

<li><p>Set <var>activation</var>'s <span data-x="nav-activation-new-entry">new entry</span> to
the <span data-x="navigation-current-entry">current entry</span> for
<var>navigation</var>.</p></li>
noamr marked this conversation as resolved.
Show resolved Hide resolved

<li><p>Set <var>activation</var>'s <span
data-x="nav-activation-navigation-type">navigation type</span> to
<var>navigationType</var>.</p></li>
</ol>
</li>

<li>
<p>If <var>documentIsNew</var> is true, then:

noamr marked this conversation as resolved.
Show resolved Hide resolved
Expand Down