diff --git a/index.bs b/index.bs index a2d9f56d..75e2cbad 100644 --- a/index.bs +++ b/index.bs @@ -186,6 +186,7 @@ spec: HTML; urlPrefix: https://html.spec.whatwg.org/multipage/ text: set up a worker environment settings object; url: workers.html#set-up-a-worker-environment-settings-object text: set up a worklet environment settings object; url: worklets.html#set-up-a-worklet-environment-settings-object text: shared worker; url: workers.html#shared-workers + text: traverse the history by a delta; url: browsing-the-web.html#traverse-the-history-by-a-delta text: window open steps; url: window-object.html#window-open-steps text: worker event loop; url: webappapis.html#worker-event-loop-2 text: worklet global scopes; url:worklets.html#concept-document-worklet-global-scopes @@ -1852,6 +1853,7 @@ BrowsingContextCommand = ( browsingContext.Print // browsingContext.Reload // browsingContext.SetViewport + browsingContext.TraverseHistory ) @@ -1864,6 +1866,7 @@ BrowsingContextResult = ( browsingContext.GetTreeResult // browsingContext.NavigateResult // browsingContext.PrintResult + browsingContext.TraverseHistoryResult ) BrowsingContextEvent = ( @@ -3062,6 +3065,146 @@ The [=remote end steps=] with |command parameters| are: +#### The browsingContext.traverseHistory Command #### {#command-browsingContext-traverseHistory} + +The browsingContext.traverseHistory command +traverses the history of a given context by a delta. + +
+ BrowsingContext.TraverseHistory = { + method: "browsingContext.traverseHistory", + params: browsingContext.TraverseHistoryParameters + } + + browsingContext.TraverseHistoryParameters = { + context: browsingContext.BrowsingContext, + delta: int, + ? wait: browsingContext.ReadinessState, + } ++
+ browsingContext.TraverseHistoryResult = { + navigation: browsingContext.Navigation / null, + ?persisted: bool + url: text, + } ++
context
"]|.
+
+1. Assert: |browsing context| is not null.
+
+1. Let |navigable| be the [=/navigable=] whose [=navigable/active
+ document=] is |browsing context|'s [=browsing context/active document=].
+
+1. Let |delta| be |command parameters|["delta
"].
+
+1. If |command parameters| [=map/contains=] "wait
, let |wait
+ condition| be |command parameters|["wait
"]. Otherwise let |wait
+ condition| be "none
".
+
+1. Let |navigation id| be the string representation of a
+ [[!RFC4122|UUID]] based on truly random, or pseudo-random numbers.
+
+1. [=Traverse the history by a delta=] given |delta|, |navigable|, and
+ |navigation id|.
+
+1. Let (|event received|, |navigate status|) be [=await=] given
+ «"navigation started
", "navigation failed
",
+ "fragment navigated
", "pop state
"», and
+ |navigation id|.
+
+1. Assert: |navigate status|'s id is |navigation id|.
+
+1. If |navigate status|'s status is "complete
":
+
+ 1. Let |body| be a [=/map=] matching the
+ browsingContext.TraverseHistoryResult
production, with the
+ navigation
field set to |navigation id|, and the
+ url
field set to the result of the [=URL serializer=] given
+ |navigate status|'s url.
+
+ 1. Return [=success=] with data |body|.
+
+1. If |navigate status|'s status is "canceled
" return [=error=]
+ with [=error code=] [=unknown error=].
+
+1. Assert: |navigate status|'s status is "pending
" and
+ |navigation id| is not null.
+
+1. If |wait condition| is "none
":
+
+ 1. Let |body| be a [=/map=] matching the
+ browsingContext.TraverseHistoryResult
production, with the
+ navigation
field set to |navigation id|, and the
+ url
field set to the result of the [=URL serializer=] given
+ |navigate status|'s url.
+
+1. If |wait condition| is "interactive
", let |event name| be
+ "domContentLoaded
", otherwise let |event name| be
+ "load
".
+
+1. Let (|event received|, |status|) be [=await=] given «|event name|,
+ "download started
", "navigation aborted
",
+ "navigation failed
", "page show
"», and |navigation
+ id|.
+
+1. If |event received| is "navigation failed
"
+ return [=error=] with [=error code=] [=unknown error=].
+
+1. If event received is "page show
", let |persisted| be true,
+ otherwise let |persisted| be false.
+
+1. Let |body| be a [=/map=] matching the
+ browsingContext.TraverseHistoryResult
production, with the
+ navigation
field set to |status|'s id, the
+ persisted
field set to |persisted|, and the url
+ field set to the result of the [=URL serializer=] given |status|'s url.
+
+1. Return [=success=] with data |body|.
+
+page show
", |navigation id|, and
+ |navigation status|.
+
+pop state
", |navigation id|, and
+ |navigation status|.
+
+