You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 KiB

DOM

_Auto generated documentation for WebKit inspector

This 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.

Commands

DOM.getDocument(callback)

Returns the root DOM node to the caller.

Parameters

callback ( function )

Results

error ( error )
root ( Node )

Resulting node.

DOM.requestChildNodes(NodeId, [depth], callback)

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.

Parameters

nodeId ( NodeId )

Id of the node to get children for.

depth ( optional integer )

The maximum depth at which children should be retrieved, defaults to 1. Use -1 for the entire subtree or provide an integer larger than 0.

callback ( function )

Results

error ( error )

DOM.querySelector(NodeId, selector, callback)

Executes querySelector on a given node.

Parameters

nodeId ( NodeId )

Id of the node to query upon.

selector ( string )

Selector string.

callback ( function )

Results

error ( error )
nodeId ( NodeId )

Query selector result.

DOM.querySelectorAll(NodeId, selector, callback)

Executes querySelectorAll on a given node.

Parameters

nodeId ( NodeId )

Id of the node to query upon.

selector ( string )

Selector string.

callback ( function )

Results

error ( error )
nodeIds ( array of NodeId )

Query selector result.

DOM.setNodeName(NodeId, name, callback)

Sets node name for a node with given id.

Parameters

nodeId ( NodeId )

Id of the node to set name for.

name ( string )

New node's name.

callback ( function )

Results

error ( error )
nodeId ( NodeId )

New node's id.

DOM.setNodeValue(NodeId, value, callback)

Sets node value for a node with given id.

Parameters

nodeId ( NodeId )

Id of the node to set value for.

value ( string )

New node's value.

callback ( function )

Results

error ( error )

DOM.removeNode(NodeId, callback)

Removes node with given id.

Parameters

nodeId ( NodeId )

Id of the node to remove.

callback ( function )

Results

error ( error )

DOM.setAttributeValue(NodeId, name, value, callback)

Sets attribute for an element with given id.

Parameters

nodeId ( NodeId )

Id of the element to set attribute for.

name ( string )

Attribute name.

value ( string )

Attribute value.

callback ( function )

Results

error ( error )

DOM.setAttributesAsText(NodeId, text, [name], callback)

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.

Parameters

nodeId ( NodeId )

Id of the element to set attributes for.

text ( string )

Text with a number of attributes. Will parse this text using HTML parser.

name ( optional string )

Attribute name to replace with new attributes derived from text in case text parsed successfully.

callback ( function )

Results

error ( error )

DOM.removeAttribute(NodeId, name, callback)

Removes attribute with given name from an element with given id.

Parameters

nodeId ( NodeId )

Id of the element to remove attribute from.

name ( string )

Name of the attribute to remove.

callback ( function )

Results

error ( error )

DOM.getEventListenersForNode(NodeId, [objectGroup], callback)

Returns event listeners relevant to the node.

Parameters

nodeId ( NodeId )

Id of the node to get listeners for.

objectGroup ( optional string )

Symbolic group name for handler value. Handler value is not returned without this parameter specified.

callback ( function )

Results

error ( error )
listeners ( array of EventListener )

Array of relevant listeners.

DOM.getAccessibilityPropertiesForNode(NodeId, callback)

Returns a dictionary of accessibility properties for the node.

Parameters

nodeId ( NodeId )

Id of the node for which to get accessibility properties.

callback ( function )

Results

error ( error )
properties ( AccessibilityProperties )

Dictionary of relevant accessibility properties.

DOM.getOuterHTML(NodeId, callback)

Returns node's HTML markup.

Parameters

nodeId ( NodeId )

Id of the node to get markup for.

callback ( function )

Results

error ( error )
outerHTML ( string )

Outer HTML markup.

DOM.setOuterHTML(NodeId, outerHTML, callback)

Sets node HTML markup, returns new node id.

Parameters

nodeId ( NodeId )

Id of the node to set markup for.

outerHTML ( string )

Outer HTML markup to set.

callback ( function )

Results

error ( error )

DOM.performSearch(query, [NodeId], callback)

Searches for a given string in the DOM tree. Use getSearchResults to access search results or cancelSearch to end this search session.

Parameters

query ( string )

Plain text or query selector or XPath search query.

nodeIds ( optional array of NodeId )

Ids of nodes to use as starting points for the search.

callback ( function )

Results

error ( error )
searchId ( string )

Unique search session identifier.

resultCount ( integer )

Number of search results.

DOM.getSearchResults(searchId, fromIndex, toIndex, callback)

Returns search results from given fromIndex to given toIndex from the sarch with the given identifier.

Parameters

searchId ( string )

Unique search session identifier.

