Skip to main content

browser_protocol/domdebugger/
mod.rs

1//! DOM debugging allows setting breakpoints on particular DOM operations and events. JavaScript
2//! execution will stop on these operations as if there was a regular breakpoint set.
3
4use serde::{Serialize, Deserialize};
5
6/// DOM breakpoint type.
7
8#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
9pub enum DOMBreakpointType {
10    #[default]
11    SubtreeModified,
12    AttributeModified,
13    NodeRemoved,
14}
15
16/// CSP Violation type.
17
18#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
19pub enum CSPViolationType {
20    #[default]
21    TrustedtypeSinkViolation,
22    TrustedtypePolicyViolation,
23}
24
25/// Object event listener.
26
27#[derive(Debug, Clone, Serialize, Deserialize, Default)]
28#[serde(rename_all = "camelCase")]
29pub struct EventListener {
30    /// 'EventListener''s type.
31
32    #[serde(rename = "type")]
33    pub type_: String,
34    /// 'EventListener''s useCapture.
35
36    pub useCapture: bool,
37    /// 'EventListener''s passive flag.
38
39    pub passive: bool,
40    /// 'EventListener''s once flag.
41
42    pub once: bool,
43    /// Script id of the handler code.
44
45    pub scriptId: crate::runtime::ScriptId,
46    /// Line number in the script (0-based).
47
48    pub lineNumber: i64,
49    /// Column number in the script (0-based).
50
51    pub columnNumber: i64,
52    /// Event handler function value.
53
54    #[serde(skip_serializing_if = "Option::is_none")]
55    pub handler: Option<crate::runtime::RemoteObject>,
56    /// Event original handler function value.
57
58    #[serde(skip_serializing_if = "Option::is_none")]
59    pub originalHandler: Option<crate::runtime::RemoteObject>,
60    /// Node the listener is added to (if any).
61
62    #[serde(skip_serializing_if = "Option::is_none")]
63    pub backendNodeId: Option<crate::dom::BackendNodeId>,
64}
65
66/// Returns event listeners of the given object.
67
68#[derive(Debug, Clone, Serialize, Deserialize, Default)]
69#[serde(rename_all = "camelCase")]
70pub struct GetEventListenersParams {
71    /// Identifier of the object to return listeners for.
72
73    pub objectId: crate::runtime::RemoteObjectId,
74    /// The maximum depth at which Node children should be retrieved, defaults to 1. Use -1 for the
75    /// entire subtree or provide an integer larger than 0.
76
77    #[serde(skip_serializing_if = "Option::is_none")]
78    pub depth: Option<i64>,
79    /// Whether or not iframes and shadow roots should be traversed when returning the subtree
80    /// (default is false). Reports listeners for all contexts if pierce is enabled.
81
82    #[serde(skip_serializing_if = "Option::is_none")]
83    pub pierce: Option<bool>,
84}
85
86/// Returns event listeners of the given object.
87
88#[derive(Debug, Clone, Serialize, Deserialize, Default)]
89#[serde(rename_all = "camelCase")]
90pub struct GetEventListenersReturns {
91    /// Array of relevant listeners.
92
93    pub listeners: Vec<EventListener>,
94}
95
96/// Removes DOM breakpoint that was set using 'setDOMBreakpoint'.
97
98#[derive(Debug, Clone, Serialize, Deserialize, Default)]
99#[serde(rename_all = "camelCase")]
100pub struct RemoveDOMBreakpointParams {
101    /// Identifier of the node to remove breakpoint from.
102
103    pub nodeId: crate::dom::NodeId,
104    /// Type of the breakpoint to remove.
105
106    #[serde(rename = "type")]
107    pub type_: DOMBreakpointType,
108}
109
110/// Removes breakpoint on particular DOM event.
111
112#[derive(Debug, Clone, Serialize, Deserialize, Default)]
113#[serde(rename_all = "camelCase")]
114pub struct RemoveEventListenerBreakpointParams {
115    /// Event name.
116
117    pub eventName: String,
118    /// EventTarget interface name.
119
120    #[serde(skip_serializing_if = "Option::is_none")]
121    pub targetName: Option<String>,
122}
123
124/// Removes breakpoint on particular native event.
125
126#[derive(Debug, Clone, Serialize, Deserialize, Default)]
127#[serde(rename_all = "camelCase")]
128pub struct RemoveInstrumentationBreakpointParams {
129    /// Instrumentation name to stop on.
130
131    pub eventName: String,
132}
133
134/// Removes breakpoint from XMLHttpRequest.
135
136#[derive(Debug, Clone, Serialize, Deserialize, Default)]
137#[serde(rename_all = "camelCase")]
138pub struct RemoveXHRBreakpointParams {
139    /// Resource URL substring.
140
141    pub url: String,
142}
143
144/// Sets breakpoint on particular CSP violations.
145
146#[derive(Debug, Clone, Serialize, Deserialize, Default)]
147#[serde(rename_all = "camelCase")]
148pub struct SetBreakOnCSPViolationParams {
149    /// CSP Violations to stop upon.
150
151    pub violationTypes: Vec<CSPViolationType>,
152}
153
154/// Sets breakpoint on particular operation with DOM.
155
156#[derive(Debug, Clone, Serialize, Deserialize, Default)]
157#[serde(rename_all = "camelCase")]
158pub struct SetDOMBreakpointParams {
159    /// Identifier of the node to set breakpoint on.
160
161    pub nodeId: crate::dom::NodeId,
162    /// Type of the operation to stop upon.
163
164    #[serde(rename = "type")]
165    pub type_: DOMBreakpointType,
166}
167
168/// Sets breakpoint on particular DOM event.
169
170#[derive(Debug, Clone, Serialize, Deserialize, Default)]
171#[serde(rename_all = "camelCase")]
172pub struct SetEventListenerBreakpointParams {
173    /// DOM Event name to stop on (any DOM event will do).
174
175    pub eventName: String,
176    /// EventTarget interface name to stop on. If equal to '"*"' or not provided, will stop on any
177    /// EventTarget.
178
179    #[serde(skip_serializing_if = "Option::is_none")]
180    pub targetName: Option<String>,
181}
182
183/// Sets breakpoint on particular native event.
184
185#[derive(Debug, Clone, Serialize, Deserialize, Default)]
186#[serde(rename_all = "camelCase")]
187pub struct SetInstrumentationBreakpointParams {
188    /// Instrumentation name to stop on.
189
190    pub eventName: String,
191}
192
193/// Sets breakpoint on XMLHttpRequest.
194
195#[derive(Debug, Clone, Serialize, Deserialize, Default)]
196#[serde(rename_all = "camelCase")]
197pub struct SetXHRBreakpointParams {
198    /// Resource URL substring. All XHRs having this substring in the URL will get stopped upon.
199
200    pub url: String,
201}