Skip to main content

cdp_driver/protocol/
dom_debugger.rs

1// @generated by `just generate-methods` from protocol/*.json.
2// Do not edit by hand; edit xtask/ and regenerate.
3
4//! DOM debugging allows setting breakpoints on particular DOM operations and
5//! events. JavaScript execution will stop on these operations as if there was
6//! a regular breakpoint set.
7//!
8//! Types, command parameters and event payloads for the `DOMDebugger`
9//! domain. The method-name constants for the same domain are in
10//! [`crate::methods`].
11
12use serde::{Deserialize, Serialize};
13
14/// DOM breakpoint type.
15#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
16pub enum DomBreakpointType {
17    /// `subtree-modified`
18    #[serde(rename = "subtree-modified")]
19    SubtreeModified,
20    /// `attribute-modified`
21    #[serde(rename = "attribute-modified")]
22    AttributeModified,
23    /// `node-removed`
24    #[serde(rename = "node-removed")]
25    NodeRemoved,
26    /// A value this vendored schema does not list. Chrome adds values ahead of
27    /// the published protocol, so an unrecognised one is kept as it arrived
28    /// rather than failing the payload it came in.
29    #[serde(untagged)]
30    Unrecognized(String),
31}
32
33/// CSP Violation type.
34///
35/// Experimental: may change without notice.
36#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
37pub enum CspViolationType {
38    /// `trustedtype-sink-violation`
39    #[serde(rename = "trustedtype-sink-violation")]
40    TrustedtypeSinkViolation,
41    /// `trustedtype-policy-violation`
42    #[serde(rename = "trustedtype-policy-violation")]
43    TrustedtypePolicyViolation,
44    /// A value this vendored schema does not list. Chrome adds values ahead of
45    /// the published protocol, so an unrecognised one is kept as it arrived
46    /// rather than failing the payload it came in.
47    #[serde(untagged)]
48    Unrecognized(String),
49}
50
51/// Object event listener.
52#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
53pub struct EventListener {
54    /// `EventListener`'s type.
55    pub r#type: String,
56    /// `EventListener`'s useCapture.
57    #[serde(rename = "useCapture")]
58    pub use_capture: bool,
59    /// `EventListener`'s passive flag.
60    pub passive: bool,
61    /// `EventListener`'s once flag.
62    pub once: bool,
63    /// Script id of the handler code.
64    #[serde(rename = "scriptId")]
65    pub script_id: crate::protocol::runtime::ScriptId,
66    /// Line number in the script (0-based).
67    #[serde(rename = "lineNumber")]
68    pub line_number: i64,
69    /// Column number in the script (0-based).
70    #[serde(rename = "columnNumber")]
71    pub column_number: i64,
72    /// Event handler function value.
73    #[serde(default, skip_serializing_if = "Option::is_none")]
74    pub handler: Option<crate::protocol::runtime::RemoteObject>,
75    /// Event original handler function value.
76    #[serde(
77        rename = "originalHandler",
78        default,
79        skip_serializing_if = "Option::is_none"
80    )]
81    pub original_handler: Option<crate::protocol::runtime::RemoteObject>,
82    /// Node the listener is added to (if any).
83    #[serde(
84        rename = "backendNodeId",
85        default,
86        skip_serializing_if = "Option::is_none"
87    )]
88    pub backend_node_id: Option<crate::protocol::dom::BackendNodeId>,
89}
90
91/// Returns event listeners of the given object.
92///
93/// Parameters of `DOMDebugger.getEventListeners`.
94#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
95pub struct GetEventListenersParams {
96    /// Identifier of the object to return listeners for.
97    #[serde(rename = "objectId")]
98    pub object_id: crate::protocol::runtime::RemoteObjectId,
99    /// The maximum depth at which Node children should be retrieved, defaults to
100    /// 1. Use -1 for the entire subtree or provide an integer larger than 0.
101    #[serde(default, skip_serializing_if = "Option::is_none")]
102    pub depth: Option<i64>,
103    /// Whether or not iframes and shadow roots should be traversed when returning
104    /// the subtree (default is false). Reports listeners for all contexts if
105    /// pierce is enabled.
106    #[serde(default, skip_serializing_if = "Option::is_none")]
107    pub pierce: Option<bool>,
108}
109
110/// What `DOMDebugger.getEventListeners` answers with.
111#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
112pub struct GetEventListenersReturns {
113    /// Array of relevant listeners.
114    pub listeners: Vec<EventListener>,
115}
116
117impl crate::typed::Command for GetEventListenersParams {
118    const METHOD: &'static str = "DOMDebugger.getEventListeners";
119    type Returns = GetEventListenersReturns;
120}
121
122/// Removes DOM breakpoint that was set using `setDOMBreakpoint`.
123///
124/// Parameters of `DOMDebugger.removeDOMBreakpoint`.
125#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
126pub struct RemoveDomBreakpointParams {
127    /// Identifier of the node to remove breakpoint from.
128    #[serde(rename = "nodeId")]
129    pub node_id: crate::protocol::dom::NodeId,
130    /// Type of the breakpoint to remove.
131    pub r#type: DomBreakpointType,
132}
133
134impl crate::typed::Command for RemoveDomBreakpointParams {
135    const METHOD: &'static str = "DOMDebugger.removeDOMBreakpoint";
136    type Returns = crate::typed::NoReturns;
137}
138
139/// Removes breakpoint on particular DOM event.
140///
141/// Parameters of `DOMDebugger.removeEventListenerBreakpoint`.
142#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
143pub struct RemoveEventListenerBreakpointParams {
144    /// Event name.
145    #[serde(rename = "eventName")]
146    pub event_name: String,
147    /// EventTarget interface name.
148    ///
149    /// Experimental: may change without notice.
150    #[serde(
151        rename = "targetName",
152        default,
153        skip_serializing_if = "Option::is_none"
154    )]
155    pub target_name: Option<String>,
156}
157
158impl crate::typed::Command for RemoveEventListenerBreakpointParams {
159    const METHOD: &'static str = "DOMDebugger.removeEventListenerBreakpoint";
160    type Returns = crate::typed::NoReturns;
161}
162
163/// Removes breakpoint on particular native event.
164///
165/// Deprecated in the protocol.
166///
167/// Experimental: may change without notice.
168///
169/// Parameters of `DOMDebugger.removeInstrumentationBreakpoint`.
170#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
171pub struct RemoveInstrumentationBreakpointParams {
172    /// Instrumentation name to stop on.
173    #[serde(rename = "eventName")]
174    pub event_name: String,
175}
176
177impl crate::typed::Command for RemoveInstrumentationBreakpointParams {
178    const METHOD: &'static str = "DOMDebugger.removeInstrumentationBreakpoint";
179    type Returns = crate::typed::NoReturns;
180}
181
182/// Removes breakpoint from XMLHttpRequest.
183///
184/// Parameters of `DOMDebugger.removeXHRBreakpoint`.
185#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
186pub struct RemoveXhrBreakpointParams {
187    /// Resource URL substring.
188    pub url: String,
189}
190
191impl crate::typed::Command for RemoveXhrBreakpointParams {
192    const METHOD: &'static str = "DOMDebugger.removeXHRBreakpoint";
193    type Returns = crate::typed::NoReturns;
194}
195
196/// Sets breakpoint on particular CSP violations.
197///
198/// Experimental: may change without notice.
199///
200/// Parameters of `DOMDebugger.setBreakOnCSPViolation`.
201#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
202pub struct SetBreakOnCspViolationParams {
203    /// CSP Violations to stop upon.
204    #[serde(rename = "violationTypes")]
205    pub violation_types: Vec<CspViolationType>,
206}
207
208impl crate::typed::Command for SetBreakOnCspViolationParams {
209    const METHOD: &'static str = "DOMDebugger.setBreakOnCSPViolation";
210    type Returns = crate::typed::NoReturns;
211}
212
213/// Sets breakpoint on particular operation with DOM.
214///
215/// Parameters of `DOMDebugger.setDOMBreakpoint`.
216#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
217pub struct SetDomBreakpointParams {
218    /// Identifier of the node to set breakpoint on.
219    #[serde(rename = "nodeId")]
220    pub node_id: crate::protocol::dom::NodeId,
221    /// Type of the operation to stop upon.
222    pub r#type: DomBreakpointType,
223}
224
225impl crate::typed::Command for SetDomBreakpointParams {
226    const METHOD: &'static str = "DOMDebugger.setDOMBreakpoint";
227    type Returns = crate::typed::NoReturns;
228}
229
230/// Sets breakpoint on particular DOM event.
231///
232/// Parameters of `DOMDebugger.setEventListenerBreakpoint`.
233#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
234pub struct SetEventListenerBreakpointParams {
235    /// DOM Event name to stop on (any DOM event will do).
236    #[serde(rename = "eventName")]
237    pub event_name: String,
238    /// EventTarget interface name to stop on. If equal to `"*"` or not provided,
239    /// will stop on any EventTarget.
240    ///
241    /// Experimental: may change without notice.
242    #[serde(
243        rename = "targetName",
244        default,
245        skip_serializing_if = "Option::is_none"
246    )]
247    pub target_name: Option<String>,
248}
249
250impl crate::typed::Command for SetEventListenerBreakpointParams {
251    const METHOD: &'static str = "DOMDebugger.setEventListenerBreakpoint";
252    type Returns = crate::typed::NoReturns;
253}
254
255/// Sets breakpoint on particular native event.
256///
257/// Deprecated in the protocol.
258///
259/// Experimental: may change without notice.
260///
261/// Parameters of `DOMDebugger.setInstrumentationBreakpoint`.
262#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
263pub struct SetInstrumentationBreakpointParams {
264    /// Instrumentation name to stop on.
265    #[serde(rename = "eventName")]
266    pub event_name: String,
267}
268
269impl crate::typed::Command for SetInstrumentationBreakpointParams {
270    const METHOD: &'static str = "DOMDebugger.setInstrumentationBreakpoint";
271    type Returns = crate::typed::NoReturns;
272}
273
274/// Sets breakpoint on XMLHttpRequest.
275///
276/// Parameters of `DOMDebugger.setXHRBreakpoint`.
277#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
278pub struct SetXhrBreakpointParams {
279    /// Resource URL substring. All XHRs having this substring in the URL will get
280    /// stopped upon.
281    pub url: String,
282}
283
284impl crate::typed::Command for SetXhrBreakpointParams {
285    const METHOD: &'static str = "DOMDebugger.setXHRBreakpoint";
286    type Returns = crate::typed::NoReturns;
287}