fromIndex ( integer )

Start index of the search result to be returned.

toIndex ( integer )

End index of the search result to be returned.

callback ( function )

Results

error ( error )
nodeIds ( array of NodeId )

Ids of the search result nodes.

DOM.discardSearchResults(searchId, callback)

Discards search results from the session with the given id. getSearchResults should no longer be called for that search.

Parameters

searchId ( string )

Unique search session identifier.

callback ( function )

Results

error ( error )

DOM.requestNode(Runtime.RemoteObjectId, callback)

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.

Parameters

objectId ( Runtime.RemoteObjectId )

JavaScript object id to convert into node.

callback ( function )

Results

error ( error )
nodeId ( NodeId )

Node id for given object.

DOM.setInspectModeEnabled(enabled, [HighlightConfig], callback)

Enters the 'inspect' mode. In this mode, elements that user is hovering over are highlighted. Backend then generates 'inspect' command upon element selection.

Parameters

enabled ( boolean )

True to enable inspection mode, false to disable it.

highlightConfig ( optional HighlightConfig )

A descriptor for the highlight appearance of hovered-over nodes. May be omitted if enabled == false.

callback ( function )

Results

error ( error )

DOM.highlightRect(x, y, width, height, [RGBAColor], [RGBAColor], [usePageCoordinates], callback)

Highlights given rectangle. Coordinates are absolute with respect to the main frame viewport.

Parameters

x ( integer )

X coordinate

y ( integer )

Y coordinate

width ( integer )

Rectangle width

height ( integer )

Rectangle height

color ( optional RGBAColor )

The highlight fill color (default: transparent).

outlineColor ( optional RGBAColor )

The highlight outline color (default: transparent).

usePageCoordinates ( optional boolean )

Indicates whether the provided parameters are in page coordinates or in viewport coordinates (the default).

callback ( function )

Results

error ( error )

DOM.highlightQuad(Quad, [RGBAColor], [RGBAColor], [usePageCoordinates], callback)

Highlights given quad. Coordinates are absolute with respect to the main frame viewport.

Parameters

quad ( Quad )

Quad to highlight

color ( optional RGBAColor )

The highlight fill color (default: transparent).

outlineColor ( optional RGBAColor )

The highlight outline color (default: transparent).

usePageCoordinates ( optional boolean )

Indicates whether the provided parameters are in page coordinates or in viewport coordinates (the default).

callback ( function )

Results

error ( error )

DOM.highlightNode(HighlightConfig, [NodeId], [Runtime.RemoteObjectId], callback)

Highlights DOM node with given id or with the given JavaScript object wrapper. Either nodeId or objectId must be specified.

Parameters

highlightConfig ( HighlightConfig )

A descriptor for the highlight appearance.

nodeId ( optional NodeId )

Identifier of the node to highlight.

objectId ( optional Runtime.RemoteObjectId )

JavaScript object id of the node to be highlighted.

callback ( function )

Results

error ( error )

DOM.hideHighlight(callback)

Hides DOM node highlight.

Parameters

callback ( function )

Results

error ( error )

DOM.highlightFrame(Network.FrameId, [RGBAColor], [RGBAColor], callback)

Highlights owner element of the frame with given id.

Parameters

frameId ( Network.FrameId )

Identifier of the frame to highlight.

contentColor ( optional RGBAColor )

The content box highlight fill color (default: transparent).

contentOutlineColor ( optional RGBAColor )

The content box highlight outline color (default: transparent).

callback ( function )

Results

error ( error )

DOM.pushNodeByPathToFrontend(path, callback)

Requests that the node is sent to the caller given its path. // FIXME, use XPath

Parameters

path ( string )

Path to node in the proprietary format.

callback ( function )

Results

error ( error )
nodeId ( NodeId )

Id of the node for given path.

DOM.pushNodeByBackendIdToFrontend(BackendNodeId, callback)

Requests that the node is sent to the caller given its backend node id.

Parameters

backendNodeId ( BackendNodeId )

The backend node id of the node.

callback ( function )

Results

error ( error )
nodeId ( NodeId )

The pushed node's id.

DOM.releaseBackendNodeIds(nodeGroup, callback)

Requests that group of BackendNodeIds is released.

Parameters

nodeGroup ( string )

The backend node ids group name.

callback ( function )

Results

error ( error )

DOM.resolveNode(NodeId, [objectGroup], callback)

Resolves JavaScript node object for given node id.

Parameters

nodeId ( NodeId )

Id of the node to resolve.

objectGroup ( optional string )

Symbolic group name that can be used to release multiple objects.

callback ( function )

Results

error ( error )
object ( Runtime.RemoteObject )

