Skip to main content

js_protocol/runtime/
mod.rs

1//! Runtime domain exposes JavaScript runtime by means of remote evaluation and mirror objects.
2//! Evaluation results are returned as mirror object that expose object type, string representation
3//! and unique identifier that can be used for further object reference. Original objects are
4//! maintained in memory unless they are either explicitly released or are released along with the
5//! other objects in their object group.
6use serde::{Serialize, Deserialize};
7use serde_json::Value as JsonValue;
8
9/// Unique script identifier.
10
11pub type ScriptId = String;
12
13/// Represents options for serialization. Overrides 'generatePreview' and 'returnByValue'.
14
15#[derive(Debug, Clone, Serialize, Deserialize, Default)]
16#[serde(rename_all = "camelCase")]
17pub struct SerializationOptions {
18
19    pub serialization: String,
20    /// Deep serialization depth. Default is full depth. Respected only in 'deep' serialization mode.
21
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub maxDepth: Option<i64>,
24    /// Embedder-specific parameters. For example if connected to V8 in Chrome these control DOM
25    /// serialization via 'maxNodeDepth: integer' and 'includeShadowTree: "none" | "open" | "all"'.
26    /// Values can be only of type string or integer.
27
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub additionalParameters: Option<serde_json::Map<String, JsonValue>>,
30}
31
32/// Represents deep serialized value.
33
34#[derive(Debug, Clone, Serialize, Deserialize, Default)]
35#[serde(rename_all = "camelCase")]
36pub struct DeepSerializedValue {
37
38    #[serde(rename = "type")]
39    pub type_: String,
40
41    #[serde(skip_serializing_if = "Option::is_none")]
42    pub value: Option<JsonValue>,
43
44    #[serde(skip_serializing_if = "Option::is_none")]
45    pub objectId: Option<String>,
46    /// Set if value reference met more then once during serialization. In such
47    /// case, value is provided only to one of the serialized values. Unique
48    /// per value in the scope of one CDP call.
49
50    #[serde(skip_serializing_if = "Option::is_none")]
51    pub weakLocalObjectReference: Option<i64>,
52}
53
54/// Unique object identifier.
55
56pub type RemoteObjectId = String;
57
58/// Primitive value which cannot be JSON-stringified. Includes values '-0', 'NaN', 'Infinity',
59/// '-Infinity', and bigint literals.
60
61pub type UnserializableValue = String;
62
63/// Mirror object referencing original JavaScript object.
64
65#[derive(Debug, Clone, Serialize, Deserialize, Default)]
66#[serde(rename_all = "camelCase")]
67pub struct RemoteObject {
68    /// Object type.
69
70    #[serde(rename = "type")]
71    pub type_: String,
72    /// Object subtype hint. Specified for 'object' type values only.
73    /// NOTE: If you change anything here, make sure to also update
74    /// 'subtype' in 'ObjectPreview' and 'PropertyPreview' below.
75
76    #[serde(skip_serializing_if = "Option::is_none")]
77    pub subtype: Option<String>,
78    /// Object class (constructor) name. Specified for 'object' type values only.
79
80    #[serde(skip_serializing_if = "Option::is_none")]
81    pub className: Option<String>,
82    /// Remote object value in case of primitive values or JSON values (if it was requested).
83
84    #[serde(skip_serializing_if = "Option::is_none")]
85    pub value: Option<JsonValue>,
86    /// Primitive value which can not be JSON-stringified does not have 'value', but gets this
87    /// property.
88
89    #[serde(skip_serializing_if = "Option::is_none")]
90    pub unserializableValue: Option<UnserializableValue>,
91    /// String representation of the object.
92
93    #[serde(skip_serializing_if = "Option::is_none")]
94    pub description: Option<String>,
95    /// Deep serialized value.
96
97    #[serde(skip_serializing_if = "Option::is_none")]
98    pub deepSerializedValue: Option<DeepSerializedValue>,
99    /// Unique object identifier (for non-primitive values).
100
101    #[serde(skip_serializing_if = "Option::is_none")]
102    pub objectId: Option<RemoteObjectId>,
103    /// Preview containing abbreviated property values. Specified for 'object' type values only.
104
105    #[serde(skip_serializing_if = "Option::is_none")]
106    pub preview: Option<ObjectPreview>,
107
108    #[serde(skip_serializing_if = "Option::is_none")]
109    pub customPreview: Option<CustomPreview>,
110}
111
112
113#[derive(Debug, Clone, Serialize, Deserialize, Default)]
114#[serde(rename_all = "camelCase")]
115pub struct CustomPreview {
116    /// The JSON-stringified result of formatter.header(object, config) call.
117    /// It contains json ML array that represents RemoteObject.
118
119    pub header: String,
120    /// If formatter returns true as a result of formatter.hasBody call then bodyGetterId will
121    /// contain RemoteObjectId for the function that returns result of formatter.body(object, config) call.
122    /// The result value is json ML array.
123
124    #[serde(skip_serializing_if = "Option::is_none")]
125    pub bodyGetterId: Option<RemoteObjectId>,
126}
127
128/// Object containing abbreviated remote object value.
129
130#[derive(Debug, Clone, Serialize, Deserialize, Default)]
131#[serde(rename_all = "camelCase")]
132pub struct ObjectPreview {
133    /// Object type.
134
135    #[serde(rename = "type")]
136    pub type_: String,
137    /// Object subtype hint. Specified for 'object' type values only.
138
139    #[serde(skip_serializing_if = "Option::is_none")]
140    pub subtype: Option<String>,
141    /// String representation of the object.
142
143    #[serde(skip_serializing_if = "Option::is_none")]
144    pub description: Option<String>,
145    /// True iff some of the properties or entries of the original object did not fit.
146
147    pub overflow: bool,
148    /// List of the properties.
149
150    pub properties: Vec<PropertyPreview>,
151    /// List of the entries. Specified for 'map' and 'set' subtype values only.
152
153    #[serde(skip_serializing_if = "Option::is_none")]
154    pub entries: Option<Vec<EntryPreview>>,
155}
156
157
158#[derive(Debug, Clone, Serialize, Deserialize, Default)]
159#[serde(rename_all = "camelCase")]
160pub struct PropertyPreview {
161    /// Property name.
162
163    pub name: String,
164    /// Object type. Accessor means that the property itself is an accessor property.
165
166    #[serde(rename = "type")]
167    pub type_: String,
168    /// User-friendly property value string.
169
170    #[serde(skip_serializing_if = "Option::is_none")]
171    pub value: Option<String>,
172    /// Nested value preview.
173
174    #[serde(skip_serializing_if = "Option::is_none")]
175    pub valuePreview: Option<ObjectPreview>,
176    /// Object subtype hint. Specified for 'object' type values only.
177
178    #[serde(skip_serializing_if = "Option::is_none")]
179    pub subtype: Option<String>,
180}
181
182
183#[derive(Debug, Clone, Serialize, Deserialize, Default)]
184#[serde(rename_all = "camelCase")]
185pub struct EntryPreview {
186    /// Preview of the key. Specified for map-like collection entries.
187
188    #[serde(skip_serializing_if = "Option::is_none")]
189    pub key: Option<ObjectPreview>,
190    /// Preview of the value.
191
192    pub value: ObjectPreview,
193}
194
195/// Object property descriptor.
196
197#[derive(Debug, Clone, Serialize, Deserialize, Default)]
198#[serde(rename_all = "camelCase")]
199pub struct PropertyDescriptor {
200    /// Property name or symbol description.
201
202    pub name: String,
203    /// The value associated with the property.
204
205    #[serde(skip_serializing_if = "Option::is_none")]
206    pub value: Option<RemoteObject>,
207    /// True if the value associated with the property may be changed (data descriptors only).
208
209    #[serde(skip_serializing_if = "Option::is_none")]
210    pub writable: Option<bool>,
211    /// A function which serves as a getter for the property, or 'undefined' if there is no getter
212    /// (accessor descriptors only).
213
214    #[serde(skip_serializing_if = "Option::is_none")]
215    pub get: Option<RemoteObject>,
216    /// A function which serves as a setter for the property, or 'undefined' if there is no setter
217    /// (accessor descriptors only).
218
219    #[serde(skip_serializing_if = "Option::is_none")]
220    pub set: Option<RemoteObject>,
221    /// True if the type of this property descriptor may be changed and if the property may be
222    /// deleted from the corresponding object.
223
224    pub configurable: bool,
225    /// True if this property shows up during enumeration of the properties on the corresponding
226    /// object.
227
228    pub enumerable: bool,
229    /// True if the result was thrown during the evaluation.
230
231    #[serde(skip_serializing_if = "Option::is_none")]
232    pub wasThrown: Option<bool>,
233    /// True if the property is owned for the object.
234
235    #[serde(skip_serializing_if = "Option::is_none")]
236    pub isOwn: Option<bool>,
237    /// Property symbol object, if the property is of the 'symbol' type.
238
239    #[serde(skip_serializing_if = "Option::is_none")]
240    pub symbol: Option<RemoteObject>,
241}
242
243/// Object internal property descriptor. This property isn't normally visible in JavaScript code.
244
245#[derive(Debug, Clone, Serialize, Deserialize, Default)]
246#[serde(rename_all = "camelCase")]
247pub struct InternalPropertyDescriptor {
248    /// Conventional property name.
249
250    pub name: String,
251    /// The value associated with the property.
252
253    #[serde(skip_serializing_if = "Option::is_none")]
254    pub value: Option<RemoteObject>,
255}
256
257/// Object private field descriptor.
258
259#[derive(Debug, Clone, Serialize, Deserialize, Default)]
260#[serde(rename_all = "camelCase")]
261pub struct PrivatePropertyDescriptor {
262    /// Private property name.
263
264    pub name: String,
265    /// The value associated with the private property.
266
267    #[serde(skip_serializing_if = "Option::is_none")]
268    pub value: Option<RemoteObject>,
269    /// A function which serves as a getter for the private property,
270    /// or 'undefined' if there is no getter (accessor descriptors only).
271
272    #[serde(skip_serializing_if = "Option::is_none")]
273    pub get: Option<RemoteObject>,
274    /// A function which serves as a setter for the private property,
275    /// or 'undefined' if there is no setter (accessor descriptors only).
276
277    #[serde(skip_serializing_if = "Option::is_none")]
278    pub set: Option<RemoteObject>,
279}
280
281/// Represents function call argument. Either remote object id 'objectId', primitive 'value',
282/// unserializable primitive value or neither of (for undefined) them should be specified.
283
284#[derive(Debug, Clone, Serialize, Deserialize, Default)]
285#[serde(rename_all = "camelCase")]
286pub struct CallArgument {
287    /// Primitive value or serializable javascript object.
288
289    #[serde(skip_serializing_if = "Option::is_none")]
290    pub value: Option<JsonValue>,
291    /// Primitive value which can not be JSON-stringified.
292
293    #[serde(skip_serializing_if = "Option::is_none")]
294    pub unserializableValue: Option<UnserializableValue>,
295    /// Remote object handle.
296
297    #[serde(skip_serializing_if = "Option::is_none")]
298    pub objectId: Option<RemoteObjectId>,
299}
300
301/// Id of an execution context.
302
303pub type ExecutionContextId = i64;
304
305/// Description of an isolated world.
306
307#[derive(Debug, Clone, Serialize, Deserialize, Default)]
308#[serde(rename_all = "camelCase")]
309pub struct ExecutionContextDescription {
310    /// Unique id of the execution context. It can be used to specify in which execution context
311    /// script evaluation should be performed.
312
313    pub id: ExecutionContextId,
314    /// Execution context origin.
315
316    pub origin: String,
317    /// Human readable name describing given context.
318
319    pub name: String,
320    /// A system-unique execution context identifier. Unlike the id, this is unique across
321    /// multiple processes, so can be reliably used to identify specific context while backend
322    /// performs a cross-process navigation.
323
324    pub uniqueId: String,
325    /// Embedder-specific auxiliary data likely matching {isDefault: boolean, type: 'default'|'isolated'|'worker', frameId: string}
326
327    #[serde(skip_serializing_if = "Option::is_none")]
328    pub auxData: Option<serde_json::Map<String, JsonValue>>,
329}
330
331/// Detailed information about exception (or error) that was thrown during script compilation or
332/// execution.
333
334#[derive(Debug, Clone, Serialize, Deserialize, Default)]
335#[serde(rename_all = "camelCase")]
336pub struct ExceptionDetails {
337    /// Exception id.
338
339    pub exceptionId: u64,
340    /// Exception text, which should be used together with exception object when available.
341
342    pub text: String,
343    /// Line number of the exception location (0-based).
344
345    pub lineNumber: i64,
346    /// Column number of the exception location (0-based).
347
348    pub columnNumber: i64,
349    /// Script ID of the exception location.
350
351    #[serde(skip_serializing_if = "Option::is_none")]
352    pub scriptId: Option<ScriptId>,
353    /// URL of the exception location, to be used when the script was not reported.
354
355    #[serde(skip_serializing_if = "Option::is_none")]
356    pub url: Option<String>,
357    /// JavaScript stack trace if available.
358
359    #[serde(skip_serializing_if = "Option::is_none")]
360    pub stackTrace: Option<StackTrace>,
361    /// Exception object if available.
362
363    #[serde(skip_serializing_if = "Option::is_none")]
364    pub exception: Option<RemoteObject>,
365    /// Identifier of the context where exception happened.
366
367    #[serde(skip_serializing_if = "Option::is_none")]
368    pub executionContextId: Option<ExecutionContextId>,
369    /// Dictionary with entries of meta data that the client associated
370    /// with this exception, such as information about associated network
371    /// requests, etc.
372
373    #[serde(skip_serializing_if = "Option::is_none")]
374    pub exceptionMetaData: Option<serde_json::Map<String, JsonValue>>,
375}
376
377/// Number of milliseconds since epoch.
378
379pub type Timestamp = f64;
380
381/// Number of milliseconds.
382
383pub type TimeDelta = f64;
384
385/// Stack entry for runtime errors and assertions.
386
387#[derive(Debug, Clone, Serialize, Deserialize, Default)]
388#[serde(rename_all = "camelCase")]
389pub struct CallFrame {
390    /// JavaScript function name.
391
392    pub functionName: String,
393    /// JavaScript script id.
394
395    pub scriptId: ScriptId,
396    /// JavaScript script name or url.
397
398    pub url: String,
399    /// JavaScript script line number (0-based).
400
401    pub lineNumber: i64,
402    /// JavaScript script column number (0-based).
403
404    pub columnNumber: i64,
405}
406
407/// Call frames for assertions or error messages.
408
409#[derive(Debug, Clone, Serialize, Deserialize, Default)]
410#[serde(rename_all = "camelCase")]
411pub struct StackTrace {
412    /// String label of this stack trace. For async traces this may be a name of the function that
413    /// initiated the async call.
414
415    #[serde(skip_serializing_if = "Option::is_none")]
416    pub description: Option<String>,
417    /// JavaScript function name.
418
419    pub callFrames: Vec<CallFrame>,
420    /// Asynchronous JavaScript stack trace that preceded this stack, if available.
421
422    #[serde(skip_serializing_if = "Option::is_none")]
423    pub parent: Option<Box<StackTrace>>,
424    /// Asynchronous JavaScript stack trace that preceded this stack, if available.
425
426    #[serde(skip_serializing_if = "Option::is_none")]
427    pub parentId: Option<StackTraceId>,
428}
429
430/// Unique identifier of current debugger.
431
432pub type UniqueDebuggerId = String;
433
434/// If 'debuggerId' is set stack trace comes from another debugger and can be resolved there. This
435/// allows to track cross-debugger calls. See 'Runtime.StackTrace' and 'Debugger.paused' for usages.
436
437#[derive(Debug, Clone, Serialize, Deserialize, Default)]
438#[serde(rename_all = "camelCase")]
439pub struct StackTraceId {
440
441    pub id: String,
442
443    #[serde(skip_serializing_if = "Option::is_none")]
444    pub debuggerId: Option<UniqueDebuggerId>,
445}
446
447/// Add handler to promise with given promise object id.
448
449#[derive(Debug, Clone, Serialize, Deserialize, Default)]
450#[serde(rename_all = "camelCase")]
451pub struct AwaitPromiseParams {
452    /// Identifier of the promise.
453
454    pub promiseObjectId: RemoteObjectId,
455    /// Whether the result is expected to be a JSON object that should be sent by value.
456
457    #[serde(skip_serializing_if = "Option::is_none")]
458    pub returnByValue: Option<bool>,
459    /// Whether preview should be generated for the result.
460
461    #[serde(skip_serializing_if = "Option::is_none")]
462    pub generatePreview: Option<bool>,
463}
464
465/// Add handler to promise with given promise object id.
466
467#[derive(Debug, Clone, Serialize, Deserialize, Default)]
468#[serde(rename_all = "camelCase")]
469pub struct AwaitPromiseReturns {
470    /// Promise result. Will contain rejected value if promise was rejected.
471
472    pub result: RemoteObject,
473    /// Exception details if stack strace is available.
474
475    #[serde(skip_serializing_if = "Option::is_none")]
476    pub exceptionDetails: Option<ExceptionDetails>,
477}
478
479impl AwaitPromiseParams { pub const METHOD: &'static str = "Runtime.awaitPromise"; }
480
481impl crate::CdpCommand for AwaitPromiseParams {
482    const METHOD: &'static str = "Runtime.awaitPromise";
483    type Response = AwaitPromiseReturns;
484}
485
486/// Calls function with given declaration on the given object. Object group of the result is
487/// inherited from the target object.
488
489#[derive(Debug, Clone, Serialize, Deserialize, Default)]
490#[serde(rename_all = "camelCase")]
491pub struct CallFunctionOnParams {
492    /// Declaration of the function to call.
493
494    pub functionDeclaration: String,
495    /// Identifier of the object to call function on. Either objectId or executionContextId should
496    /// be specified.
497
498    #[serde(skip_serializing_if = "Option::is_none")]
499    pub objectId: Option<RemoteObjectId>,
500    /// Call arguments. All call arguments must belong to the same JavaScript world as the target
501    /// object.
502
503    #[serde(skip_serializing_if = "Option::is_none")]
504    pub arguments: Option<Vec<CallArgument>>,
505    /// In silent mode exceptions thrown during evaluation are not reported and do not pause
506    /// execution. Overrides 'setPauseOnException' state.
507
508    #[serde(skip_serializing_if = "Option::is_none")]
509    pub silent: Option<bool>,
510    /// Whether the result is expected to be a JSON object which should be sent by value.
511    /// Can be overriden by 'serializationOptions'.
512
513    #[serde(skip_serializing_if = "Option::is_none")]
514    pub returnByValue: Option<bool>,
515    /// Whether preview should be generated for the result.
516
517    #[serde(skip_serializing_if = "Option::is_none")]
518    pub generatePreview: Option<bool>,
519    /// Whether execution should be treated as initiated by user in the UI.
520
521    #[serde(skip_serializing_if = "Option::is_none")]
522    pub userGesture: Option<bool>,
523    /// Whether execution should 'await' for resulting value and return once awaited promise is
524    /// resolved.
525
526    #[serde(skip_serializing_if = "Option::is_none")]
527    pub awaitPromise: Option<bool>,
528    /// Specifies execution context which global object will be used to call function on. Either
529    /// executionContextId or objectId should be specified.
530
531    #[serde(skip_serializing_if = "Option::is_none")]
532    pub executionContextId: Option<ExecutionContextId>,
533    /// Symbolic group name that can be used to release multiple objects. If objectGroup is not
534    /// specified and objectId is, objectGroup will be inherited from object.
535
536    #[serde(skip_serializing_if = "Option::is_none")]
537    pub objectGroup: Option<String>,
538    /// Whether to throw an exception if side effect cannot be ruled out during evaluation.
539
540    #[serde(skip_serializing_if = "Option::is_none")]
541    pub throwOnSideEffect: Option<bool>,
542    /// An alternative way to specify the execution context to call function on.
543    /// Compared to contextId that may be reused across processes, this is guaranteed to be
544    /// system-unique, so it can be used to prevent accidental function call
545    /// in context different than intended (e.g. as a result of navigation across process
546    /// boundaries).
547    /// This is mutually exclusive with 'executionContextId'.
548
549    #[serde(skip_serializing_if = "Option::is_none")]
550    pub uniqueContextId: Option<String>,
551    /// Specifies the result serialization. If provided, overrides
552    /// 'generatePreview' and 'returnByValue'.
553
554    #[serde(skip_serializing_if = "Option::is_none")]
555    pub serializationOptions: Option<SerializationOptions>,
556}
557
558/// Calls function with given declaration on the given object. Object group of the result is
559/// inherited from the target object.
560
561#[derive(Debug, Clone, Serialize, Deserialize, Default)]
562#[serde(rename_all = "camelCase")]
563pub struct CallFunctionOnReturns {
564    /// Call result.
565
566    pub result: RemoteObject,
567    /// Exception details.
568
569    #[serde(skip_serializing_if = "Option::is_none")]
570    pub exceptionDetails: Option<ExceptionDetails>,
571}
572
573impl CallFunctionOnParams { pub const METHOD: &'static str = "Runtime.callFunctionOn"; }
574
575impl crate::CdpCommand for CallFunctionOnParams {
576    const METHOD: &'static str = "Runtime.callFunctionOn";
577    type Response = CallFunctionOnReturns;
578}
579
580/// Compiles expression.
581
582#[derive(Debug, Clone, Serialize, Deserialize, Default)]
583#[serde(rename_all = "camelCase")]
584pub struct CompileScriptParams {
585    /// Expression to compile.
586
587    pub expression: String,
588    /// Source url to be set for the script.
589
590    pub sourceURL: String,
591    /// Specifies whether the compiled script should be persisted.
592
593    pub persistScript: bool,
594    /// Specifies in which execution context to perform script run. If the parameter is omitted the
595    /// evaluation will be performed in the context of the inspected page.
596
597    #[serde(skip_serializing_if = "Option::is_none")]
598    pub executionContextId: Option<ExecutionContextId>,
599}
600
601/// Compiles expression.
602
603#[derive(Debug, Clone, Serialize, Deserialize, Default)]
604#[serde(rename_all = "camelCase")]
605pub struct CompileScriptReturns {
606    /// Id of the script.
607
608    #[serde(skip_serializing_if = "Option::is_none")]
609    pub scriptId: Option<ScriptId>,
610    /// Exception details.
611
612    #[serde(skip_serializing_if = "Option::is_none")]
613    pub exceptionDetails: Option<ExceptionDetails>,
614}
615
616impl CompileScriptParams { pub const METHOD: &'static str = "Runtime.compileScript"; }
617
618impl crate::CdpCommand for CompileScriptParams {
619    const METHOD: &'static str = "Runtime.compileScript";
620    type Response = CompileScriptReturns;
621}
622
623#[derive(Debug, Clone, Serialize, Deserialize, Default)]
624pub struct DisableParams {}
625
626impl DisableParams { pub const METHOD: &'static str = "Runtime.disable"; }
627
628impl crate::CdpCommand for DisableParams {
629    const METHOD: &'static str = "Runtime.disable";
630    type Response = crate::EmptyReturns;
631}
632
633#[derive(Debug, Clone, Serialize, Deserialize, Default)]
634pub struct DiscardConsoleEntriesParams {}
635
636impl DiscardConsoleEntriesParams { pub const METHOD: &'static str = "Runtime.discardConsoleEntries"; }
637
638impl crate::CdpCommand for DiscardConsoleEntriesParams {
639    const METHOD: &'static str = "Runtime.discardConsoleEntries";
640    type Response = crate::EmptyReturns;
641}
642
643#[derive(Debug, Clone, Serialize, Deserialize, Default)]
644pub struct EnableParams {}
645
646impl EnableParams { pub const METHOD: &'static str = "Runtime.enable"; }
647
648impl crate::CdpCommand for EnableParams {
649    const METHOD: &'static str = "Runtime.enable";
650    type Response = crate::EmptyReturns;
651}
652
653/// Evaluates expression on global object.
654
655#[derive(Debug, Clone, Serialize, Deserialize, Default)]
656#[serde(rename_all = "camelCase")]
657pub struct EvaluateParams {
658    /// Expression to evaluate.
659
660    pub expression: String,
661    /// Symbolic group name that can be used to release multiple objects.
662
663    #[serde(skip_serializing_if = "Option::is_none")]
664    pub objectGroup: Option<String>,
665    /// Determines whether Command Line API should be available during the evaluation.
666
667    #[serde(skip_serializing_if = "Option::is_none")]
668    pub includeCommandLineAPI: Option<bool>,
669    /// In silent mode exceptions thrown during evaluation are not reported and do not pause
670    /// execution. Overrides 'setPauseOnException' state.
671
672    #[serde(skip_serializing_if = "Option::is_none")]
673    pub silent: Option<bool>,
674    /// Specifies in which execution context to perform evaluation. If the parameter is omitted the
675    /// evaluation will be performed in the context of the inspected page.
676    /// This is mutually exclusive with 'uniqueContextId', which offers an
677    /// alternative way to identify the execution context that is more reliable
678    /// in a multi-process environment.
679
680    #[serde(skip_serializing_if = "Option::is_none")]
681    pub contextId: Option<ExecutionContextId>,
682    /// Whether the result is expected to be a JSON object that should be sent by value.
683
684    #[serde(skip_serializing_if = "Option::is_none")]
685    pub returnByValue: Option<bool>,
686    /// Whether preview should be generated for the result.
687
688    #[serde(skip_serializing_if = "Option::is_none")]
689    pub generatePreview: Option<bool>,
690    /// Whether execution should be treated as initiated by user in the UI.
691
692    #[serde(skip_serializing_if = "Option::is_none")]
693    pub userGesture: Option<bool>,
694    /// Whether execution should 'await' for resulting value and return once awaited promise is
695    /// resolved.
696
697    #[serde(skip_serializing_if = "Option::is_none")]
698    pub awaitPromise: Option<bool>,
699    /// Whether to throw an exception if side effect cannot be ruled out during evaluation.
700    /// This implies 'disableBreaks' below.
701
702    #[serde(skip_serializing_if = "Option::is_none")]
703    pub throwOnSideEffect: Option<bool>,
704    /// Terminate execution after timing out (number of milliseconds).
705
706    #[serde(skip_serializing_if = "Option::is_none")]
707    pub timeout: Option<TimeDelta>,
708    /// Disable breakpoints during execution.
709
710    #[serde(skip_serializing_if = "Option::is_none")]
711    pub disableBreaks: Option<bool>,
712    /// Setting this flag to true enables 'let' re-declaration and top-level 'await'.
713    /// Note that 'let' variables can only be re-declared if they originate from
714    /// 'replMode' themselves.
715
716    #[serde(skip_serializing_if = "Option::is_none")]
717    pub replMode: Option<bool>,
718    /// The Content Security Policy (CSP) for the target might block 'unsafe-eval'
719    /// which includes eval(), Function(), setTimeout() and setInterval()
720    /// when called with non-callable arguments. This flag bypasses CSP for this
721    /// evaluation and allows unsafe-eval. Defaults to true.
722
723    #[serde(skip_serializing_if = "Option::is_none")]
724    pub allowUnsafeEvalBlockedByCSP: Option<bool>,
725    /// An alternative way to specify the execution context to evaluate in.
726    /// Compared to contextId that may be reused across processes, this is guaranteed to be
727    /// system-unique, so it can be used to prevent accidental evaluation of the expression
728    /// in context different than intended (e.g. as a result of navigation across process
729    /// boundaries).
730    /// This is mutually exclusive with 'contextId'.
731
732    #[serde(skip_serializing_if = "Option::is_none")]
733    pub uniqueContextId: Option<String>,
734    /// Specifies the result serialization. If provided, overrides
735    /// 'generatePreview' and 'returnByValue'.
736
737    #[serde(skip_serializing_if = "Option::is_none")]
738    pub serializationOptions: Option<SerializationOptions>,
739}
740
741/// Evaluates expression on global object.
742
743#[derive(Debug, Clone, Serialize, Deserialize, Default)]
744#[serde(rename_all = "camelCase")]
745pub struct EvaluateReturns {
746    /// Evaluation result.
747
748    pub result: RemoteObject,
749    /// Exception details.
750
751    #[serde(skip_serializing_if = "Option::is_none")]
752    pub exceptionDetails: Option<ExceptionDetails>,
753}
754
755impl EvaluateParams { pub const METHOD: &'static str = "Runtime.evaluate"; }
756
757impl crate::CdpCommand for EvaluateParams {
758    const METHOD: &'static str = "Runtime.evaluate";
759    type Response = EvaluateReturns;
760}
761
762/// Returns the isolate id.
763
764#[derive(Debug, Clone, Serialize, Deserialize, Default)]
765#[serde(rename_all = "camelCase")]
766pub struct GetIsolateIdReturns {
767    /// The isolate id.
768
769    pub id: String,
770}
771
772#[derive(Debug, Clone, Serialize, Deserialize, Default)]
773pub struct GetIsolateIdParams {}
774
775impl GetIsolateIdParams { pub const METHOD: &'static str = "Runtime.getIsolateId"; }
776
777impl crate::CdpCommand for GetIsolateIdParams {
778    const METHOD: &'static str = "Runtime.getIsolateId";
779    type Response = GetIsolateIdReturns;
780}
781
782/// Returns the JavaScript heap usage.
783/// It is the total usage of the corresponding isolate not scoped to a particular Runtime.
784
785#[derive(Debug, Clone, Serialize, Deserialize, Default)]
786#[serde(rename_all = "camelCase")]
787pub struct GetHeapUsageReturns {
788    /// Used JavaScript heap size in bytes.
789
790    pub usedSize: f64,
791    /// Allocated JavaScript heap size in bytes.
792
793    pub totalSize: f64,
794    /// Used size in bytes in the embedder's garbage-collected heap.
795
796    pub embedderHeapUsedSize: f64,
797    /// Size in bytes of backing storage for array buffers and external strings.
798
799    pub backingStorageSize: f64,
800}
801
802#[derive(Debug, Clone, Serialize, Deserialize, Default)]
803pub struct GetHeapUsageParams {}
804
805impl GetHeapUsageParams { pub const METHOD: &'static str = "Runtime.getHeapUsage"; }
806
807impl crate::CdpCommand for GetHeapUsageParams {
808    const METHOD: &'static str = "Runtime.getHeapUsage";
809    type Response = GetHeapUsageReturns;
810}
811
812/// Returns properties of a given object. Object group of the result is inherited from the target
813/// object.
814
815#[derive(Debug, Clone, Serialize, Deserialize, Default)]
816#[serde(rename_all = "camelCase")]
817pub struct GetPropertiesParams {
818    /// Identifier of the object to return properties for.
819
820    pub objectId: RemoteObjectId,
821    /// If true, returns properties belonging only to the element itself, not to its prototype
822    /// chain.
823
824    #[serde(skip_serializing_if = "Option::is_none")]
825    pub ownProperties: Option<bool>,
826    /// If true, returns accessor properties (with getter/setter) only; internal properties are not
827    /// returned either.
828
829    #[serde(skip_serializing_if = "Option::is_none")]
830    pub accessorPropertiesOnly: Option<bool>,
831    /// Whether preview should be generated for the results.
832
833    #[serde(skip_serializing_if = "Option::is_none")]
834    pub generatePreview: Option<bool>,
835    /// If true, returns non-indexed properties only.
836
837    #[serde(skip_serializing_if = "Option::is_none")]
838    pub nonIndexedPropertiesOnly: Option<bool>,
839}
840
841/// Returns properties of a given object. Object group of the result is inherited from the target
842/// object.
843
844#[derive(Debug, Clone, Serialize, Deserialize, Default)]
845#[serde(rename_all = "camelCase")]
846pub struct GetPropertiesReturns {
847    /// Object properties.
848
849    pub result: Vec<PropertyDescriptor>,
850    /// Internal object properties (only of the element itself).
851
852    #[serde(skip_serializing_if = "Option::is_none")]
853    pub internalProperties: Option<Vec<InternalPropertyDescriptor>>,
854    /// Object private properties.
855
856    #[serde(skip_serializing_if = "Option::is_none")]
857    pub privateProperties: Option<Vec<PrivatePropertyDescriptor>>,
858    /// Exception details.
859
860    #[serde(skip_serializing_if = "Option::is_none")]
861    pub exceptionDetails: Option<ExceptionDetails>,
862}
863
864impl GetPropertiesParams { pub const METHOD: &'static str = "Runtime.getProperties"; }
865
866impl crate::CdpCommand for GetPropertiesParams {
867    const METHOD: &'static str = "Runtime.getProperties";
868    type Response = GetPropertiesReturns;
869}
870
871/// Returns all let, const and class variables from global scope.
872
873#[derive(Debug, Clone, Serialize, Deserialize, Default)]
874#[serde(rename_all = "camelCase")]
875pub struct GlobalLexicalScopeNamesParams {
876    /// Specifies in which execution context to lookup global scope variables.
877
878    #[serde(skip_serializing_if = "Option::is_none")]
879    pub executionContextId: Option<ExecutionContextId>,
880}
881
882/// Returns all let, const and class variables from global scope.
883
884#[derive(Debug, Clone, Serialize, Deserialize, Default)]
885#[serde(rename_all = "camelCase")]
886pub struct GlobalLexicalScopeNamesReturns {
887
888    pub names: Vec<String>,
889}
890
891impl GlobalLexicalScopeNamesParams { pub const METHOD: &'static str = "Runtime.globalLexicalScopeNames"; }
892
893impl crate::CdpCommand for GlobalLexicalScopeNamesParams {
894    const METHOD: &'static str = "Runtime.globalLexicalScopeNames";
895    type Response = GlobalLexicalScopeNamesReturns;
896}
897
898
899#[derive(Debug, Clone, Serialize, Deserialize, Default)]
900#[serde(rename_all = "camelCase")]
901pub struct QueryObjectsParams {
902    /// Identifier of the prototype to return objects for.
903
904    pub prototypeObjectId: RemoteObjectId,
905    /// Symbolic group name that can be used to release the results.
906
907    #[serde(skip_serializing_if = "Option::is_none")]
908    pub objectGroup: Option<String>,
909}
910
911
912#[derive(Debug, Clone, Serialize, Deserialize, Default)]
913#[serde(rename_all = "camelCase")]
914pub struct QueryObjectsReturns {
915    /// Array with objects.
916
917    pub objects: RemoteObject,
918}
919
920impl QueryObjectsParams { pub const METHOD: &'static str = "Runtime.queryObjects"; }
921
922impl crate::CdpCommand for QueryObjectsParams {
923    const METHOD: &'static str = "Runtime.queryObjects";
924    type Response = QueryObjectsReturns;
925}
926
927/// Releases remote object with given id.
928
929#[derive(Debug, Clone, Serialize, Deserialize, Default)]
930#[serde(rename_all = "camelCase")]
931pub struct ReleaseObjectParams {
932    /// Identifier of the object to release.
933
934    pub objectId: RemoteObjectId,
935}
936
937impl ReleaseObjectParams { pub const METHOD: &'static str = "Runtime.releaseObject"; }
938
939impl crate::CdpCommand for ReleaseObjectParams {
940    const METHOD: &'static str = "Runtime.releaseObject";
941    type Response = crate::EmptyReturns;
942}
943
944/// Releases all remote objects that belong to a given group.
945
946#[derive(Debug, Clone, Serialize, Deserialize, Default)]
947#[serde(rename_all = "camelCase")]
948pub struct ReleaseObjectGroupParams {
949    /// Symbolic object group name.
950
951    pub objectGroup: String,
952}
953
954impl ReleaseObjectGroupParams { pub const METHOD: &'static str = "Runtime.releaseObjectGroup"; }
955
956impl crate::CdpCommand for ReleaseObjectGroupParams {
957    const METHOD: &'static str = "Runtime.releaseObjectGroup";
958    type Response = crate::EmptyReturns;
959}
960
961#[derive(Debug, Clone, Serialize, Deserialize, Default)]
962pub struct RunIfWaitingForDebuggerParams {}
963
964impl RunIfWaitingForDebuggerParams { pub const METHOD: &'static str = "Runtime.runIfWaitingForDebugger"; }
965
966impl crate::CdpCommand for RunIfWaitingForDebuggerParams {
967    const METHOD: &'static str = "Runtime.runIfWaitingForDebugger";
968    type Response = crate::EmptyReturns;
969}
970
971/// Runs script with given id in a given context.
972
973#[derive(Debug, Clone, Serialize, Deserialize, Default)]
974#[serde(rename_all = "camelCase")]
975pub struct RunScriptParams {
976    /// Id of the script to run.
977
978    pub scriptId: ScriptId,
979    /// Specifies in which execution context to perform script run. If the parameter is omitted the
980    /// evaluation will be performed in the context of the inspected page.
981
982    #[serde(skip_serializing_if = "Option::is_none")]
983    pub executionContextId: Option<ExecutionContextId>,
984    /// Symbolic group name that can be used to release multiple objects.
985
986    #[serde(skip_serializing_if = "Option::is_none")]
987    pub objectGroup: Option<String>,
988    /// In silent mode exceptions thrown during evaluation are not reported and do not pause
989    /// execution. Overrides 'setPauseOnException' state.
990
991    #[serde(skip_serializing_if = "Option::is_none")]
992    pub silent: Option<bool>,
993    /// Determines whether Command Line API should be available during the evaluation.
994
995    #[serde(skip_serializing_if = "Option::is_none")]
996    pub includeCommandLineAPI: Option<bool>,
997    /// Whether the result is expected to be a JSON object which should be sent by value.
998
999    #[serde(skip_serializing_if = "Option::is_none")]
1000    pub returnByValue: Option<bool>,
1001    /// Whether preview should be generated for the result.
1002
1003    #[serde(skip_serializing_if = "Option::is_none")]
1004    pub generatePreview: Option<bool>,
1005    /// Whether execution should 'await' for resulting value and return once awaited promise is
1006    /// resolved.
1007
1008    #[serde(skip_serializing_if = "Option::is_none")]
1009    pub awaitPromise: Option<bool>,
1010}
1011
1012/// Runs script with given id in a given context.
1013
1014#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1015#[serde(rename_all = "camelCase")]
1016pub struct RunScriptReturns {
1017    /// Run result.
1018
1019    pub result: RemoteObject,
1020    /// Exception details.
1021
1022    #[serde(skip_serializing_if = "Option::is_none")]
1023    pub exceptionDetails: Option<ExceptionDetails>,
1024}
1025
1026impl RunScriptParams { pub const METHOD: &'static str = "Runtime.runScript"; }
1027
1028impl crate::CdpCommand for RunScriptParams {
1029    const METHOD: &'static str = "Runtime.runScript";
1030    type Response = RunScriptReturns;
1031}
1032
1033/// Enables or disables async call stacks tracking.
1034
1035#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1036#[serde(rename_all = "camelCase")]
1037pub struct SetAsyncCallStackDepthParams {
1038    /// Maximum depth of async call stacks. Setting to '0' will effectively disable collecting async
1039    /// call stacks (default).
1040
1041    pub maxDepth: i64,
1042}
1043
1044impl SetAsyncCallStackDepthParams { pub const METHOD: &'static str = "Runtime.setAsyncCallStackDepth"; }
1045
1046impl crate::CdpCommand for SetAsyncCallStackDepthParams {
1047    const METHOD: &'static str = "Runtime.setAsyncCallStackDepth";
1048    type Response = crate::EmptyReturns;
1049}
1050
1051
1052#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1053#[serde(rename_all = "camelCase")]
1054pub struct SetCustomObjectFormatterEnabledParams {
1055
1056    pub enabled: bool,
1057}
1058
1059impl SetCustomObjectFormatterEnabledParams { pub const METHOD: &'static str = "Runtime.setCustomObjectFormatterEnabled"; }
1060
1061impl crate::CdpCommand for SetCustomObjectFormatterEnabledParams {
1062    const METHOD: &'static str = "Runtime.setCustomObjectFormatterEnabled";
1063    type Response = crate::EmptyReturns;
1064}
1065
1066
1067#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1068#[serde(rename_all = "camelCase")]
1069pub struct SetMaxCallStackSizeToCaptureParams {
1070
1071    pub size: u64,
1072}
1073
1074impl SetMaxCallStackSizeToCaptureParams { pub const METHOD: &'static str = "Runtime.setMaxCallStackSizeToCapture"; }
1075
1076impl crate::CdpCommand for SetMaxCallStackSizeToCaptureParams {
1077    const METHOD: &'static str = "Runtime.setMaxCallStackSizeToCapture";
1078    type Response = crate::EmptyReturns;
1079}
1080
1081#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1082pub struct TerminateExecutionParams {}
1083
1084impl TerminateExecutionParams { pub const METHOD: &'static str = "Runtime.terminateExecution"; }
1085
1086impl crate::CdpCommand for TerminateExecutionParams {
1087    const METHOD: &'static str = "Runtime.terminateExecution";
1088    type Response = crate::EmptyReturns;
1089}
1090
1091/// If executionContextId is empty, adds binding with the given name on the
1092/// global objects of all inspected contexts, including those created later,
1093/// bindings survive reloads.
1094/// Binding function takes exactly one argument, this argument should be string,
1095/// in case of any other input, function throws an exception.
1096/// Each binding function call produces Runtime.bindingCalled notification.
1097
1098#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1099#[serde(rename_all = "camelCase")]
1100pub struct AddBindingParams {
1101
1102    pub name: String,
1103    /// If specified, the binding would only be exposed to the specified
1104    /// execution context. If omitted and 'executionContextName' is not set,
1105    /// the binding is exposed to all execution contexts of the target.
1106    /// This parameter is mutually exclusive with 'executionContextName'.
1107    /// Deprecated in favor of 'executionContextName' due to an unclear use case
1108    /// and bugs in implementation (crbug.com/1169639). 'executionContextId' will be
1109    /// removed in the future.
1110
1111    #[serde(skip_serializing_if = "Option::is_none")]
1112    pub executionContextId: Option<ExecutionContextId>,
1113    /// If specified, the binding is exposed to the executionContext with
1114    /// matching name, even for contexts created after the binding is added.
1115    /// See also 'ExecutionContext.name' and 'worldName' parameter to
1116    /// 'Page.addScriptToEvaluateOnNewDocument'.
1117    /// This parameter is mutually exclusive with 'executionContextId'.
1118
1119    #[serde(skip_serializing_if = "Option::is_none")]
1120    pub executionContextName: Option<String>,
1121}
1122
1123impl AddBindingParams { pub const METHOD: &'static str = "Runtime.addBinding"; }
1124
1125impl crate::CdpCommand for AddBindingParams {
1126    const METHOD: &'static str = "Runtime.addBinding";
1127    type Response = crate::EmptyReturns;
1128}
1129
1130/// This method does not remove binding function from global object but
1131/// unsubscribes current runtime agent from Runtime.bindingCalled notifications.
1132
1133#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1134#[serde(rename_all = "camelCase")]
1135pub struct RemoveBindingParams {
1136
1137    pub name: String,
1138}
1139
1140impl RemoveBindingParams { pub const METHOD: &'static str = "Runtime.removeBinding"; }
1141
1142impl crate::CdpCommand for RemoveBindingParams {
1143    const METHOD: &'static str = "Runtime.removeBinding";
1144    type Response = crate::EmptyReturns;
1145}
1146
1147/// This method tries to lookup and populate exception details for a
1148/// JavaScript Error object.
1149/// Note that the stackTrace portion of the resulting exceptionDetails will
1150/// only be populated if the Runtime domain was enabled at the time when the
1151/// Error was thrown.
1152
1153#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1154#[serde(rename_all = "camelCase")]
1155pub struct GetExceptionDetailsParams {
1156    /// The error object for which to resolve the exception details.
1157
1158    pub errorObjectId: RemoteObjectId,
1159}
1160
1161/// This method tries to lookup and populate exception details for a
1162/// JavaScript Error object.
1163/// Note that the stackTrace portion of the resulting exceptionDetails will
1164/// only be populated if the Runtime domain was enabled at the time when the
1165/// Error was thrown.
1166
1167#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1168#[serde(rename_all = "camelCase")]
1169pub struct GetExceptionDetailsReturns {
1170
1171    #[serde(skip_serializing_if = "Option::is_none")]
1172    pub exceptionDetails: Option<ExceptionDetails>,
1173}
1174
1175impl GetExceptionDetailsParams { pub const METHOD: &'static str = "Runtime.getExceptionDetails"; }
1176
1177impl crate::CdpCommand for GetExceptionDetailsParams {
1178    const METHOD: &'static str = "Runtime.getExceptionDetails";
1179    type Response = GetExceptionDetailsReturns;
1180}