viewpoint_cdp/protocol/
page.rs

1//! Page domain types.
2//!
3//! The Page domain provides actions and events related to the inspected page.
4
5use serde::{Deserialize, Serialize};
6
7/// Frame information.
8#[derive(Debug, Clone, Deserialize)]
9#[serde(rename_all = "camelCase")]
10pub struct Frame {
11    /// Frame unique identifier.
12    pub id: String,
13    /// Parent frame identifier.
14    pub parent_id: Option<String>,
15    /// Identifier of the loader associated with this frame.
16    pub loader_id: String,
17    /// Frame's name as specified in the tag.
18    pub name: Option<String>,
19    /// Frame document's URL.
20    pub url: String,
21    /// Frame document's security origin.
22    pub security_origin: Option<String>,
23    /// Frame document's mimeType.
24    pub mime_type: Option<String>,
25}
26
27/// Parameters for Page.navigate.
28#[derive(Debug, Clone, Serialize)]
29#[serde(rename_all = "camelCase")]
30pub struct NavigateParams {
31    /// URL to navigate the page to.
32    pub url: String,
33    /// Referrer URL.
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub referrer: Option<String>,
36    /// Intended transition type.
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub transition_type: Option<String>,
39    /// Frame id to navigate.
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub frame_id: Option<String>,
42}
43
44/// Result of Page.navigate.
45#[derive(Debug, Clone, Deserialize)]
46#[serde(rename_all = "camelCase")]
47pub struct NavigateResult {
48    /// Frame id that has navigated (or failed to navigate).
49    pub frame_id: String,
50    /// Loader identifier.
51    pub loader_id: Option<String>,
52    /// User friendly error message if navigation failed.
53    pub error_text: Option<String>,
54}
55
56/// Parameters for Page.reload.
57#[derive(Debug, Clone, Serialize, Default)]
58#[serde(rename_all = "camelCase")]
59pub struct ReloadParams {
60    /// If true, browser cache is ignored.
61    #[serde(skip_serializing_if = "Option::is_none")]
62    pub ignore_cache: Option<bool>,
63    /// Script to inject into all frames.
64    #[serde(skip_serializing_if = "Option::is_none")]
65    pub script_to_evaluate_on_load: Option<String>,
66}
67
68/// Result of Page.getFrameTree.
69#[derive(Debug, Clone, Deserialize)]
70#[serde(rename_all = "camelCase")]
71pub struct GetFrameTreeResult {
72    /// Frame tree structure.
73    pub frame_tree: FrameTree,
74}
75
76/// Frame tree structure.
77#[derive(Debug, Clone, Deserialize)]
78#[serde(rename_all = "camelCase")]
79pub struct FrameTree {
80    /// Frame information.
81    pub frame: Frame,
82    /// Child frames.
83    pub child_frames: Option<Vec<FrameTree>>,
84}
85
86/// Event: Page.loadEventFired
87#[derive(Debug, Clone, Deserialize)]
88pub struct LoadEventFiredEvent {
89    /// Monotonic time.
90    pub timestamp: f64,
91}
92
93/// Event: Page.domContentEventFired
94#[derive(Debug, Clone, Deserialize)]
95pub struct DomContentEventFiredEvent {
96    /// Monotonic time.
97    pub timestamp: f64,
98}
99
100/// Event: Page.frameNavigated
101#[derive(Debug, Clone, Deserialize)]
102#[serde(rename_all = "camelCase")]
103pub struct FrameNavigatedEvent {
104    /// Frame object.
105    pub frame: Frame,
106    /// Navigation type.
107    #[serde(rename = "type")]
108    pub navigation_type: Option<String>,
109}
110
111/// Event: Page.frameStartedLoading
112#[derive(Debug, Clone, Deserialize)]
113#[serde(rename_all = "camelCase")]
114pub struct FrameStartedLoadingEvent {
115    /// Frame ID.
116    pub frame_id: String,
117}
118
119/// Event: Page.frameStoppedLoading
120#[derive(Debug, Clone, Deserialize)]
121#[serde(rename_all = "camelCase")]
122pub struct FrameStoppedLoadingEvent {
123    /// Frame ID.
124    pub frame_id: String,
125}
126
127/// Event: Page.lifecycleEvent
128#[derive(Debug, Clone, Deserialize)]
129#[serde(rename_all = "camelCase")]
130pub struct LifecycleEvent {
131    /// Frame ID.
132    pub frame_id: String,
133    /// Loader identifier.
134    pub loader_id: String,
135    /// Lifecycle event name.
136    pub name: String,
137    /// Timestamp.
138    pub timestamp: f64,
139}
140
141/// Parameters for Page.setLifecycleEventsEnabled.
142#[derive(Debug, Clone, Serialize)]
143pub struct SetLifecycleEventsEnabledParams {
144    /// Whether to enable lifecycle events.
145    pub enabled: bool,
146}