JavaScript object wrapper for given node.

DOM.getAttributes(NodeId, callback)

Returns attributes for the specified node.

Parameters

nodeId ( NodeId )

Id of the node to retrieve attibutes for.

callback ( function )

Results

error ( error )
attributes ( array )

An interleaved array of node attribute names and values.

DOM.moveTo(NodeId, NodeId, [NodeId], callback)

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

Parameters

nodeId ( NodeId )

Id of the node to drop.

targetNodeId ( NodeId )

Id of the element to drop into.

insertBeforeNodeId ( optional NodeId )

Drop node before given one.

callback ( function )

Results

error ( error )
nodeId ( NodeId )

New id of the moved node.

DOM.undo(callback)

Undoes the last performed action.

Parameters

callback ( function )

Results

error ( error )

DOM.redo(callback)

Re-does the last undone action.

Parameters

callback ( function )

Results

error ( error )

DOM.markUndoableState(callback)

Marks last undoable state.

Parameters

callback ( function )

Results

error ( error )

DOM.focus(NodeId, callback)

Focuses the given element.

Parameters

nodeId ( NodeId )

Id of the node to focus.

callback ( function )

Results

error ( error )

Events

Event: documentUpdated

Fired when Document has been totally updated. Node ids are no longer valid.

Event: setChildNodes

Fired when backend wants to provide client with the missing DOM structure. This happens upon most of the calls requesting node ids.

Results

parentId ( NodeId )

Parent node id to populate with children.

nodes ( array of Node )

Child nodes array.

Event: attributeModified

Fired when Element's attribute is modified.

Results

nodeId ( NodeId )

Id of the node that has changed.

name ( string )

Attribute name.

value ( string )

Attribute value.

Event: attributeRemoved

Fired when Element's attribute is removed.

Results

nodeId ( NodeId )

Id of the node that has changed.

name ( string )

A ttribute name.

Event: inlineStyleInvalidated

Fired when Element's inline style is modified via a CSS property modification.

Results

nodeIds ( array of NodeId )

Ids of the nodes for which the inline styles have been invalidated.

Event: characterDataModified

Mirrors DOMCharacterDataModified event.

Results

nodeId ( NodeId )

Id of the node that has changed.

characterData ( string )

New text value.

Event: childNodeCountUpdated

Fired when Container's child node count has changed.

Results

nodeId ( NodeId )

Id of the node that has changed.

childNodeCount ( integer )

New node count.

Event: childNodeInserted

Mirrors DOMNodeInserted event.

Results

parentNodeId ( NodeId )

Id of the node that has changed.

previousNodeId ( NodeId )

If of the previous siblint.

node ( Node )

Inserted node data.

Event: childNodeRemoved

Mirrors DOMNodeRemoved event.

Results

parentNodeId ( NodeId )

Parent id.

nodeId ( NodeId )

Id of the node that has been removed.

Event: shadowRootPushed

Called when shadow root is pushed into the element.

Results

hostId ( NodeId )

Host element id.

root ( Node )

Shadow root.

Event: shadowRootPopped

Called when shadow root is popped from the element.

Results

hostId ( NodeId )

Host element id.

rootId ( NodeId )

Shadow root id.

Types

Class: NodeId

Type: integer

Unique DOM node identifier.

Class: BackendNodeId

Type: integer

Unique DOM node identifier used to reference a node that may not have been pushed to the front-end.

Class: LiveRegionRelevant

Type: string

Token values of @aria-relevant attribute.

Class: Node

Type: object

DOM interaction is implemented in terms of mirror objects that represent the actual DOM nodes. DOMNode is a base node mirror type.

Properties

nodeId ( NodeId )

Node identifier that is passed into the rest of the DOM messages as the nodeId. Backend will only push node with given id once. It is aware of all requested nodes and will only fire DOM events for nodes known to the client.

nodeType ( integer )

Node's nodeType.

nodeName ( string )

Node's nodeName.

localName ( string )

Node's localName.

nodeValue ( string )

Node's nodeValue.

childNodeCount ( optional integer )

Child count for Container nodes.

children ( optional array of Node )

Child nodes of this node when requested with children.

attributes ( optional array )

Attributes of the Element node in the form of flat array [name1, value1, name2, value2].

documentURL ( optional string )

Document URL that Document or FrameOwner node points to.

baseURL ( optional string )

Base URL that Document or FrameOwner node uses for URL completion.

publicId ( optional string )

DocumentType's publicId.

systemId ( optional string )

DocumentType's systemId.

internalSubset ( optional string )

DocumentType's internalSubset.

xmlVersion ( optional string )

Document's XML version in case of XML documents.

