src/domains/dom

Search:
Group by:

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: [].}

DOM.describeNode

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: [].}

DOM.disable

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: [].}

DOM.enable

Enables the DOM agent for the given page.

proc focus(tab: Tab): owned(Future[void]) {....stackTrace: false,
    raises: [Exception],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
proc focus(tab: Tab; params: JsonNode): owned(Future[void]) {....stackTrace: false,
    raises: [Exception],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}

DOM.focus

Focuses the given element.

proc getAttributes(tab: Tab; nodeId: string): Future[JsonNode] {.
    ...stackTrace: false, raises: [Exception, ValueError],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}

DOM.getAttributes

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: [].}

DOM.getBoxModel

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: [].}

DOM.getDocument

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: [].}

DOM.getNodeForLocation

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: [].}

DOM.getOuterHTML

Returns node's HTML markup.

proc hideHighlight(tab: Tab): owned(Future[void]) {....stackTrace: false,
    raises: [Exception],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}

DOM.hideHighlight

Hides any highlight.

proc highlightNode(tab: Tab): owned(Future[void]) {....stackTrace: false,
    raises: [Exception],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}

DOM.highlightNode

Highlights DOM node.

proc highlightRect(tab: Tab): owned(Future[void]) {....stackTrace: false,
    raises: [Exception],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}

DOM.highlightRect

Highlights given rectangle.

proc moveTo(tab: Tab; nodeId, targetNodeId: string): Future[JsonNode] {.
    ...stackTrace: false, raises: [Exception, ValueError],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
proc moveTo(tab: Tab; nodeId, targetNodeId: string; params: JsonNode): Future[
    JsonNode] {....stackTrace: false, raises: [Exception, ValueError],
                tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect],
                forbids: [].}

DOM.moveTo

Moves node into the new container, places it before the given anchor.

proc querySelector(tab: Tab; nodeId, selector: string): Future[JsonNode] {.
    ...stackTrace: false, raises: [Exception, ValueError],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}

DOM.querySelector

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: [].}

DOM.querySelectorAll

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: [].}

DOM.removeAttribute

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: [].}

DOM.removeNode

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: [].}

DOM.requestChildNodes

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: [].}

DOM.requestNode

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: [].}

DOM.resolveNode

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: [].}

DOM.scrollIntoViewIfNeeded

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: [].}

DOM.setAttributesAsText

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: [].}

DOM.setAttributeValue

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: [].}

DOM.setFileInputFiles

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: [].}

DOM.setNodeName

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: [].}

DOM.setNodeValue

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: [].}

DOM.setOuterHTML

Sets node HTML markup, returns new node id.