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 19 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
237 changes: 215 additions & 22 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,94 @@ 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
Contributor 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
Contributor Author

Choose a reason for hiding this comment

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

Fixed


<p>There are some cases in which either the <code
data-x="dom-NavigationActivation-from">from</code> or <code
data-x="dom-NavigationActivation-entry">entry</code> <code>NavigationHistoryEntry</code> objects
would not be viable targets for the <code data-x="dom-Navigation-traverseTo">traverseTo()</code>
noamr marked this conversation as resolved.
Show resolved Hide resolved
method, as they might not be retained in history. For example, the <code>Document</code> can be
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
activated using <code data-x="dom-location-replace">location.replace()</code> or its initial
noamr marked this conversation as resolved.
Show resolved Hide resolved
entry could be replaced by <code
noamr marked this conversation as resolved.
Show resolved Hide resolved
data-x="dom-history-replaceState">history.replaceState()</code>. However, those entries' <code
data-x="dom-NavigationHistoryEntry-url">url</code> property and <code
data-x="dom-NavigationHistoryEntry-getState">getState()</code> method are still accessible.</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-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
noamr marked this conversation as resolved.
Show resolved Hide resolved
<code>NavigationHistoryEntry</code>.</p></li>

<li><p><dfn data-x="nav-activation-navigation-type">navigation type</dfn>, a
<code>NavigationType</code>.</p></li>
</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 +97043,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 +97415,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 @@ -97359,7 +97449,8 @@ location.href = '#foo';</code></pre>

<ol>
<li><p><span>Finalize a same-document navigation</span> given <var>traversable</var>,
<var>navigable</var>, <var>historyEntry</var>, and <var>entryToReplace</var>.</p></li>
<var>navigable</var>, <var>historyEntry</var>, <var>entryToReplace</var>, and
<var>historyHandling</var>.</p></li>

<li><p>Invoke <span>WebDriver BiDi fragment navigated</span> with <var>navigable</var>'s <span
data-x="nav-bc">active browsing context</span> and a new <span>WebDriver BiDi navigation
Expand All @@ -97373,8 +97464,9 @@ location.href = '#foo';</code></pre>

<p>To <dfn>finalize a same-document navigation</dfn> given a <span>traversable navigable</span>
<var>traversable</var>, a <span>navigable</span> <var>targetNavigable</var>, a <span>session
history entry</span> <var>targetEntry</var>, and <span>session history entry</span>-or-null
<var>entryToReplace</var>:</p>
history entry</span> <var>targetEntry</var>, a <span>session history entry</span>-or-null
<var>entryToReplace</var>, and a <span>history handling behavior</span>
<var>historyHandling</var>:</p>

<p class="note">This is used by both <span data-x="navigate-fragid">fragment navigations</span>
and by the <span>URL and history update steps</span>, which are the only synchronous updates to
Expand Down Expand Up @@ -97428,7 +97520,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>

<p class="note">This is done even for "<code
data-x="NavigationHistoryBehavior-replace">replace</code>" navigations, as it resolves race
Expand Down Expand Up @@ -98099,7 +98191,8 @@ location.href = '#foo';</code></pre>

<ol>
<li><p><span>Finalize a same-document navigation</span> given <var>traversable</var>,
<var>navigable</var>, <var>newEntry</var>, and <var>entryToReplace</var>.</p></li>
<var>navigable</var>, <var>newEntry</var>, <var>entryToReplace</var>, and
<var>historyHandling</var>.</p></li>
</ol>
</li>
</ol>
Expand Down Expand Up @@ -99323,15 +99416,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 +99443,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 "<code data-x="dom-NavigationType-reload">reload</code>".</p></li>
</ol>

<p class="note"><span>Apply the reload history step</span> never passes <span>source snapshot
Expand All @@ -99363,8 +99460,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 "<code
data-x="dom-NavigationType-traverse">traverse</code>".</p></li>
</ol>

<hr>
Expand All @@ -99375,8 +99473,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 +99605,34 @@ location.href = '#foo';</code></pre>
data-x="nav-active-history-entry">active session history entry</span>.</p>
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

</li>

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

<dl class=switch>
<dt>"<code data-x="dom-NavigationType-reload">reload</code>"</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-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 +99905,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>

<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 +100242,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>-or-null <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>previousEntryForActivation</var>:</p>

<ol>
<li><p>Let <var>documentIsNew</var> be true if <var>document</var>'s <span>latest entry</span>
Expand All @@ -100131,6 +100260,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 +100275,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 +100325,70 @@ location.href = '#foo';</code></pre>
</ol>
</li>

<li>
<p>If all the following are true:</p>
noamr marked this conversation as resolved.
Show resolved Hide resolved

<ul class="brief">
<li><var>previousEntryForActivation</var> is given;</li>

<li><var>navigationType</var> is non-null; and</li>

noamr marked this conversation as resolved.
Show resolved Hide resolved
<li><var>navigationType</var> is "<code data-x="dom-NavigationType-reload">reload</code>" or
<var>previousEntryForActivation</var>'s <span data-x="she-document">document</span> is not
<var>document</var></li>
</ul>

<p>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
<code>NavigationActivation</code> object in <var>navigation</var>'s
<span data-x="concept-relevant-realm">relevant realm</span>.</p></li>
noamr marked this conversation as resolved.
Show resolved Hide resolved

<li><p>Let <var>previousEntryIndex</var> be the result of
<span>getting the navigation API entry index</span> of <var>previousEntryForActivation</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 all the following are true:</p>

<ul class="brief">
<li><var>navigationType</var> is "<code
noamr marked this conversation as resolved.
Show resolved Hide resolved
data-x="dom-NavigationType-replace">replace</code>"</li>

<li><var>previousEntryForActivation</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></li>

<li><var>previousEntryForActivation</var>'s
<span data-x="she-document-state">document state</span>'s
<span data-x="she-document">document</span> is not the <span data-x="is initial
about:blank">initial <code>about:blank</code></span> <code>Document</code></li>
noamr marked this conversation as resolved.
Show resolved Hide resolved
</ul>

<p>then set <var>activation</var>'s <span data-x="nav-activation-old-entry">old entry</span>
to a new <code>NavigationHistoryEntry</code> in <var>navigation</var>'s <span
data-x="concept-relevant-realm">relevant realm</span>, whose <span
data-x="nhe-she">session history entry</span> is
<var>previousEntryForActivation</var>.</p>
</li>

<li><p>Set <var>activation</var>'s <span data-x="nav-activation-new-entry">new entry</span> to
<var>navigation</var>'s <span data-x="navigation-current-entry">current entry</span>.</p></li>

<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:

Expand Down