Skip to content

Commit abcc6b6

Browse files
committed
Some updates... navigate event still pretty borked
1 parent 5ba5673 commit abcc6b6

File tree

1 file changed

+45
-11
lines changed

1 file changed

+45
-11
lines changed

spec.bs

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ spec: html; urlPrefix: https://html.spec.whatwg.org/multipage/
4747
text: exceptionsEnabled; url: browsing-the-web.html#exceptions-enabled
4848
type: method
4949
for: Document; text: open(unused1, unused2); url: multipage/dynamic-markup-insertion.html#dom-document-open
50+
spec: html; urlPrefix: https://whatpr.org/html/6315/
51+
type: dfn
52+
text: traversable navigable; for: navigable; url: history.html#nav-traversable
53+
text: current session history entry; for: navigable; url: history.html#nav-current-history-entry
54+
text: get the session history entries; for: navigable; url: history.html#getting-session-history-entries
55+
text: session history traversal queue; for: traversable navigable; url: history.html#tn-session-history-traversal-queue
56+
text: step; for: session history entry; url: history.html#she-step
57+
text: apply the history step; url: history.html#apply-the-history-step
58+
text: checkForUserCancelation; for: apply the history step; url: history.html#apply-the-history-step
59+
text: initiatorToCheck; for: apply the history step; url: history.html#apply-the-history-step
5060
spec: uuid; type: dfn; urlPrefix: https://wicg.github.io/uuid/
5161
text: generate a random UUID; url: #dfn-generate-a-random-uuid
5262
</pre>
@@ -471,8 +481,6 @@ Each {{AppHistory}} object has an associated <dfn for="AppHistory">navigate meth
471481

472482
1. If [=this=]'s [=AppHistory/current index=] is &minus;1, then return [=a promise rejected with=] an "{{InvalidStateError}}" {{DOMException}}.
473483

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-
476484
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}}.
477485

478486
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
499507
</div>
500508

501509
<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+
502512
To <dfn>perform an app history traversal</dfn> given an {{AppHistory}} object |appHistory|, a string |key|, and an {{AppHistoryNavigationOptions}} |options|:
503513

504514
1. If |appHistory|'s [=relevant global object=]'s [=associated Document=] is not [=Document/fully active=], then return [=a promise rejected with=] an "{{InvalidStateError}}" {{DOMException}}.
505515

506516
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}}.
507517

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.
509519

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.
511521

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.
513523

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=].
515525

516-
1. [=Assert=]: exactly one such entry must exist.
526+
1. Let |initiatorBC| be |appHistory|'s [=relevant global object=]'s [=Window/browsing context=].
517527

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=].
519529

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=]:
521531

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.
523539

524-
1. <a spec="HTML">Traverse the history by a delta</a> given |destinationIndex| &minus; |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...
525557
</div>
526558

527559
<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
10771109
1. If either |isSameDocument| is true or |userInvolvement| is not "<code>[=user navigation involvement/browser UI=]</code>", then:
10781110
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|.
10791111
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=].
10801114
</div>
10811115

10821116
<div algorithm>

0 commit comments

Comments
 (0)