This module provides a direct mapping of CDP events and commands for v1.3 (stable) of the DOM Domain.
The DOM Domain exposes DOM read/write operations. Each DOM Node is represented with its mirror object that has an id. This id can be used to get additional information on the Node, resolve it into the JavaScript object wrapper, etc. It is important that client receives DOM events only for the nodes that are known to the client.
Backend keeps track of the nodes that were sent to the client and never sends the same node twice. It is client's responsibility to collect information about the nodes that were sent to the client. Note that iframe owner elements will return corresponding document elements as their child nodes.
Types
DOM {.pure.} = enum attributeModified = "DOM.attributeModified", attributeRemoved = "DOM.attributeRemoved", characterDataModified = "DOM.characterDataModified", childNodeCountUpdated = "DOM.childNodeCountUpdated", childNodeInserted = "DOM.childNodeInserted", childNodeRemoved = "DOM.childNodeRemoved", documentUpdated = "DOM.documentUpdated", setChildNodes = "DOM.setChildNodes"
- DOM Domain events
Procs
proc describeNode(tab: Tab): Future[JsonNode] {....stackTrace: false, raises: [Exception, ValueError], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
proc describeNode(tab: Tab; params: JsonNode): Future[JsonNode] {. ...stackTrace: false, raises: [Exception, ValueError], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
Describes node given its id, does not require domain to be enabled. Does not start tracking any objects, can be used for automation.
proc disableDOMDomain(tab: Tab): owned(Future[void]) {....stackTrace: false, raises: [Exception], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
Disables the DOM agent for the given page.
proc enableDOMDomain(tab: Tab): owned(Future[void]) {....stackTrace: false, raises: [Exception], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
proc enableDOMDomain(tab: Tab; params: JsonNode): owned(Future[void]) {. ...stackTrace: false, raises: [Exception], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
Enables the DOM agent for the given page.
proc getAttributes(tab: Tab; nodeId: string): Future[JsonNode] {. ...stackTrace: false, raises: [Exception, ValueError], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
Returns attributes for the specified node.
proc getBoxModel(tab: Tab): Future[JsonNode] {....stackTrace: false, raises: [Exception, ValueError], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
proc getBoxModel(tab: Tab; params: JsonNode): Future[JsonNode] {. ...stackTrace: false, raises: [Exception, ValueError], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
Returns boxes for the given node.
proc getDocument(tab: Tab): Future[JsonNode] {....stackTrace: false, raises: [Exception, ValueError], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
proc getDocument(tab: Tab; params: JsonNode): Future[JsonNode] {. ...stackTrace: false, raises: [Exception, ValueError], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
Returns the root DOM node (and optionally the subtree) to the caller. Implicitly enables the DOM domain events for the current target.
proc getNodeForLocation(tab: Tab; x, y: int): Future[JsonNode] {. ...stackTrace: false, raises: [Exception, ValueError], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
proc getNodeForLocation(tab: Tab; x, y: int; params: JsonNode): Future[JsonNode] {. ...stackTrace: false, raises: [Exception, ValueError], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
Returns node id at given location. Depending on whether DOM domain is enabled, nodeId is either returned or not.
proc getOuterHTML(tab: Tab): Future[JsonNode] {....stackTrace: false, raises: [Exception, ValueError], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
proc getOuterHTML(tab: Tab; params: JsonNode): Future[JsonNode] {. ...stackTrace: false, raises: [Exception, ValueError], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
Returns node's HTML markup.
proc hideHighlight(tab: Tab): owned(Future[void]) {....stackTrace: false, raises: [Exception], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
Hides any highlight.
proc highlightNode(tab: Tab): owned(Future[void]) {....stackTrace: false, raises: [Exception], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
Highlights DOM node.
proc highlightRect(tab: Tab): owned(Future[void]) {....stackTrace: false, raises: [Exception], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
Highlights given rectangle.
proc moveTo(tab: Tab; nodeId, targetNodeId: string): Future[JsonNode] {. ...stackTrace: false, raises: [Exception, ValueError], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
proc querySelector(tab: Tab; nodeId, selector: string): Future[JsonNode] {. ...stackTrace: false, raises: [Exception, ValueError], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
Executes querySelector on a given node.
proc querySelectorAll(tab: Tab; nodeId, selector: string): Future[JsonNode] {. ...stackTrace: false, raises: [Exception, ValueError], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
Executes querySelectorAll on a given node.
proc removeAttribute(tab: Tab; nodeId, name: string): owned(Future[void]) {. ...stackTrace: false, raises: [Exception], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
Removes attribute with given name from an element with given id.
proc removeNode(tab: Tab; nodeId: string): owned(Future[void]) {. ...stackTrace: false, raises: [Exception], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
Removes node with given id.
proc requestChildNodes(tab: Tab; nodeId: string): owned(Future[void]) {. ...stackTrace: false, raises: [Exception], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
proc requestChildNodes(tab: Tab; nodeId: string; params: JsonNode): owned( Future[void]) {....stackTrace: false, raises: [Exception], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
Requests that children of the node with given id are returned to the caller in form of setChildNodes events where not only immediate children are retrieved, but all children down to the specified depth.
proc requestNode(tab: Tab; objectId: string): Future[JsonNode] {. ...stackTrace: false, raises: [Exception, ValueError], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
Requests that the node is sent to the caller given the JavaScript node object reference. All nodes that form the path from the node to the root are also sent to the client as a series of setChildNodes notifications.
proc resolveNode(tab: Tab; params: JsonNode): Future[JsonNode] {. ...stackTrace: false, raises: [Exception, ValueError], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
Resolves the JavaScript node object for a given NodeId or BackendNodeId.
proc scrollIntoViewIfNeeded(tab: Tab; params: JsonNode): owned(Future[void]) {. ...stackTrace: false, raises: [Exception], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
Scrolls the specified rect of the given node into view if not already visible. Note: exactly one between nodeId, backendNodeId and objectId should be passed to identify the node.
proc setAttributesAsText(tab: Tab; nodeId, text: string): owned(Future[void]) {. ...stackTrace: false, raises: [Exception], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
proc setAttributesAsText(tab: Tab; nodeId, text: string; params: JsonNode): owned( Future[void]) {....stackTrace: false, raises: [Exception], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
Sets attributes on element with given id. This method is useful when user edits some existing attribute value and types in several attribute name/value pairs.
proc setAttributeValue(tab: Tab; nodeId, name, value: string): owned( Future[void]) {....stackTrace: false, raises: [Exception], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
Sets attribute for an element with given id.
proc setFileInputFiles(tab: Tab; files: seq[string]): owned(Future[void]) {. ...stackTrace: false, raises: [Exception], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
proc setFileInputFiles(tab: Tab; files: seq[string]; params: JsonNode): owned( Future[void]) {....stackTrace: false, raises: [Exception], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
Sets files for the given file input element.
proc setNodeName(tab: Tab; nodeId, name: string): Future[JsonNode] {. ...stackTrace: false, raises: [Exception, ValueError], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
Sets node name for a node with given id.
proc setNodeValue(tab: Tab; nodeId, value: string): owned(Future[void]) {. ...stackTrace: false, raises: [Exception], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
Sets node value for a node with given id.
proc setOuterHTML(tab: Tab; nodeId, outerHTML: string): owned(Future[void]) {. ...stackTrace: false, raises: [Exception], tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
-
Sets node HTML markup, returns new node id.