diff --git a/index.bs b/index.bs index cfc38bd4..63eb447d 100644 --- a/index.bs +++ b/index.bs @@ -45,6 +45,7 @@ spec: WEBDRIVER; urlPrefix: https://w3c.github.io/webdriver/ text: intermediary node; url: dfn-intermediary-node text: invalid argument; url: dfn-invalid-argument text: unknown command; url: dfn-unknown-command + text: unknown error; url: dfn-unknown-error text: no such element; url: dfn-no-such-element text: no such frame; url: dfn-no-such-frame text: active sessions; url: dfn-active-session @@ -100,6 +101,7 @@ spec: HTML; urlPrefix: https://html.spec.whatwg.org/ text: create a new browsing context; url: creating-a-new-browsing-context text: environment settings object's Realm; url: environment-settings-object's-realm text: handled; url: concept-error-handled + text: navigation id; url: concept-navigation-id text: report an error; url: report-the-error text: remove a browsing context; url: bcg-remove text: session history; url: session-history @@ -130,6 +132,45 @@ This specification depends on the Infra Standard. [[!INFRA]] Network protocol messages are defined using CDDL. [[!RFC8610]] +This specification defines a wait queue which is a map. + +Issue: Surely there's a better mechanism for doing this "wait for an event" thing. + +
canceled
",
+ "pending
", or
+ "complete
".
+ -BrowsingContextCommand = (BrowsingContextGetTreeCommand) +BrowsingContextCommand = ( + BrowsingContextGetTreeCommand // + BrowsingContextNavigateCommand +)[=local end definition=]
-BrowsingContextResult = (BrowsingContextGetTreeResult) +BrowsingContextResult = ( + BrowsingContextGetTreeResult // + BrowsingContextNavigateResult +) BrowsingContextEvent = ( BrowsingContextCreatedEvent // - BrowsingContextDestroyedEvent + BrowsingContextDestroyedEvent // + BrowsingContextNavigationStartedEvent // + BrowsingContextFragmentNavigatedEvent // + BrowsingContextDomContentLoadedEvent // + BrowsingContextLoadEvent // + BrowsingContextDownloadWillBegin // + BrowsingContextNavigationAbortedEvent // + BrowsingContextNavigationFailedEvent )@@ -1703,7 +1776,8 @@ BrowsingContextInfo = { The
BrowsingContextInfo
type represents the properties of a
browsing context.
-+Navigation = text; ++ +The
Navigation
type is a unique string identifying an ongoing
+navigation.
+
+TODO: Link to the definition in the HTML spec.
+
+
+#### The browsingContext.NavigationInfo Type #### {#type-browsingContext-NavigationInfo}
+
+[=local end definition=]:
+
++NavigationInfo = { + context: BrowsingContext, + navigation: Navigation / null, + url: text, +} ++ +The
NavigationInfo
type provides details of an ongoing navigation.
+
+NavigationInfo
production, with the
+ context
field set to |context id|, the navigation
+ field set to |navigation id|, and the url
field set to the
+ result of the [=URL serializer=] given |url|.
+
++ BrowsingContextNavigateCommand = { + method: "browsingContext.navigate", + params: BrowsingContextNavigateParameters + } + + BrowsingContextNavigateParameters = { + context: BrowsingContext, + url: text, + ?wait: ReadinessState, + } + + ReadinessState = "none" / "interactive" / "complete" ++
+ BrowsingContextNavigateResult = { + navigation: Navigation / null, + url: text, + } ++
context
field of
+ |command parameters|.
+
+ 1. Let |context| be the result of [=trying=] to [=get a browsing context=]
+ with |context id|.
+
+ 1. Assert: |context| is not null.
+
+ 1. Let |wait condition| be the value of the wait
field of |command
+ parameters| if present, or "none
" otherwise.
+
+ 1. Let |url| be the value of the url
field of |command
+ parameters|.
+
+ 1. Let |document| be |context|'s [=active document=].
+
+ 1. Let |base| be |document|'s [=base URL=].
+
+ 1. Let |url record| be the result of applying the [=URL parser=] to |url|,
+ with [=base URL=] |base|.
+
+ 1. If |url record| is failure, return [=error=] with [=error code=] [=invalid
+ argument=].
+
+ 1. Let |request| be a new [=/request=] whose URL is |url record|.
+
+ 1. Let |navigation id| be the string representation of a
+ [[!RFC4122|UUID]] based on truly random, or pseudo-random numbers.
+
+ 1. [=Navigate=] |context| with resource |request|, and using |context| as the
+ [=source browsing context=], and with navigation id |navigation id|.
+
+ 1. Let (|event received|, |navigate status|) be [=await=] given
+ «"navigation started
", "navigation failed
",
+ and "fragment navigated
"» 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
+ BrowsingContextNavigateResult
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|, and then run the following steps [=in
+ parallel=]:
+
+ 1. Run the [=WebDriver-BiDi fragment navigated=] steps given |context|
+ and |navigate status|
+
+ Note: this is the case if the navigation only caused the fragment to
+ change. The parallel steps here ensure that we return the command result
+ before emitting the event, so the navigation id is known.
+
+ 1. If |navigate status|'s status is "canceled
" return [=error=]
+ with [=error code=] [=unknown error=].
+
+ TODO: is this the right way to handle errors here?
+
+ 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
+ BrowsingContextNavigateResult
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|, and then run the following steps [=in
+ parallel=]:
+
+ 1. Run the [=WebDriver-BiDi navigation started=] steps given |context|
+ and |navigate status|
+
+ 1. Run the [=WebDriver-BiDi navigation started=] steps given |context|
+ and |navigate status|
+
+ Note: this event was previously suppressed to ensure that it would come
+ after the command response in the case that |wait condition| is
+ "none
".
+
+ Issue: Replace this suppression mechanism with an event queue.
+
+ 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
"» and |navigation id|.
+
+ 1. If |event received| is "navigation failed
"
+ return [=error=] with [=error code=] [=unknown error=].
+
+ Issue: Are we surfacing enough information about what failed and why with
+ an error here? What error code do we want? Is there going to be a problem
+ where local ends parse the implementation-defined strings to figure out
+ what actually went wrong?
+
+ 1. Let |body| be a [=map=] matching the
+ BrowsingContextNavigateResult
production, with the
+ navigation
field set to |status|'s id, and the
+ url
field set to the result of the [=URL serializer=] given
+ |status|'s url.
+
+ 1. Return [=success=] with data |body|.
+
++ BrowsingContextNavigationStartedEvent = { + method: "browsingContext.navigationStarted", + params: NavigationInfo + } ++
BrowsingContextNavigationStarted
production, with the
+ params
field set to |params|.
+
+ 1. Let |navigation id| be |navigation status|'s id.
+
+ 1. Let |related browsing contexts| be a set containing |context|.
+
+ 1. [=Resume=] with "navigation started
", |navigation id|, and
+ |navigation status|.
+
+ 1. [=Emit an event=] with |body| and |related browsing contexts|.
+
++ BrowsingContextFragmentNavigatedEvent = { + method: "browsingContext.fragmentNavigated", + params: NavigationInfo + } ++
BrowsingContextFragmentNavigatedEvent
production, with the
+ params
field set to |params|.
+
+ 1. Let |navigation id| be |navigation status|'s id.
+
+ 1. Let |related browsing contexts| be a set containing |context|.
+
+ 1. [=Resume=] with "fragment navigated
", |navigation id|, and
+ |navigation status|.
+
+ 1. [=Emit an event=] with |body| and |related browsing contexts|.
+
++ BrowsingContextDomContentLoadedEvent = { + method: "browsingContext.domContentLoaded", + params: NavigationInfo + } ++
BrowsingContextDomContentLoadedEvent
production, with the
+ params
field set to |params|.
+
+ 1. Let |related browsing contexts| be a set containing |context|.
+
+ 1. Let |navigation id| be |navigation status|'s id.
+
+ 1. [=Resume=] with "domContentLoaded
", |navigation id|, and
+ |navigation status|.
+
+ 1. [=Emit an event=] with |body| and |related browsing contexts|.
+
++ BrowsingContextLoadEvent = { + method: "browsingContext.load", + params: NavigationInfo + } ++
BrowsingContextLoadEvent
+ production, with the params
field set to |params|.
+
+ 1. Let |related browsing contexts| be a set containing |context|.
+
+ 1. Let |navigation id| be |navigation status|'s id.
+
+ 1. [=Resume=] with "load
", |navigation id| and
+ |navigation status|.
+
+ 1. [=Emit an event=] with |body| and |related browsing contexts|.
+
++ BrowsingContextDownloadWillBegin = { + method: "browsingContext.downloadWillBegin", + params: NavigationInfo + } ++
BrowsingContextDownloadWillBegin
production, with the
+ params
field set to |params|.
+
+ 1. Let |navigation id| be |navigation status|'s id.
+
+ 1. Let |related browsing contexts| be a set containing |context|.
+
+ 1. [=Resume=] with "download started
", |navigation id|, and |navigation status|.
+
+ 1. [=Emit an event=] with |body| and |related browsing contexts|.
+
++ BrowsingContextNavigationAborted = { + method: "browsingContext.navigationAborted", + params: NavigationInfo + } ++
BrowsingContextNavigationAborted
production, with the
+ params
field set to |params|.
+
+ 1. Let |navigation id| be |navigation status|'s id.
+
+ 1. Let |related browsing contexts| be a set containing |context|.
+
+ 1. [=Resume=] with "navigation aborted
", |navigation id|, and |navigation status|.
+
+ 1. [=Emit an event=] with |body| and |related browsing contexts|.
+
++ BrowsingContextNavigationFailed = { + method: "browsingContext.navigationFailed", + params: NavigationInfo + } ++
BrowsingContextNavigationFailed
production, with the
+ params
field set to |params|.
+
+ 1. Let |navigation id| be |navigation status|'s id.
+
+ 1. Let |related browsing contexts| be a set containing |context|.
+
+ 1. [=Resume=] with "navigation failed
", |navigation id|, and |navigation status|.
+
+ 1. [=Emit an event=] with |body| and |related browsing contexts|.
+
+