You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Similar to the previous commit, this attempts to tackle a specific area, not the whole rebase project (which is tracked in #221). It focuses on traversal, in particular integration with the new versions of "apply the history step" and "traverse the history by a delta".
This removes a TODO in the former definition of "perform a navigation API traversal".
@@ -988,9 +998,11 @@ An <dfn>navigation API method navigation</dfn> is a [=struct=] with the followin
988
998
989
999
To <dfn>perform a navigation API traversal</dfn> given a {{Navigation}} object |navigation|, a string |key|, and a {{NavigationOptions}} |options|:
990
1000
991
-
1. If |navigation|'s [=relevant global object=]'s [=associated Document=] is not [=Document/fully active=], then return [=an early error result=] for an "{{InvalidStateError}}" {{DOMException}}.
1001
+
1. Let |sourceDocument| be |navigation|'s [=relevant global object=]'s [=associated Document=].
992
1002
993
-
1. If |navigation|'s [=relevant global object=]'s [=associated Document=]'s <a spec="HTML">unload counter</a> is greater than 0, then return [=an early error result=] for an "{{InvalidStateError}}" {{DOMException}}.
1003
+
1. If |sourceDocument| is not [=Document/fully active=], then return [=an early error result=] for an "{{InvalidStateError}}" {{DOMException}}.
1004
+
1005
+
1. If |sourceDocument|'s <a spec="HTML">unload counter</a> is greater than 0, then return [=an early error result=] for an "{{InvalidStateError}}" {{DOMException}}.
994
1006
995
1007
1. If |navigation|'s [=Navigation/current entry=]'s [=NavigationHistoryEntry/session history entry=]'s [=session history entry/navigation API key=] equals |key|, then return «[ "{{NavigationResult/committed}}" → [=a promise resolved with=] |navigation|'s [=Navigation/current entry=], "{{NavigationResult/finished}}" → [=a promise resolved with=] |navigation|'s [=Navigation/current entry=] ]»
996
1008
@@ -1000,23 +1012,25 @@ An <dfn>navigation API method navigation</dfn> is a [=struct=] with the followin
1000
1012
1001
1013
1. Return «[ "{{NavigationResult/committed}}" → |navigation|'s [=navigation API method navigation/committed promise=], "{{NavigationResult/finished}}" → |navigation|'s [=navigation API method navigation/finished promise=] ]».
1002
1014
1003
-
1. Let |navigable| be |navigation|'s [=relevant global object=]'s[=Window/browsing context=]'s [=browsing context/containing navigable=].
1015
+
1. Let |info| be |options|["{{NavigationOptions/info}}"] if it[=map/exists=], or undefined otherwise.
1004
1016
1005
-
1. Let |traversable| be |navigable|'s [=navigable/traversable navigable=].
1017
+
1. Let |ongoingNavigation| be the result of [=Navigation/setting an upcoming traverse navigation=] for |navigation| given |key| and |info|.
1006
1018
1007
-
1. Let |initiatorBC| be |navigation|'s [=relevant global object=]'s [=Window/browsing context=].
1019
+
1. Let |navigable| be |sourceDocument|'s [=node navigable=].
1008
1020
1009
-
1. Let |info| be |options|["{{NavigationOptions/info}}"] if it [=map/exists=], or undefined otherwise.
1021
+
1. Let |traversable| be |navigable|'s [=navigable/traversable navigable=].
1010
1022
1011
-
1. Let |ongoingNavigation| be the result of [=Navigation/setting an upcoming traverse navigation=] for |navigation| given |key| and |info|.
1023
+
1. Let |unsafeNavigationStartTime| be the [=unsafe shared current time=].
1024
+
1025
+
1. Let |sourceSnapshotParams| be the result of [=snapshotting source snapshot params=] given |sourceDocument|.
1012
1026
1013
-
1. [=parallel queue/Enqueue the following steps=] on |traversable|'s [=traversable navigable/session history traversal queue=]:
1027
+
1. [=Append the following session history traversal steps=] to |traversable|:
1014
1028
1015
1029
1. Let |navigableEntries| be the result of [=navigable/getting the session history entries=] given |navigable|.
1016
1030
1017
1031
1. Let |targetEntry| be the [=session history entry=] in |navigableEntries| whose [=session history entry/navigation API key=] equals |key|. If no such entry exists, then:
1018
1032
1019
-
1. [=navigation API method navigation/Reject the finished promise=] for |ongoingNavigation| with an "{{InvalidStateError}}" {{DOMException}}.
1033
+
1. [=Queue a global task=] on the [=navigation and traversal task source=] given |sourceDocument|'s [=relevant global object=] to [=navigation API method navigation/reject the finished promise=] for |ongoingNavigation| with an "{{InvalidStateError}}" {{DOMException}}.
1020
1034
1021
1035
1. Abort these steps.
1022
1036
@@ -1026,25 +1040,13 @@ An <dfn>navigation API method navigation</dfn> is a [=struct=] with the followin
1026
1040
1027
1041
<p class="note">This can occur if a previously-queued-up traversal already took us to this session history entry. In that case that previous traversal will have dealt with |ongoingNavigation| already.
1028
1042
1029
-
1. Let |targetStep| be null.
1043
+
1. [=Apply the history step=] given by |targetEntry|'s [=session history entry/step=] to |traversable|, with <i>[=apply the history step/checkForUserCancellation=]</i> set to true, <i>[=apply the history step/unsafeNavigationStartTime=]</i> set to |unsafeNavigationStartTime|, <i>[=apply the history step/sourceSnapshotParams=]</i> set to |sourceSnapshotParams|, and <i>[=apply the history step/initiatorToCheck=]</i> set to |navigable|.
1030
1044
1031
-
1. If |targetEntry|'s [=session history entry/step=] is greater than |traversable|'s [=traversable navigable/current session history step=], then set |targetStep| to |targetEntry|'s [=session history entry/step=].
1045
+
- If this aborts due to user-canceled unloading <!-- or, in the future if we allow it to be cancelable, due to the {{Navigation/navigate}} event being canceled, --> then [=queue a global task=] on the [=navigation and traversal task source=] given |sourceDocument|'s [=relevant global object=] to [=finalize with an aborted navigation error=] given |navigation| and |ongoingNavigation|.
1032
1046
1033
-
1. Otherwise:
1034
-
1035
-
1. Let |afterTarget| be the [=session history entry=] after |targetEntry| in |navigableEntries|.
1036
-
1037
-
1. Let |allSteps| be the result of [=traversable navigable/getting all history steps=] that are part of the target session TODO.
1038
-
1039
-
1. Set |targetStep| to the greatest number in |allSteps| that is less than |afterTarget|'s [=session history entry/step=].
1040
-
1041
-
1. [=Apply the history step=] |targetStep| to |traversable|, with true, |initiatorBC|, and "<code>[=user navigation involvement/none=]</code>".
1047
+
- If this aborts due to the initiator allowed-to-navigate check, then [=queue a global task=] on the [=navigation and traversal task source=] given |sourceDocument|'s [=relevant global object=] to [=finalize with an aborted navigation error=] given |navigation|, |ongoingNavigation|, and a [=new=] "{{SecurityError}}" {{DOMException}} created in |navigation|'s [=relevant Realm=].
1042
1048
1043
-
- If this aborts due to user-canceled unloading or due to the {{Navigation/navigate}} event being canceled, then [=finalize with an aborted navigation error=] given |navigation| and |ongoingNavigation|.
1044
-
1045
-
- If this aborts due to the initiator allowed-to-navigate check, then [=finalize with an aborted navigation error=] given |navigation|, |ongoingNavigation|, and a [=new=] "{{SecurityError}}" {{DOMException}} created in |navigation|'s [=relevant Realm=].
1046
-
1047
-
<p class="advisement">Eventually [=apply the history step=] will have well-specified hooks for communicating these conditions back to its caller.</p>
1049
+
<p class="advisement">As part of merging this spec into HTML, we would modify [=apply the history step=] to have well-specified hooks for communicating these conditions back to its caller.</p>
1048
1050
1049
1051
1. Return «[ "{{NavigationResult/committed}}" → |ongoingNavigation|'s [=navigation API method navigation/committed promise=], "{{NavigationResult/finished}}" → |ongoingNavigation|'s [=navigation API method navigation/finished promise=] ]».
1050
1052
</div>
@@ -1722,10 +1724,10 @@ Modify the <a spec="HTML">navigate</a> algorithm to take an optional named argum
1722
1724
1723
1725
Modify the [=navigate to a fragment=] algorithm to take a new <var ignore>userInvolvement</var> argument. Then, update the call to it from <a spec="HTML">navigate</a> to set <i>[=navigate/userInvolvement=]</i> to this <var ignore>userInvolvement</var> value.
1724
1726
1725
-
Modify the <a spec="HTML">traverse the history by a delta</a> argument to take an optional named argument <dfn for="traverse the history by a delta"><var ignore>userInvolvement</var></dfn> (default "<code>[=user navigation involvement/none=]</code>"). Then, update the paragraph talking about user-initiated navigation as follows:
1727
+
Modify the [=traverse the history by a delta=] algorithm to take an optional named argument <dfn for="traverse the history by a delta"><var ignore>userInvolvement</var></dfn> (default "<code>[=user navigation involvement/none=]</code>"). Pass it along when calling [=apply the history step=], which also needs to be modified to take such a argument. Then, update the paragraph talking about user-initiated navigation as follows:
1726
1728
1727
1729
<blockquote>
1728
-
When the user navigates through a [=browsing context=], e.g. using a browser's back and forward buttons, the user agent must <a spec="HTML">traverse the history by a delta</a> with a delta equivalent to the action specified by the user<del> and</del><ins>,</ins> the browsing context being operated on<ins>, and <i>[=traverse the history by a delta/userInvolvement=]</i> set to "<code>[=user navigation involvement/browser UI=]</code>"</ins>.
1730
+
When the user navigates through a [=browsing context=], e.g. using a browser's back and forward buttons, the user agent must <a spec="HTML">traverse the history by a delta</a> with the [=top-level traversable=] being operated on, a delta equivalent to the action specified by the user<ins>, and <i>[=traverse the history by a delta/userInvolvement=]</i> set to "<code>[=user navigation involvement/browser UI=]</code>"</ins>.
1729
1731
</blockquote>
1730
1732
1731
1733
<hr>
@@ -1833,23 +1835,12 @@ Expand the section of the navigation/traversal response handling which deals wit
The <a spec="HTML">traverse the history by a delta</a> algorithm will be totally re-written as part of <a href="https://github.com/whatwg/html/pull/6315">the session history rewrite</a>. Here we reproduce the final version of the algorithm, after both that rewrite and with appropriate navigation API updates. Recall that per [[#user-initiated-patches]] we have introduced a |userInvolvement| argument, so the arguments are now |delta|, |source browsing context|, and |userInvolvement|.
1838
-
1839
-
1. Let |traversable| be |source browsing context|'s [=browsing context/containing navigable=]'s [=navigable/traversable navigable=].
1840
-
1. Let |initiatorOrigin| be |source browsing context|'s [=active document=]'s [=Document/origin=].
1841
-
1. [=parallel queue/enqueue steps|Enqueue the following steps=] to |traversable|'s [=traversable navigable/session history traversal queue=]:
1842
-
1. Let |allSteps| be the result of [=traversable navigable/getting all history steps=] for |traversable|.
1843
-
1. Let |currentStepIndex| be the index of the [=traversable navigable/current session history step=] within |allSteps|.
1844
-
1. Let |targetStepIndex| be |currentStepIndex| plus |delta|.
1845
-
1. If |allSteps|[|targetStepIndex|] does not [=set/exist=], then return.
1846
-
1. [=Apply the history step=] |allSteps|[|targetStepIndex|] to |traversable| with true, <var ignore>step</var>, |initiatorOrigin|, and |userInvolvement|.
1847
-
</div>
1848
-
1849
1838
<div algorithm="apply the history step">
1850
-
Modify the <a spec="HTML">apply the history step</a> algorithm as follows. Inside the loop over each <var ignore>navigable</var> of <var ignore>toTraverse</var>, inside the task that is posted, after the check if |targetEntry|'s document is |previousDocument| that might abort the algorithm, add the following steps:
1839
+
Modify the [=apply the history step=] algorithm as follows. Near the end of the algorithm, inside the queued task over each global (currently step 14.10), before potentially unloading or activating the history entry, add the following step:
1840
+
1841
+
1. [=Fire a traversal navigate event=] at <var ignore>displayedDocument</var>'s [=relevant global object=]'s [=Window/navigation API=] with <i>[=fire a traversal navigate event/destinationEntry=]</i> set to <var ignore>targetEntry</var> and <i>[=fire a traversal navigate event/userInvolvement=]</i> set to <var ignore>userInvolvement</var>.
1851
1842
1852
-
1. [=Fire a traversal navigate event=] at |previousDocument|'s [=relevant global object=]'s [=Window/navigation API=] with <i>[=fire a traversal navigate event/destinationEntry=]</i> set to |targetEntry| and <i>[=fire a traversal navigate event/userInvolvement=]</i> set to <var ignore>userInvolvement</var>.
1843
+
(Recall that we introduced the <var ignore>userInvolvement</var> parameter as part of [[#user-initiated-patches]].)
1853
1844
</div>
1854
1845
1855
1846
<h3 id="navigate-event-download-patches">Download a hyperlink updates</h3>
0 commit comments