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
text: generate a random UUID; url: #dfn-generate-a-random-uuid
52
69
</pre>
@@ -612,10 +629,11 @@ The <dfn attribute for="AppHistoryDestination">sameDocument</dfn> getter steps a
612
629
<h3 id="navigate-event-firing">Firing the event</h3>
613
630
614
631
<div algorithm="fire a traversal navigate event">
615
-
To <dfn>fire a traversal `navigate` event</dfn> at an {{AppHistory}} |appHistory| given a [=session history entry=]<dfn for="fire a traversal navigate event">|destinationEntry|</dfn>, a boolean <dfn for="fire a traversal navigate event">|isSameDocument|</dfn>, an optional [=user navigation involvement=]<dfn for="fire a traversal navigate event">|userInvolvement|</dfn> (default "<code>[=user navigation involvement/none=]</code>"), and an optional JavaScript value |info| (default undefined):
632
+
To <dfn>fire a traversal `navigate` event</dfn> at an {{AppHistory}} |appHistory| given a [=session history entry=]<dfn for="fire a traversal navigate event">|destinationEntry|</dfn>, an optional [=user navigation involvement=]<dfn for="fire a traversal navigate event">|userInvolvement|</dfn> (default "<code>[=user navigation involvement/none=]</code>"), and an optional JavaScript value |info| (default undefined):
616
633
617
634
1. Let |destinationURL| be |destinationEntry|'s [=session history entry/URL=].
618
635
1. Let |destinationState| be |destinationEntry|'s [=session history entry/app history state=].
636
+
1. Let |isSameDocument| be true if |destinationEntry|'s [=session history entry/document=] is equal to |appHistory|'s [=relevant global object=]'s [=associated Document=]; otherwise false.
619
637
1. Let |event| be the result of [=creating an event=] given {{AppHistoryNavigateEvent}}, in |appHistory|'s [=relevant Realm=].
620
638
1. Set |event|'s [=AppHistoryNavigateEvent/destination entry=] to |destinationEntry|.
621
639
1. Return the result of performing the [=inner navigate event firing algorithm=] given |appHistory|, |event|, "{{AppHistoryNavigationType/traverse}}", |isSameDocument|, |destinationURL|, |destinationState|, |userInvolvement|, |info|, and null.
@@ -650,6 +668,7 @@ The <dfn attribute for="AppHistoryDestination">sameDocument</dfn> getter steps a
650
668
then initialize |event|'s {{AppHistoryNavigateEvent/hashChange}} to true. Otherwise, initialize it to false.
651
669
1. If |destinationURL| is [=rewritable=] relative to |currentURL|, and either |isSameDocument| is true or |navigationType| is not "{{AppHistoryNavigationType/traverse}}", then initialize |event|'s {{AppHistoryNavigateEvent/canRespond}} to true. Otherwise, initialize it to false.
652
670
1. If either |userInvolvement| is not "<code>[=user navigation involvement/browser UI=]</code>" or |navigationType| is not "{{AppHistoryNavigationType/traverse}}", then initialize |event|'s {{Event/cancelable}} to true.
671
+
1. If both |event|'s {{AppHistoryNavigateEvent/canRespond}} and |event|'s {{Event/cancelable}} are false, then return true. (No event is actually fired.)
653
672
1. If |userInvolvement| is "<code>[=user navigation involvement/none=]</code>", then initialize |event|'s {{AppHistoryNavigateEvent/userInitiated}} to false. Otherwise, initialize it to true.
654
673
1. If |formDataEntryList| is not null, then initialize |event|'s {{AppHistoryNavigateEvent/formData}} to a [=new=]{{FormData}} created in |realm|, associated to |formDataEntryList|. Otherwise, initialize it to null.
655
674
1. [=Assert=]: |appHistory|'s [=AppHistory/ongoing navigate event=] is null.
@@ -963,17 +982,6 @@ With the above infrastructure in place, we can actually fire and handle the {{Ap
963
982
<p class="note">"<code>[=user navigation involvement/browser UI=]</code>" or [=same origin-domain|cross origin-domain=] navigations that cause <a spec="HTML" lt="navigate to a fragment">fragment navigations</a><em>do</em> fire the {{AppHistory/navigate}} event; those are handled as part of the <a spec="HTML">navigate to a fragment</a> algorithm called earlier in <a spec="HTML">navigate</a>, which is not guarded by this condition.
964
983
</div>
965
984
966
-
<div algorithm="traverse the history by a delta">
967
-
Modify the <a spec="HTML">traverse the history by a delta</a> algorithm by inserting the following steps inside the queued task, before the call to <a spec="HTML">traverse the history</a>. Recall that per [[#user-initiated-patches]] we have introduced a |userInvolvement| argument.
968
-
969
-
1. Let |appHistory| be <var ignore>specified browsing context</var>'s [=browsing context/active window=]'s [=Window/app history=].
970
-
1. [=Cancel any ongoing navigate event=] for |appHistory|.
971
-
1. Let |isSameDocument| be true if <var ignore>specified browsing context</var>'s [=active document=] equals <var ignore>specified entry</var>'s [=session history entry/document=]; otherwise, false.
972
-
1. If either |isSameDocument| is true or |userInvolvement| is not "<code>[=user navigation involvement/browser UI=]</code>", then:
973
-
1. Let |continue| be the result of [=firing a traversal navigate event=] at |appHistory| with <i>[=fire a traversal navigate event/destinationEntry=]</i> set to <var ignore>specified entry</var>, <i>[=fire a traversal navigate event/isSameDocument=]</i> set to |isSameDocument|, and <i>[=fire a traversal navigate event/userInvolvement=]</i> set to |userInvolvement|.
974
-
1. If |continue| is false, abort these steps.
975
-
</div>
976
-
977
985
<div algorithm>
978
986
To <dfn>convert a history handling behavior to a navigation type</dfn> given a <a spec="HTML">history handling behavior</a> |historyHandling|:
979
987
@@ -989,6 +997,43 @@ With the above infrastructure in place, we can actually fire and handle the {{Ap
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 app history updates. Recall that per [[#user-initiated-patches]] we have introduced a |userInvolvement| argument, so the arguments are now |delta|, |source browsing context|, and |userInvolvement|.
1004
+
1005
+
1. Let |traversable| be |source browsing context|'s [=browsing context/containing navigable=]'s [=navigable/traversable navigable=].
1006
+
1. Let |initiatorOrigin| be |source browsing context|'s [=active document=]'s [=Document/origin=].
1007
+
1. [=parallel queue/enqueue steps|Enqueue the following steps=] to |traversable|'s [=traversable navigable/session history traversal queue=]:
1008
+
1. Let |allSteps| be the result of [=traversable navigable/getting all history steps=] for |traversable|.
1009
+
1. Let |targetStep| be TODO compute using [=traversable navigable/current session history step=], |allSteps|, and |delta|. Will be failure if there is no step |delta| away from the current one.
1010
+
1. If |targetStep| is failure, then return.
1011
+
1. [=Apply the history step=] |targetStep| to |traversable| with true, <var ignore>step</var>, |initiatorOrigin|, and |userInvolvement|.
1012
+
</div>
1013
+
1014
+
<div algorithm="apply the history step">
1015
+
Modify the <a spec="HTML">apply the history step</a> algorithm as follows. Change <var ignore>checkForUserCancellation</var> to |fireBeforeunloadAndNavigate|. Add the |userInvolvement| parameter. Then, insert the following step after step 12 (which assembles |toTraverse| and other lists) but before step 13 (which checks if unloading is user-cancelled):
1016
+
1017
+
1. If |fireBeforeunloadAndNavigate| is true and the result of <a>firing traversal `navigate` events</a> given |toTraverse|, <var ignore>step</var>, <var ignore>initiatorToCheck</var>, and |userInvolvement| is false, then return.
1018
+
</div>
1019
+
1020
+
<div algorithm>
1021
+
To <dfn>fire traversal `navigate` events</dfn> for a [=list=] of [=navigables=] |toTraverse|, an integer |step|, an [=origin=] |initiatorOrigin|, and a [=user navigation involvement=] |userInvolvement|:
1022
+
1023
+
1. Let |overallResult| be true.
1024
+
1. Let |totalTasks| be the [=list/size=] of |toTraverse|.
1025
+
1. Let |completedTasks| be 0.
1026
+
1. [=list/For each=] |navigable| of |toTraverse|, [=queue a global task=] on the [=history traversal task source=] given |navigable|'s [=navigable/active document=]'s [=relevant global object=] to run these steps:
1027
+
1. Let |destinationEntry| be the item in the result of [=navigable/getting the session history entries=] for |navigable| that has the greatest [=session history entry/step=] less than or equal to |step|.
1028
+
1. If |destinationEntry|'s [=session history entry/document=] is not equal to |navigable|'s [=navigable/active document=], and |initiatorOrigin| is not [=same origin-domain=] with |navigable|'s [=navigable/active document=]'s [=Document/origin=], then abort these steps.
1029
+
1. Let |appHistory| be |navigable|'s [=navigable/active document=]'s [=relevant global object=]'s [=Window/app history=].
1030
+
1. Let |result| be the result of [=firing a traversal navigate event=] at |appHistory| with <i>[=fire a traversal navigate event/destinationEntry=]</i> set to |destinationEntry| and <i>[=fire a traversal navigate event/userInvolvement=]</i> set to |userInvolvement|.
1031
+
1. If |result| is false, then set |overallResult| to false.
1032
+
1. Increment |completedTasks|.
1033
+
1. Wait for |completedTasks| to be |totalTasks|.
1034
+
1. Return |overallResult|.
1035
+
</div>
1036
+
992
1037
<h2 id="session-history-patches">Patches to session history</h2>
993
1038
994
1039
This section details monkeypatches to [[!HTML]] to track appropriate data for associating an {{AppHistory}} with a [=session history entry=].
0 commit comments