diff --git a/index.bs b/index.bs index f2f80845..e3edae4c 100644 --- a/index.bs +++ b/index.bs @@ -63,6 +63,7 @@ spec: WEBDRIVER; urlPrefix: https://w3c.github.io/webdriver/ text: input cancel list; url: dfn-input-cancel-list text: intermediary node; url: dfn-intermediary-node text: invalid argument; url: dfn-invalid-argument + text: invalid selector; url: dfn-invalid-selector text: invalid session id; url: dfn-invalid-session-id text: is element origin; url: dfn-is-element-origin text: local end; url: dfn-local-ends @@ -145,6 +146,7 @@ spec: ECMASCRIPT; urlPrefix: https://tc39.es/ecma262/ text: realm; url: sec-code-realms text: running execution context; url: running-execution-context text: throw completion; url: sec-completion-record-specification-type + text: test; url: #sec-regexp.prototype.test text: time value; url: sec-time-values-and-time-range text: undefined; url: sec-undefined-value spec: GEOMETRY; urlPrefix: https://drafts.fxtf.org/geometry/ @@ -177,6 +179,7 @@ spec: HTML; urlPrefix: https://html.spec.whatwg.org/multipage/ text: handled; url: webappapis.html#concept-error-handled text: hidden; url: document-sequences.html#system-visibility-state text: history handling behavior; url: browsing-the-web.html#history-handling-behavior + text: innerText getter steps; url:dom.html#dom-innertext text: navigables; url: document-sequences.html#navigables text: navigation id; url: browsing-the-web.html#navigation-id text: origin-clean; url: canvas.html#concept-canvas-origin-clean @@ -221,7 +224,24 @@ spec: CSSOM-VIEW; urlPrefix: https://drafts.csswg.org/cssom-view/ text: visual viewport; url: #visual-viewport spec: DOM; urlPrefix: https://dom.spec.whatwg.org/ type: dfn + text: root; url: #concept-tree-root text: document element; url: #ref-for-dom-document-documentelement + text: evaluate; url: #dom-xpathevaluatorbase-evaluate + text: ORDERED_NODE_SNAPSHOT_TYPE; url: #dom-xpathresult-ordered_node_snapshot_type + text: snapshotItem; url: #dom-xpathresult-snapshotitem +spec: SELECTORS4; urlPrefix: https://drafts.csswg.org/selectors-4/ + type: dfn + text: match a selector against a tree; url: #match-a-selector-against-a-tree + text: parse a selector; url: #parse-a-selector + text: scoping root; url: #scoping-root +spec: WEB-IDL; urlPrefix: https://webidl.spec.whatwg.org/ + type: dfn + text: DOMException; url: #idl-DOMException + text: SyntaxError; url:#syntaxerror +spec: UNICODE; urlPrefix: https://www.unicode.org/versions/Unicode15.0.0/ + type: dfn + text: Unicode Default Case Conversion algorithm; url: ch03.pdf#G34944 + text: toUppercase; url: ch03.pdf#G34078
@@ -1848,6 +1868,7 @@ BrowsingContextCommand = ( browsingContext.Create // browsingContext.GetTree // browsingContext.HandleUserPrompt // + browsingContext.LocateNodes // browsingContext.Navigate // browsingContext.Print // browsingContext.Reload // @@ -1862,6 +1883,7 @@ BrowsingContextResult = ( browsingContext.CaptureScreenshotResult / browsingContext.CreateResult / browsingContext.GetTreeResult / + browsingContext.LocateNodesResult / browsingContext.NavigateResult / browsingContext.PrintResult ) @@ -2098,6 +2120,39 @@ To await a navigation given |context|, |request|, |wait condition|, a +#### The browsingContext.Locator Type #### {#type-browsingContext-Locator} + +[=remote end definition=] and [=local end definition=] + ++browsingContext.Locator = ( + browsingContext.CssLocator / + browsingContext.InnerTextLocator / + browsingContext.XPathLocator +) + +browsingContext.CssLocator = { + type: "css", + value: text +} + +browsingContext.InnerTextLocator = { + type: "innerText", + value: text, + ? ignoreCase: bool + ? matchType: "full" / "partial", + ? maxDepth: js-uint, +} + +browsingContext.XPathLocator = { + type: "xpath", + value: text +} ++ +ThebrowsingContext.Locator
type provides details on the strategy +for locating a node in a document. + #### The browsingContext.Navigation Type #### {#type-browsingContext-Navigation} [=remote end definition=] and [=local end definition=] @@ -2778,6 +2833,279 @@ The [=remote end steps=] with session and |command parameters| 1. Return [=success=] with data null. + +#### The browsingContext.locateNodes Command #### {#command-browsingContext-locateNodes} + +The browsingContext.locateNodes command returns a +list of all nodes matching the specified locator. + +
+ browsingContext.LocateNodes = ( + method: "browsingContext.locateNodes", + params: browsingContext.LocateNodesParameters + ) + + browsingContext.LocateNodesParameters = { + context: browsingContext.BrowsingContext, + locator: browsingContext.Locator, + ? maxNodeCount: (js-uint .ge 1), + ? ownership: script.ResultOwnership, + ? sandbox: text, + ? serializationOptions: script.SerializationOptions, + ? startNodes: [ + script.SharedReference ] + } ++
+ browsingContext.LocateNodesResult = { + nodes: [ * script.NodeRemoteValue ] + } ++
snapshotLength
property
+ from |evaluate result|.
+
+ 1. Repeat, while |index| is less than |length|:
+
+ 1. Let |node| be the result of calling [=snapshotItem=] with |evaluate result|
+ as this and |index| as the argument.
+
+ 1. [=list/Append=] |node| to |returned nodes|.
+
+ 1. If |maximum returned node count| not null and [=list/size=] of
+ |returned nodes| is equal to |maximum returned node count|,
+ return |returned nodes|.
+
+ 1. Set |index| to |index| + 1.
+
+1. Return |returned nodes|.
+
+"full"
and |node text| [=is=] |search text|,
+ [=list/append=] |context node| to |returned nodes|.
+
+ 1. Otherwise, [=list/append=] |context node| to |returned nodes|.
+
+ 1. Otherwise, perform the following steps:
+
+ 1. Set |max depth| to |max depth| - 1.
+
+ 1. Let |child node matches| be the result of [=locate nodes using inner text=]
+ with |context target|, |child nodes|, |selector|, |max depth|,
+ |match type|, |ignore case|, |maximum returned node count|, and |session|.
+
+ 1. If [=list/size=] of |child node matches| is equal to 0 and |match type| is
+ "partial"
, append |context node| to |returned nodes|. Otherwise,
+ [=list/extend=] |returned nodes| with |child node matches|.
+
+1. If |maximum returned node count| is not null, [=list/remove=] all entries
+ in |returned nodes| with an index greater than or equal to |maximum returned
+ node count|.
+
+1. Return |returned nodes|.
+
+context
"].
+
+1. Let |context| be the result of [=trying=] to [=get a browsing context=]
+ with |context id|.
+
+1. Assert: |context| is not null.
+
+1. If |command parameters| [=map/contains=] "sandbox
", let
+ |sandbox| be |command parameters|["sandbox
"]. Otherwise,
+ let |sandbox| be null.
+
+1. Let |current context target| be the a [=/map=] matching of the
+ script.ContextTarget
production with the
+ context
field set to the [=browsing context id=]
+ of |context| and the sandbox
field set to |sandbox|.
+
+1. Let |realm| be the result of [=trying=] to [=get a realm from a target=]
+ given |current context target|.
+
+1. Let |locator| be |command parameters|["locator
"].
+
+1. If |command parameters| [=map/contains=] "startNodes
", let
+ |start nodes parameter| be |command parameters|["startNodes
"].
+ Otherwise let |start nodes parameter| be null.
+
+1. If |command parameters| [=map/contains=] "maxNodeCount
", let
+ |maximum returned node count| be |command parameters|["maxNodeCount
"].
+ Otherwise, let |maximum returned node count| be null.
+
+1. Let |context nodes| be an empty [=/list=].
+
+1. If |start nodes parameter| is null, [=list/append=] the [=document element=]
+ of |context|'s [=active document=] to |context nodes|. Otherwise, for each
+ |serialized start node| in |start nodes parameter|:
+
+ 1. Let |start node| be the result of [=trying=] to [=deserialize shared reference=] given
+ |serialized start node|, |realm| and |session|.
+
+ 1. [=list/Append=] |start node| to |context nodes|.
+
+1. Assert [=list/size=] of |context nodes| is greater than 0.
+
+1. Let |type| be |locator|["type
"].
+
+1. In the following list of conditions and associated steps, run the first set
+ of steps for which the associated condition is true:
+
+ css
"
+ value
"].
+
+ 1. Let |result nodes| be a result of [=trying=] to [=locate nodes using css=]
+ given |current context target|, |context nodes|, |selector|, |maximum returned
+ nodes| and |session|.
+
+ xpath
"
+ value
"].
+
+ 1. Let |result nodes| be a result of [=trying=] to [=locate nodes using xpath=]
+ given |current context target|, |context nodes|, |selector|, |maximum returned
+ nodes| and |session|.
+
+ innerText
"
+ value
"].
+
+ 1. If |locator| [=map/contains=] maxDepth
, let |max depth| be
+ |locator|["maxDepth
"]. Otherwise, let |max depth| be null.
+
+ 1. If |locator| [=map/contains=] ignoreCase
, let |ignore case| be
+ |locator|["ignoreCase
"]. Otherwise, let |ignore case| be false.
+
+ 1. If |locator| [=map/contains=] matchType
, let |match type| be
+ |locator|["matchType
"]. Otherwise, let |match type| be "full".
+
+ 1. Let |result nodes| be a result of [=trying=] to [=locate nodes using inner text=]
+ given |current context target|, |context nodes|, |selector|, |max depth|,
+ |match type|, |ignore case|, |maximum returned node count| and |session|.
+
+1. Assert: |maximum returned node count| is null or [=list/size=] of |result nodes| is less
+ than or equal to |maximum returned node count|.
+
+1. If |command parameters| [=map/contains=] "serializationOptions
",
+ let |serialization options| be |command parameters|["serializationOptions
"].
+ Otherwise, let |serialization options| be a [=/map=] matching the
+ script.SerializationOptions
production with the fields
+ set to their default values.
+
+1. If |command parameters| [=map/contains=] "ownership
",
+ let |result ownership| be |command parameters|["ownership
"].
+ Otherwise, let |result ownership| be "none".
+
+1. Let |serialized nodes| be the result of [=serialize as a remote value=] with
+ |result nodes|, |serialization options|, |result ownership|, a new [=/map=]
+ as serialization internal map, |realm| and |session|.
+
+1. Let |result| be a [=/map=] matching the browsingContext.LocateNodesResult
+ production, with the nodes
field set |serialized nodes|.
+
+1. Return [=success=] with data |result|.
+