name ( optional string )

Attr's name.

value ( optional string )

Attr's value.

frameId ( optional Network.FrameId )

Frame ID for frame owner elements.

contentDocument ( optional Node )

Content document for frame owner elements.

shadowRoots ( optional array of Node )

Shadow root list for given element host.

templateContent ( optional Node )

Content document fragment for template elements

role ( optional string )

Computed value for first recognized role token, default role per element, or overridden role.

Class: EventListener

Type: object

A structure holding event listener properties.

Properties

type ( string )

EventListener's type.

useCapture ( boolean )

EventListener's useCapture.

isAttribute ( boolean )

EventListener's isAttribute.

nodeId ( NodeId )

Target DOMNode id.

handlerBody ( string )

Event handler function body.

location ( optional Debugger.Location )

Handler code location.

sourceName ( optional string )

Source script URL.

handler ( optional Runtime.RemoteObject )

Event handler function value.

Class: AccessibilityProperties

Type: object

A structure holding accessibility properties.

Properties

activeDescendantNodeId ( optional NodeId )

DOMNode id of the accessibility object referenced by aria-activedescendant.

busy ( optional boolean )

Value of @aria-busy on current or ancestor node.

checked ( optional string enumerated ["true","false","mixed"] )

Checked state of certain form controls.

childNodeIds ( optional array of NodeId )

Array of DOMNode ids of the accessibility tree children if available.

controlledNodeIds ( optional array of NodeId )

Array of DOMNode ids of any nodes referenced via @aria-controls.

disabled ( optional boolean )

Disabled state of form controls.

exists ( boolean )

Indicates whether there is an existing AX object for the DOM node. If this is false, all the other properties will be default values.

expanded ( optional boolean )

Expanded state.

flowedNodeIds ( optional array of NodeId )

Array of DOMNode ids of any nodes referenced via @aria-flowto.

focused ( optional boolean )

Focused state. Only defined on focusable elements.

ignored ( optional boolean )

Indicates whether the accessibility of the associated AX object node is ignored, whether heuristically or explicitly.

ignoredByDefault ( optional boolean )

State indicating whether the accessibility of the associated AX object node is ignored by default for node type.

invalid ( optional string enumerated ["true","false","grammar","spelling"] )

Invalid status of form controls.

hidden ( optional boolean )

Hidden state. True if node or an ancestor is hidden via CSS or explicit @aria-hidden, to clarify why the element is ignored.

label ( string )

Computed label value for the node, sometimes calculated by referencing other nodes.

liveRegionAtomic ( optional boolean )

Value of @aria-atomic.

liveRegionRelevant ( optional array )

Token value(s) of element's @aria-relevant attribute. Array of string values matching $ref LiveRegionRelevant. FIXME: Enum values blocked by http://webkit.org/b/133711

liveRegionStatus ( optional string enumerated ["assertive","polite","off"] )

Value of element's @aria-live attribute.

mouseEventNodeId ( optional NodeId )

DOMNode id of node or closest ancestor node that has a mousedown, mouseup, or click event handler.

nodeId ( NodeId )

Target DOMNode id.

ownedNodeIds ( optional array of NodeId )

Array of DOMNode ids of any nodes referenced via @aria-owns.

parentNodeId ( optional NodeId )

DOMNode id of the accessibility tree parent object if available.

pressed ( optional boolean )

Pressed state for toggle buttons.

readonly ( optional boolean )

Readonly state of text controls.

required ( optional boolean )

Required state of form controls.

role ( string )

Computed value for first recognized role token, default role per element, or overridden role.

selected ( optional boolean )

Selected state of certain form controls.

selectedChildNodeIds ( optional array of NodeId )

Array of DOMNode ids of any children marked as selected.

Class: RGBAColor

Type: object

A structure holding an RGBA color.

Properties

r ( integer )

The red component, in the [0-255] range.

g ( integer )

The green component, in the [0-255] range.

b ( integer )

The blue component, in the [0-255] range.

a ( optional number )

The alpha component, in the [0-1] range (default: 1).

Class: Quad

Type: array

An array of quad vertices, x immediately followed by y for each point, points clock-wise.

Class: HighlightConfig

Type: object

Configuration data for the highlighting of page elements.

Properties

showInfo ( optional boolean )

Whether the node info tooltip should be shown (default: false).

contentColor ( optional RGBAColor )

The content box highlight fill color (default: transparent).

paddingColor ( optional RGBAColor )

The padding highlight fill color (default: transparent).

borderColor ( optional RGBAColor )

The border highlight fill color (default: transparent).

marginColor ( optional RGBAColor )

The margin highlight fill color (default: transparent).