diff --git a/cdp/dom/dom.go b/cdp/dom/dom.go index 038065b..441228d 100644 --- a/cdp/dom/dom.go +++ b/cdp/dom/dom.go @@ -803,20 +803,32 @@ func (p *SetInspectedNodeParams) Do(ctxt context.Context, h cdp.Handler) (err er return h.Execute(ctxt, cdp.CommandDOMSetInspectedNode, p, nil) } -// ResolveNodeParams resolves JavaScript node object for given node id. +// ResolveNodeParams resolves the JavaScript node object for a given NodeId +// or BackendNodeId. type ResolveNodeParams struct { - NodeID cdp.NodeID `json:"nodeId"` // Id of the node to resolve. - ObjectGroup string `json:"objectGroup,omitempty"` // Symbolic group name that can be used to release multiple objects. + NodeID cdp.NodeID `json:"nodeId,omitempty"` // Id of the node to resolve. + BackendNodeID cdp.BackendNodeID `json:"backendNodeId,omitempty"` // Backend identifier of the node to resolve. + ObjectGroup string `json:"objectGroup,omitempty"` // Symbolic group name that can be used to release multiple objects. } -// ResolveNode resolves JavaScript node object for given node id. +// ResolveNode resolves the JavaScript node object for a given NodeId or +// BackendNodeId. // // parameters: -// nodeID - Id of the node to resolve. -func ResolveNode(nodeID cdp.NodeID) *ResolveNodeParams { - return &ResolveNodeParams{ - NodeID: nodeID, - } +func ResolveNode() *ResolveNodeParams { + return &ResolveNodeParams{} +} + +// WithNodeID id of the node to resolve. +func (p ResolveNodeParams) WithNodeID(nodeID cdp.NodeID) *ResolveNodeParams { + p.NodeID = nodeID + return &p +} + +// WithBackendNodeID backend identifier of the node to resolve. +func (p ResolveNodeParams) WithBackendNodeID(backendNodeID cdp.BackendNodeID) *ResolveNodeParams { + p.BackendNodeID = backendNodeID + return &p } // WithObjectGroup symbolic group name that can be used to release multiple diff --git a/cdp/dom/easyjson.go b/cdp/dom/easyjson.go index aa6e642..289b40a 100644 --- a/cdp/dom/easyjson.go +++ b/cdp/dom/easyjson.go @@ -995,6 +995,8 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDom11(in *jlexer.Lexer, out *R switch key { case "nodeId": (out.NodeID).UnmarshalEasyJSON(in) + case "backendNodeId": + (out.BackendNodeID).UnmarshalEasyJSON(in) case "objectGroup": out.ObjectGroup = string(in.String()) default: @@ -1011,12 +1013,22 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDom11(out *jwriter.Writer, in out.RawByte('{') first := true _ = first - if !first { - out.RawByte(',') + if in.NodeID != 0 { + if !first { + out.RawByte(',') + } + first = false + out.RawString("\"nodeId\":") + out.Int64(int64(in.NodeID)) + } + if in.BackendNodeID != 0 { + if !first { + out.RawByte(',') + } + first = false + out.RawString("\"backendNodeId\":") + out.Int64(int64(in.BackendNodeID)) } - first = false - out.RawString("\"nodeId\":") - out.Int64(int64(in.NodeID)) if in.ObjectGroup != "" { if !first { out.RawByte(',') diff --git a/cmd/chromedp-gen/protocol.json b/cmd/chromedp-gen/protocol.json index 558e234..a63a52a 100644 --- a/cmd/chromedp-gen/protocol.json +++ b/cmd/chromedp-gen/protocol.json @@ -5874,8 +5874,15 @@ { "name": "nodeId", "$ref": "NodeId", + "optional": true, "description": "Id of the node to resolve." }, + { + "name": "backendNodeId", + "$ref": "DOM.BackendNodeId", + "optional": true, + "description": "Backend identifier of the node to resolve." + }, { "name": "objectGroup", "type": "string", @@ -5890,7 +5897,7 @@ "description": "JavaScript object wrapper for given node." } ], - "description": "Resolves JavaScript node object for given node id." + "description": "Resolves the JavaScript node object for a given NodeId or BackendNodeId." }, { "name": "getAttributes",