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
62
</pre>
@@ -471,8 +481,6 @@ Each {{AppHistory}} object has an associated <dfn for="AppHistory">navigate meth
471
481
472
482
1. If [=this=]'s [=AppHistory/current index=] is −1, then return [=a promise rejected with=] an "{{InvalidStateError}}" {{DOMException}}.
473
483
474
-
1. If [=this=]'s [=AppHistory/entry list=][[=this=]'s [=AppHistory/current index=]]'s [=AppHistoryEntry/session history entry=]'s [=session history entry/app history key=] equals |key|, then return [=a promise resolved with=] undefined.
475
-
476
484
1. If [=this=]'s [=AppHistory/entry list=] does not contain any {{AppHistoryEntry}} whose [=AppHistoryEntry/session history entry=]'s [=session history entry/app history key=] equals |key|, then return [=a promise rejected with=] an "{{InvalidStateError}}" {{DOMException}}.
477
485
478
486
1. Return the result of [=performing an app history traversal=] given [=this=], |key|, and |options|.
@@ -499,29 +507,53 @@ Each {{AppHistory}} object has an associated <dfn for="AppHistory">navigate meth
499
507
</div>
500
508
501
509
<div algorithm>
510
+
<p class="advisement">The following algorithm is specified in terms of the <a href="https://github.com/whatwg/html/pull/6315">session history rewrite pull request</a> against the HTML Standard, because the existing session history traversal infrastructure is broken enough that it's hard to build on. It is expected to track that work as it continues.</p>
511
+
502
512
To <dfn>perform an app history traversal</dfn> given an {{AppHistory}} object |appHistory|, a string |key|, and an {{AppHistoryNavigationOptions}} |options|:
503
513
504
514
1. If |appHistory|'s [=relevant global object=]'s [=associated Document=] is not [=Document/fully active=], then return [=a promise rejected with=] an "{{InvalidStateError}}" {{DOMException}}.
505
515
506
516
1. If |appHistory|'s [=relevant global object=]'s [=associated Document=]'s <a spec="HTML">unload counter</a> is greater than 0, then return [=a promise rejected with=] an "{{InvalidStateError}}" {{DOMException}}.
507
517
508
-
1. Let |jsh| be |appHistory|'s [=relevant global object=]'s [=Window/browsing context=]'s [=top-level browsing context=]'s <a spec="HTML">joint session history</a>.
518
+
1. If |appHistory|'s [=AppHistory/entry list=][|appHistory|'s [=AppHistory/current index=]]'s [=AppHistoryEntry/session history entry=]'s [=session history entry/app history key=] equals |key|, then return [=a promise resolved with=] undefined.
509
519
510
-
1. Let |currentEntryIndex| be the index of the <a spec="HTML" lt="current entry of the joint session history">current entry</a> within |jsh|.
520
+
1. Let |navigateInfo| be |options|["{{AppHistoryNavigationOptions/navigateInfo}}"] if it [=map/exists=], or undefined otherwise.
511
521
512
-
1. Let |destinationIndex| be the index of the closest [=session history entry=] to the <a spec="HTML" lt="current entry of the joint session history">current entry</a>, such that either that entry's [=session history entry/app history key=] equals |key|, or that entry is "standing in place of" another entry whose [=session history entry/app history key=] equals |key|. Here, |entryA| "standing in place of" <var ignore>entryB</var> means that they occupy the same "slot" within the joint session history, but only |entryA| is included because it most recently became the [=session history/current entry=] of its [=session history=].
522
+
1. Let |navigable| be |appHistory|'s [=relevant global object=]'s [=associated Document=]'s navigable.
513
523
514
-
<p class="issue">This imprecise phrasing will go away when the great session history overhaul documented in <a href="https://github.com/whatwg/html/issues/5767">whatwg/html#5767</a> is completed and we have a clear inventory of all [=session history entries=] in each slot in the <a spec="HTML">joint session history</a>.
524
+
1. Let |traversable| be |navigable|'s [=navigable/traversable navigable=].
515
525
516
-
1. [=Assert=]: exactly one such entry must exist.
526
+
1. Let |initiatorBC| be |appHistory|'s [=relevant global object=]'s [=Window/browsing context=].
517
527
518
-
1. If |appHistory|'s [=relevant global object=]'s [=Window/browsing context=] is not <a spec="HTML">allowed to navigate</a> any of the browsing contexts which would be navigated by traversing to |destinationIndex|, then return [=a promise rejected with=] a "{{SecurityError}}" {{DOMException}}.
528
+
1. Let |promise| be [=a new promise=] created in |appHistory|'s [=relevant Realm=].
519
529
520
-
<p class="issue">This is super-vague. And probably cannot be determined synchronously. Revisit this after <a href="https://github.com/whatwg/html/issues/5767">whatwg/html#5767</a>.
530
+
1. [=parallel queue/Enqueue the following steps=] on |traversable|'s [=traversable navigable/session history traversal queue=]:
521
531
522
-
1. Let |navigateInfo| be |options|["{{AppHistoryNavigationOptions/navigateInfo}}"] if it [=map/exists=], or undefined otherwise.
532
+
1. Let |navigableEntries| be the result of [=navigable/getting the session history entries=] given |navigable|.
533
+
534
+
1. Let |targetEntry| be the [=session history entry=] in |navigableEntries| whose [=session history entry/app history key=] equals |key|. If no such entry exists, then:
535
+
536
+
1. [=Reject=] |promise| with an "{{InvalidStateError}}" {{DOMException}}.
537
+
538
+
1. Abort these steps.
523
539
524
-
1. <a spec="HTML">Traverse the history by a delta</a> given |destinationIndex| − |currentEntryIndex| and |appHistory|'s [=relevant global object=]'s [=Window/browsing context=], with <i>[=traverse the history by a delta/appHistoryInfo=]</i> set to |navigateInfo|.
540
+
<p class="note">This can occur if the |appHistory| object's view of session history is outdated, which can happen for brief periods while all the relevant threads and processes are being synchronized in reaction to a history change (such as the user clearing their history).
541
+
542
+
1. Assert: |targetEntry| is not |navigable|'s [=navigable/current session history entry=].
543
+
544
+
1. Let |targetStep| be |targetEntry|'s [=session history entry/step=].
545
+
546
+
1. [=Apply the history step=] |targetStep| to |traversable|, with <i>[=apply the history step/checkForUserCancelation=]</i> set to true, <i>[=apply the history step/initiatorToCheck=]</i> set to |initiatorBC|, and <i>[=apply the history step/appHistoryInfo=]</i> set to |navigateInfo|.
547
+
548
+
- If this aborts due to user-canceled unloading, then [=reject=] |promise| with an "{{AbortError}}" {{DOMException}}.
549
+
550
+
- If this aborts due to the initiator allowed-to-navigate check, then [=reject=] |promise| with a "{{SecurityError}}" {{DOMException}}.
551
+
552
+
- TODO: deal with another traversal aborting this one. (The HTML spec PR doesn't support this yet.) Should result in "{{AbortError}}" {{DOMException}}.
553
+
554
+
<p class="advisement">Eventually [=apply the history step=] will have well-specified hooks for communicating these conditions back to its caller.</p>
555
+
556
+
TODO: this doesn't deal with the navigate event...
525
557
</div>
526
558
527
559
<h3 id="global-events">Event handlers</h3>
@@ -1077,6 +1109,8 @@ With the above infrastructure in place, we can actually fire and handle the {{Ap
1077
1109
1. If either |isSameDocument| is true or |userInvolvement| is not "<code>[=user navigation involvement/browser UI=]</code>", then:
1078
1110
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|, <i>[=fire a traversal navigate event/userInvolvement=]</i> set to |userInvolvement|, and <i>[=fire a traversal navigate event/info=]</i> set to |appHistoryInfo|.
1079
1111
1. If |continue| is false, abort these steps.
1112
+
1113
+
<p class="advisement">The <a href="https://github.com/whatwg/html/pull/6315">session history rewrite pull request</a> will largely replace the above algorithm with [=apply the history step=].
0 commit comments