Skip to main content

browser_protocol/emulation/
mod.rs

1//! This domain emulates different environments for the page.
2
3use serde::{Serialize, Deserialize};
4
5
6#[derive(Debug, Clone, Serialize, Deserialize, Default)]
7#[serde(rename_all = "camelCase")]
8pub struct SafeAreaInsets {
9    /// Overrides safe-area-inset-top.
10
11    #[serde(skip_serializing_if = "Option::is_none")]
12    pub top: Option<i64>,
13    /// Overrides safe-area-max-inset-top.
14
15    #[serde(skip_serializing_if = "Option::is_none")]
16    pub topMax: Option<i64>,
17    /// Overrides safe-area-inset-left.
18
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub left: Option<i64>,
21    /// Overrides safe-area-max-inset-left.
22
23    #[serde(skip_serializing_if = "Option::is_none")]
24    pub leftMax: Option<i64>,
25    /// Overrides safe-area-inset-bottom.
26
27    #[serde(skip_serializing_if = "Option::is_none")]
28    pub bottom: Option<i64>,
29    /// Overrides safe-area-max-inset-bottom.
30
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub bottomMax: Option<i64>,
33    /// Overrides safe-area-inset-right.
34
35    #[serde(skip_serializing_if = "Option::is_none")]
36    pub right: Option<i64>,
37    /// Overrides safe-area-max-inset-right.
38
39    #[serde(skip_serializing_if = "Option::is_none")]
40    pub rightMax: Option<i64>,
41}
42
43/// Screen orientation.
44
45#[derive(Debug, Clone, Serialize, Deserialize, Default)]
46#[serde(rename_all = "camelCase")]
47pub struct ScreenOrientation {
48    /// Orientation type.
49
50    #[serde(rename = "type")]
51    pub type_: String,
52    /// Orientation angle.
53
54    pub angle: i64,
55}
56
57
58#[derive(Debug, Clone, Serialize, Deserialize, Default)]
59#[serde(rename_all = "camelCase")]
60pub struct DisplayFeature {
61    /// Orientation of a display feature in relation to screen
62
63    pub orientation: String,
64    /// The offset from the screen origin in either the x (for vertical
65    /// orientation) or y (for horizontal orientation) direction.
66
67    pub offset: i32,
68    /// A display feature may mask content such that it is not physically
69    /// displayed - this length along with the offset describes this area.
70    /// A display feature that only splits content will have a 0 mask_length.
71
72    pub maskLength: u64,
73}
74
75
76#[derive(Debug, Clone, Serialize, Deserialize, Default)]
77#[serde(rename_all = "camelCase")]
78pub struct DevicePosture {
79    /// Current posture of the device
80
81    #[serde(rename = "type")]
82    pub type_: String,
83}
84
85
86#[derive(Debug, Clone, Serialize, Deserialize, Default)]
87#[serde(rename_all = "camelCase")]
88pub struct MediaFeature {
89
90    pub name: String,
91
92    pub value: String,
93}
94
95/// advance: If the scheduler runs out of immediate work, the virtual time base may fast forward to
96/// allow the next delayed task (if any) to run; pause: The virtual time base may not advance;
97/// pauseIfNetworkFetchesPending: The virtual time base may not advance if there are any pending
98/// resource fetches.
99
100#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
101pub enum VirtualTimePolicy {
102    #[default]
103    Advance,
104    Pause,
105    PauseIfNetworkFetchesPending,
106}
107
108/// Used to specify User Agent Client Hints to emulate. See <https://wicg.github.io/ua-client-hints>
109
110#[derive(Debug, Clone, Serialize, Deserialize, Default)]
111#[serde(rename_all = "camelCase")]
112pub struct UserAgentBrandVersion {
113
114    pub brand: String,
115
116    pub version: String,
117}
118
119/// Used to specify User Agent Client Hints to emulate. See <https://wicg.github.io/ua-client-hints>
120/// Missing optional values will be filled in by the target with what it would normally use.
121
122#[derive(Debug, Clone, Serialize, Deserialize, Default)]
123#[serde(rename_all = "camelCase")]
124pub struct UserAgentMetadata {
125    /// Brands appearing in Sec-CH-UA.
126
127    #[serde(skip_serializing_if = "Option::is_none")]
128    pub brands: Option<Vec<UserAgentBrandVersion>>,
129    /// Brands appearing in Sec-CH-UA-Full-Version-List.
130
131    #[serde(skip_serializing_if = "Option::is_none")]
132    pub fullVersionList: Option<Vec<UserAgentBrandVersion>>,
133
134    #[serde(skip_serializing_if = "Option::is_none")]
135    pub fullVersion: Option<String>,
136
137    pub platform: String,
138
139    pub platformVersion: String,
140
141    pub architecture: String,
142
143    pub model: String,
144
145    pub mobile: bool,
146
147    #[serde(skip_serializing_if = "Option::is_none")]
148    pub bitness: Option<String>,
149
150    #[serde(skip_serializing_if = "Option::is_none")]
151    pub wow64: Option<bool>,
152    /// Used to specify User Agent form-factor values.
153    /// See <https://wicg.github.io/ua-client-hints/#sec-ch-ua-form-factors>
154
155    #[serde(skip_serializing_if = "Option::is_none")]
156    pub formFactors: Option<Vec<String>>,
157}
158
159/// Used to specify sensor types to emulate.
160/// See <https://w3c.github.io/sensors/#automation> for more information.
161
162#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
163pub enum SensorType {
164    #[default]
165    AbsoluteOrientation,
166    Accelerometer,
167    AmbientLight,
168    Gravity,
169    Gyroscope,
170    LinearAcceleration,
171    Magnetometer,
172    RelativeOrientation,
173}
174
175
176#[derive(Debug, Clone, Serialize, Deserialize, Default)]
177#[serde(rename_all = "camelCase")]
178pub struct SensorMetadata {
179
180    #[serde(skip_serializing_if = "Option::is_none")]
181    pub available: Option<bool>,
182
183    #[serde(skip_serializing_if = "Option::is_none")]
184    pub minimumFrequency: Option<f64>,
185
186    #[serde(skip_serializing_if = "Option::is_none")]
187    pub maximumFrequency: Option<f64>,
188}
189
190
191#[derive(Debug, Clone, Serialize, Deserialize, Default)]
192#[serde(rename_all = "camelCase")]
193pub struct SensorReadingSingle {
194
195    pub value: f64,
196}
197
198
199#[derive(Debug, Clone, Serialize, Deserialize, Default)]
200#[serde(rename_all = "camelCase")]
201pub struct SensorReadingXYZ {
202
203    pub x: f64,
204
205    pub y: f64,
206
207    pub z: f64,
208}
209
210
211#[derive(Debug, Clone, Serialize, Deserialize, Default)]
212#[serde(rename_all = "camelCase")]
213pub struct SensorReadingQuaternion {
214
215    pub x: f64,
216
217    pub y: f64,
218
219    pub z: f64,
220
221    pub w: f64,
222}
223
224
225#[derive(Debug, Clone, Serialize, Deserialize, Default)]
226#[serde(rename_all = "camelCase")]
227pub struct SensorReading {
228
229    #[serde(skip_serializing_if = "Option::is_none")]
230    pub single: Option<SensorReadingSingle>,
231
232    #[serde(skip_serializing_if = "Option::is_none")]
233    pub xyz: Option<SensorReadingXYZ>,
234
235    #[serde(skip_serializing_if = "Option::is_none")]
236    pub quaternion: Option<SensorReadingQuaternion>,
237}
238
239
240#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
241pub enum PressureSource {
242    #[default]
243    Cpu,
244}
245
246
247#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
248pub enum PressureState {
249    #[default]
250    Nominal,
251    Fair,
252    Serious,
253    Critical,
254}
255
256
257#[derive(Debug, Clone, Serialize, Deserialize, Default)]
258#[serde(rename_all = "camelCase")]
259pub struct PressureMetadata {
260
261    #[serde(skip_serializing_if = "Option::is_none")]
262    pub available: Option<bool>,
263}
264
265
266#[derive(Debug, Clone, Serialize, Deserialize, Default)]
267#[serde(rename_all = "camelCase")]
268pub struct WorkAreaInsets {
269    /// Work area top inset in pixels. Default is 0;
270
271    #[serde(skip_serializing_if = "Option::is_none")]
272    pub top: Option<i64>,
273    /// Work area left inset in pixels. Default is 0;
274
275    #[serde(skip_serializing_if = "Option::is_none")]
276    pub left: Option<i64>,
277    /// Work area bottom inset in pixels. Default is 0;
278
279    #[serde(skip_serializing_if = "Option::is_none")]
280    pub bottom: Option<i64>,
281    /// Work area right inset in pixels. Default is 0;
282
283    #[serde(skip_serializing_if = "Option::is_none")]
284    pub right: Option<i64>,
285}
286
287
288pub type ScreenId = String;
289
290/// Screen information similar to the one returned by window.getScreenDetails() method,
291/// see <https://w3c.github.io/window-management/#screendetailed.>
292
293#[derive(Debug, Clone, Serialize, Deserialize, Default)]
294#[serde(rename_all = "camelCase")]
295pub struct ScreenInfo {
296    /// Offset of the left edge of the screen.
297
298    pub left: i64,
299    /// Offset of the top edge of the screen.
300
301    pub top: i64,
302    /// Width of the screen.
303
304    pub width: u64,
305    /// Height of the screen.
306
307    pub height: i64,
308    /// Offset of the left edge of the available screen area.
309
310    pub availLeft: i64,
311    /// Offset of the top edge of the available screen area.
312
313    pub availTop: i64,
314    /// Width of the available screen area.
315
316    pub availWidth: u64,
317    /// Height of the available screen area.
318
319    pub availHeight: i64,
320    /// Specifies the screen's device pixel ratio.
321
322    pub devicePixelRatio: f64,
323    /// Specifies the screen's orientation.
324
325    pub orientation: ScreenOrientation,
326    /// Specifies the screen's color depth in bits.
327
328    pub colorDepth: i64,
329    /// Indicates whether the device has multiple screens.
330
331    pub isExtended: bool,
332    /// Indicates whether the screen is internal to the device or external, attached to the device.
333
334    pub isInternal: bool,
335    /// Indicates whether the screen is set as the the operating system primary screen.
336
337    pub isPrimary: bool,
338    /// Specifies the descriptive label for the screen.
339
340    pub label: String,
341    /// Specifies the unique identifier of the screen.
342
343    pub id: ScreenId,
344}
345
346/// Enum of image types that can be disabled.
347
348#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
349pub enum DisabledImageType {
350    #[default]
351    Avif,
352    Jxl,
353    Webp,
354}
355
356/// Tells whether emulation is supported.
357
358#[derive(Debug, Clone, Serialize, Deserialize, Default)]
359#[serde(rename_all = "camelCase")]
360pub struct CanEmulateReturns {
361    /// True if emulation is supported.
362
363    pub result: bool,
364}
365
366/// Enables or disables simulating a focused and active page.
367
368#[derive(Debug, Clone, Serialize, Deserialize, Default)]
369#[serde(rename_all = "camelCase")]
370pub struct SetFocusEmulationEnabledParams {
371    /// Whether to enable to disable focus emulation.
372
373    pub enabled: bool,
374}
375
376/// Automatically render all web contents using a dark theme.
377
378#[derive(Debug, Clone, Serialize, Deserialize, Default)]
379#[serde(rename_all = "camelCase")]
380pub struct SetAutoDarkModeOverrideParams {
381    /// Whether to enable or disable automatic dark mode.
382    /// If not specified, any existing override will be cleared.
383
384    #[serde(skip_serializing_if = "Option::is_none")]
385    pub enabled: Option<bool>,
386}
387
388/// Enables CPU throttling to emulate slow CPUs.
389
390#[derive(Debug, Clone, Serialize, Deserialize, Default)]
391#[serde(rename_all = "camelCase")]
392pub struct SetCPUThrottlingRateParams {
393    /// Throttling rate as a slowdown factor (1 is no throttle, 2 is 2x slowdown, etc).
394
395    pub rate: f64,
396}
397
398/// Sets or clears an override of the default background color of the frame. This override is used
399/// if the content does not specify one.
400
401#[derive(Debug, Clone, Serialize, Deserialize, Default)]
402#[serde(rename_all = "camelCase")]
403pub struct SetDefaultBackgroundColorOverrideParams {
404    /// RGBA of the default background color. If not specified, any existing override will be
405    /// cleared.
406
407    #[serde(skip_serializing_if = "Option::is_none")]
408    pub color: Option<crate::dom::RGBA>,
409}
410
411/// Overrides the values for env(safe-area-inset-*) and env(safe-area-max-inset-*). Unset values will cause the
412/// respective variables to be undefined, even if previously overridden.
413
414#[derive(Debug, Clone, Serialize, Deserialize, Default)]
415#[serde(rename_all = "camelCase")]
416pub struct SetSafeAreaInsetsOverrideParams {
417
418    pub insets: SafeAreaInsets,
419}
420
421/// Overrides the values of device screen dimensions (window.screen.width, window.screen.height,
422/// window.innerWidth, window.innerHeight, and "device-width"/"device-height"-related CSS media
423/// query results).
424
425#[derive(Debug, Clone, Serialize, Deserialize, Default)]
426#[serde(rename_all = "camelCase")]
427pub struct SetDeviceMetricsOverrideParams {
428    /// Overriding width value in pixels (minimum 0, maximum 10000000). 0 disables the override.
429
430    pub width: u64,
431    /// Overriding height value in pixels (minimum 0, maximum 10000000). 0 disables the override.
432
433    pub height: i64,
434    /// Overriding device scale factor value. 0 disables the override.
435
436    pub deviceScaleFactor: f64,
437    /// Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text
438    /// autosizing and more.
439
440    pub mobile: bool,
441    /// Scale to apply to resulting view image.
442
443    #[serde(skip_serializing_if = "Option::is_none")]
444    pub scale: Option<f64>,
445    /// Overriding screen width value in pixels (minimum 0, maximum 10000000).
446
447    #[serde(skip_serializing_if = "Option::is_none")]
448    pub screenWidth: Option<u64>,
449    /// Overriding screen height value in pixels (minimum 0, maximum 10000000).
450
451    #[serde(skip_serializing_if = "Option::is_none")]
452    pub screenHeight: Option<i64>,
453    /// Overriding view X position on screen in pixels (minimum 0, maximum 10000000).
454
455    #[serde(skip_serializing_if = "Option::is_none")]
456    pub positionX: Option<i64>,
457    /// Overriding view Y position on screen in pixels (minimum 0, maximum 10000000).
458
459    #[serde(skip_serializing_if = "Option::is_none")]
460    pub positionY: Option<i64>,
461    /// Do not set visible view size, rely upon explicit setVisibleSize call.
462
463    #[serde(skip_serializing_if = "Option::is_none")]
464    pub dontSetVisibleSize: Option<bool>,
465    /// Screen orientation override.
466
467    #[serde(skip_serializing_if = "Option::is_none")]
468    pub screenOrientation: Option<ScreenOrientation>,
469    /// If set, the visible area of the page will be overridden to this viewport. This viewport
470    /// change is not observed by the page, e.g. viewport-relative elements do not change positions.
471
472    #[serde(skip_serializing_if = "Option::is_none")]
473    pub viewport: Option<crate::page::Viewport>,
474    /// If set, the display feature of a multi-segment screen. If not set, multi-segment support
475    /// is turned-off.
476    /// Deprecated, use Emulation.setDisplayFeaturesOverride.
477
478    #[serde(skip_serializing_if = "Option::is_none")]
479    pub displayFeature: Option<DisplayFeature>,
480    /// If set, the posture of a foldable device. If not set the posture is set
481    /// to continuous.
482    /// Deprecated, use Emulation.setDevicePostureOverride.
483
484    #[serde(skip_serializing_if = "Option::is_none")]
485    pub devicePosture: Option<DevicePosture>,
486    /// Scrollbar type. Default: 'default'.
487
488    #[serde(skip_serializing_if = "Option::is_none")]
489    pub scrollbarType: Option<String>,
490    /// If set to true, enables screen orientation lock emulation, which
491    /// intercepts screen.orientation.lock() calls from the page and reports
492    /// orientation changes via screenOrientationLockChanged events. This is
493    /// useful for emulating mobile device orientation lock behavior in
494    /// responsive design mode.
495
496    #[serde(skip_serializing_if = "Option::is_none")]
497    pub screenOrientationLockEmulation: Option<bool>,
498}
499
500/// Start reporting the given posture value to the Device Posture API.
501/// This override can also be set in setDeviceMetricsOverride().
502
503#[derive(Debug, Clone, Serialize, Deserialize, Default)]
504#[serde(rename_all = "camelCase")]
505pub struct SetDevicePostureOverrideParams {
506
507    pub posture: DevicePosture,
508}
509
510/// Start using the given display features to pupulate the Viewport Segments API.
511/// This override can also be set in setDeviceMetricsOverride().
512
513#[derive(Debug, Clone, Serialize, Deserialize, Default)]
514#[serde(rename_all = "camelCase")]
515pub struct SetDisplayFeaturesOverrideParams {
516
517    pub features: Vec<DisplayFeature>,
518}
519
520
521#[derive(Debug, Clone, Serialize, Deserialize, Default)]
522#[serde(rename_all = "camelCase")]
523pub struct SetScrollbarsHiddenParams {
524    /// Whether scrollbars should be always hidden.
525
526    pub hidden: bool,
527}
528
529
530#[derive(Debug, Clone, Serialize, Deserialize, Default)]
531#[serde(rename_all = "camelCase")]
532pub struct SetDocumentCookieDisabledParams {
533    /// Whether document.coookie API should be disabled.
534
535    pub disabled: bool,
536}
537
538
539#[derive(Debug, Clone, Serialize, Deserialize, Default)]
540#[serde(rename_all = "camelCase")]
541pub struct SetEmitTouchEventsForMouseParams {
542    /// Whether touch emulation based on mouse input should be enabled.
543
544    pub enabled: bool,
545    /// Touch/gesture events configuration. Default: current platform.
546
547    #[serde(skip_serializing_if = "Option::is_none")]
548    pub configuration: Option<String>,
549}
550
551/// Emulates the given media type or media feature for CSS media queries.
552
553#[derive(Debug, Clone, Serialize, Deserialize, Default)]
554#[serde(rename_all = "camelCase")]
555pub struct SetEmulatedMediaParams {
556    /// Media type to emulate. Empty string disables the override.
557
558    #[serde(skip_serializing_if = "Option::is_none")]
559    pub media: Option<String>,
560    /// Media features to emulate.
561
562    #[serde(skip_serializing_if = "Option::is_none")]
563    pub features: Option<Vec<MediaFeature>>,
564}
565
566/// Emulates the given vision deficiency.
567
568#[derive(Debug, Clone, Serialize, Deserialize, Default)]
569#[serde(rename_all = "camelCase")]
570pub struct SetEmulatedVisionDeficiencyParams {
571    /// Vision deficiency to emulate. Order: best-effort emulations come first, followed by any
572    /// physiologically accurate emulations for medically recognized color vision deficiencies.
573
574    #[serde(rename = "type")]
575    pub type_: String,
576}
577
578/// Emulates the given OS text scale.
579
580#[derive(Debug, Clone, Serialize, Deserialize, Default)]
581#[serde(rename_all = "camelCase")]
582pub struct SetEmulatedOSTextScaleParams {
583
584    #[serde(skip_serializing_if = "Option::is_none")]
585    pub scale: Option<f64>,
586}
587
588/// Overrides the Geolocation Position or Error. Omitting latitude, longitude or
589/// accuracy emulates position unavailable.
590
591#[derive(Debug, Clone, Serialize, Deserialize, Default)]
592#[serde(rename_all = "camelCase")]
593pub struct SetGeolocationOverrideParams {
594    /// Mock latitude
595
596    #[serde(skip_serializing_if = "Option::is_none")]
597    pub latitude: Option<f64>,
598    /// Mock longitude
599
600    #[serde(skip_serializing_if = "Option::is_none")]
601    pub longitude: Option<f64>,
602    /// Mock accuracy
603
604    #[serde(skip_serializing_if = "Option::is_none")]
605    pub accuracy: Option<f64>,
606    /// Mock altitude
607
608    #[serde(skip_serializing_if = "Option::is_none")]
609    pub altitude: Option<f64>,
610    /// Mock altitudeAccuracy
611
612    #[serde(skip_serializing_if = "Option::is_none")]
613    pub altitudeAccuracy: Option<f64>,
614    /// Mock heading
615
616    #[serde(skip_serializing_if = "Option::is_none")]
617    pub heading: Option<f64>,
618    /// Mock speed
619
620    #[serde(skip_serializing_if = "Option::is_none")]
621    pub speed: Option<f64>,
622}
623
624
625#[derive(Debug, Clone, Serialize, Deserialize, Default)]
626#[serde(rename_all = "camelCase")]
627pub struct GetOverriddenSensorInformationParams {
628
629    #[serde(rename = "type")]
630    pub type_: SensorType,
631}
632
633
634#[derive(Debug, Clone, Serialize, Deserialize, Default)]
635#[serde(rename_all = "camelCase")]
636pub struct GetOverriddenSensorInformationReturns {
637
638    pub requestedSamplingFrequency: f64,
639}
640
641/// Overrides a platform sensor of a given type. If |enabled| is true, calls to
642/// Sensor.start() will use a virtual sensor as backend rather than fetching
643/// data from a real hardware sensor. Otherwise, existing virtual
644/// sensor-backend Sensor objects will fire an error event and new calls to
645/// Sensor.start() will attempt to use a real sensor instead.
646
647#[derive(Debug, Clone, Serialize, Deserialize, Default)]
648#[serde(rename_all = "camelCase")]
649pub struct SetSensorOverrideEnabledParams {
650
651    pub enabled: bool,
652
653    #[serde(rename = "type")]
654    pub type_: SensorType,
655
656    #[serde(skip_serializing_if = "Option::is_none")]
657    pub metadata: Option<SensorMetadata>,
658}
659
660/// Updates the sensor readings reported by a sensor type previously overridden
661/// by setSensorOverrideEnabled.
662
663#[derive(Debug, Clone, Serialize, Deserialize, Default)]
664#[serde(rename_all = "camelCase")]
665pub struct SetSensorOverrideReadingsParams {
666
667    #[serde(rename = "type")]
668    pub type_: SensorType,
669
670    pub reading: SensorReading,
671}
672
673/// Overrides a pressure source of a given type, as used by the Compute
674/// Pressure API, so that updates to PressureObserver.observe() are provided
675/// via setPressureStateOverride instead of being retrieved from
676/// platform-provided telemetry data.
677
678#[derive(Debug, Clone, Serialize, Deserialize, Default)]
679#[serde(rename_all = "camelCase")]
680pub struct SetPressureSourceOverrideEnabledParams {
681
682    pub enabled: bool,
683
684    pub source: PressureSource,
685
686    #[serde(skip_serializing_if = "Option::is_none")]
687    pub metadata: Option<PressureMetadata>,
688}
689
690/// TODO: OBSOLETE: To remove when setPressureDataOverride is merged.
691/// Provides a given pressure state that will be processed and eventually be
692/// delivered to PressureObserver users. |source| must have been previously
693/// overridden by setPressureSourceOverrideEnabled.
694
695#[derive(Debug, Clone, Serialize, Deserialize, Default)]
696#[serde(rename_all = "camelCase")]
697pub struct SetPressureStateOverrideParams {
698
699    pub source: PressureSource,
700
701    pub state: PressureState,
702}
703
704/// Provides a given pressure data set that will be processed and eventually be
705/// delivered to PressureObserver users. |source| must have been previously
706/// overridden by setPressureSourceOverrideEnabled.
707
708#[derive(Debug, Clone, Serialize, Deserialize, Default)]
709#[serde(rename_all = "camelCase")]
710pub struct SetPressureDataOverrideParams {
711
712    pub source: PressureSource,
713
714    pub state: PressureState,
715
716    #[serde(skip_serializing_if = "Option::is_none")]
717    pub ownContributionEstimate: Option<f64>,
718}
719
720/// Overrides the Idle state.
721
722#[derive(Debug, Clone, Serialize, Deserialize, Default)]
723#[serde(rename_all = "camelCase")]
724pub struct SetIdleOverrideParams {
725    /// Mock isUserActive
726
727    pub isUserActive: bool,
728    /// Mock isScreenUnlocked
729
730    pub isScreenUnlocked: bool,
731}
732
733/// Overrides value returned by the javascript navigator object.
734
735#[derive(Debug, Clone, Serialize, Deserialize, Default)]
736#[serde(rename_all = "camelCase")]
737pub struct SetNavigatorOverridesParams {
738    /// The platform navigator.platform should return.
739
740    pub platform: String,
741}
742
743/// Sets a specified page scale factor.
744
745#[derive(Debug, Clone, Serialize, Deserialize, Default)]
746#[serde(rename_all = "camelCase")]
747pub struct SetPageScaleFactorParams {
748    /// Page scale factor.
749
750    pub pageScaleFactor: f64,
751}
752
753/// Switches script execution in the page.
754
755#[derive(Debug, Clone, Serialize, Deserialize, Default)]
756#[serde(rename_all = "camelCase")]
757pub struct SetScriptExecutionDisabledParams {
758    /// Whether script execution should be disabled in the page.
759
760    pub value: bool,
761}
762
763/// Enables touch on platforms which do not support them.
764
765#[derive(Debug, Clone, Serialize, Deserialize, Default)]
766#[serde(rename_all = "camelCase")]
767pub struct SetTouchEmulationEnabledParams {
768    /// Whether the touch event emulation should be enabled.
769
770    pub enabled: bool,
771    /// Maximum touch points supported. Defaults to one.
772
773    #[serde(skip_serializing_if = "Option::is_none")]
774    pub maxTouchPoints: Option<i64>,
775}
776
777/// Turns on virtual time for all frames (replacing real-time with a synthetic time source) and sets
778/// the current virtual time policy.  Note this supersedes any previous time budget.
779
780#[derive(Debug, Clone, Serialize, Deserialize, Default)]
781#[serde(rename_all = "camelCase")]
782pub struct SetVirtualTimePolicyParams {
783
784    pub policy: VirtualTimePolicy,
785    /// If set, after this many virtual milliseconds have elapsed virtual time will be paused and a
786    /// virtualTimeBudgetExpired event is sent.
787
788    #[serde(skip_serializing_if = "Option::is_none")]
789    pub budget: Option<f64>,
790    /// If set this specifies the maximum number of tasks that can be run before virtual is forced
791    /// forwards to prevent deadlock.
792
793    #[serde(skip_serializing_if = "Option::is_none")]
794    pub maxVirtualTimeTaskStarvationCount: Option<u64>,
795    /// If set, base::Time::Now will be overridden to initially return this value.
796
797    #[serde(skip_serializing_if = "Option::is_none")]
798    pub initialVirtualTime: Option<crate::network::TimeSinceEpoch>,
799}
800
801/// Turns on virtual time for all frames (replacing real-time with a synthetic time source) and sets
802/// the current virtual time policy.  Note this supersedes any previous time budget.
803
804#[derive(Debug, Clone, Serialize, Deserialize, Default)]
805#[serde(rename_all = "camelCase")]
806pub struct SetVirtualTimePolicyReturns {
807    /// Absolute timestamp at which virtual time was first enabled (up time in milliseconds).
808
809    pub virtualTimeTicksBase: f64,
810}
811
812/// Overrides default host system locale with the specified one.
813
814#[derive(Debug, Clone, Serialize, Deserialize, Default)]
815#[serde(rename_all = "camelCase")]
816pub struct SetLocaleOverrideParams {
817    /// ICU style C locale (e.g. "en_US"). If not specified or empty, disables the override and
818    /// restores default host system locale.
819
820    #[serde(skip_serializing_if = "Option::is_none")]
821    pub locale: Option<String>,
822}
823
824/// Overrides default host system timezone with the specified one.
825
826#[derive(Debug, Clone, Serialize, Deserialize, Default)]
827#[serde(rename_all = "camelCase")]
828pub struct SetTimezoneOverrideParams {
829    /// The timezone identifier. List of supported timezones:
830    /// <https://source.chromium.org/chromium/chromium/deps/icu.git/+/faee8bc70570192d82d2978a71e2a615788597d1:source/data/misc/metaZones.txt>
831    /// If empty, disables the override and restores default host system timezone.
832
833    pub timezoneId: String,
834}
835
836/// Resizes the frame/viewport of the page. Note that this does not affect the frame's container
837/// (e.g. browser window). Can be used to produce screenshots of the specified size. Not supported
838/// on Android.
839
840#[derive(Debug, Clone, Serialize, Deserialize, Default)]
841#[serde(rename_all = "camelCase")]
842pub struct SetVisibleSizeParams {
843    /// Frame width (DIP).
844
845    pub width: u64,
846    /// Frame height (DIP).
847
848    pub height: i64,
849}
850
851
852#[derive(Debug, Clone, Serialize, Deserialize, Default)]
853#[serde(rename_all = "camelCase")]
854pub struct SetDisabledImageTypesParams {
855    /// Image types to disable.
856
857    pub imageTypes: Vec<DisabledImageType>,
858}
859
860/// Override the value of navigator.connection.saveData
861
862#[derive(Debug, Clone, Serialize, Deserialize, Default)]
863#[serde(rename_all = "camelCase")]
864pub struct SetDataSaverOverrideParams {
865    /// Override value. Omitting the parameter disables the override.
866
867    #[serde(skip_serializing_if = "Option::is_none")]
868    pub dataSaverEnabled: Option<bool>,
869}
870
871
872#[derive(Debug, Clone, Serialize, Deserialize, Default)]
873#[serde(rename_all = "camelCase")]
874pub struct SetHardwareConcurrencyOverrideParams {
875    /// Hardware concurrency to report
876
877    pub hardwareConcurrency: i64,
878}
879
880/// Allows overriding user agent with the given string.
881/// 'userAgentMetadata' must be set for Client Hint headers to be sent.
882
883#[derive(Debug, Clone, Serialize, Deserialize, Default)]
884#[serde(rename_all = "camelCase")]
885pub struct SetUserAgentOverrideParams {
886    /// User agent to use.
887
888    pub userAgent: String,
889    /// Browser language to emulate.
890
891    #[serde(skip_serializing_if = "Option::is_none")]
892    pub acceptLanguage: Option<String>,
893    /// The platform navigator.platform should return.
894
895    #[serde(skip_serializing_if = "Option::is_none")]
896    pub platform: Option<String>,
897    /// To be sent in Sec-CH-UA-* headers and returned in navigator.userAgentData
898
899    #[serde(skip_serializing_if = "Option::is_none")]
900    pub userAgentMetadata: Option<UserAgentMetadata>,
901}
902
903/// Allows overriding the automation flag.
904
905#[derive(Debug, Clone, Serialize, Deserialize, Default)]
906#[serde(rename_all = "camelCase")]
907pub struct SetAutomationOverrideParams {
908    /// Whether the override should be enabled.
909
910    pub enabled: bool,
911}
912
913/// Allows overriding the difference between the small and large viewport sizes, which determine the
914/// value of the 'svh' and 'lvh' unit, respectively. Only supported for top-level frames.
915
916#[derive(Debug, Clone, Serialize, Deserialize, Default)]
917#[serde(rename_all = "camelCase")]
918pub struct SetSmallViewportHeightDifferenceOverrideParams {
919    /// This will cause an element of size 100svh to be 'difference' pixels smaller than an element
920    /// of size 100lvh.
921
922    pub difference: i64,
923}
924
925/// Returns device's screen configuration. In headful mode, the physical screens configuration is returned,
926/// whereas in headless mode, a virtual headless screen configuration is provided instead.
927
928#[derive(Debug, Clone, Serialize, Deserialize, Default)]
929#[serde(rename_all = "camelCase")]
930pub struct GetScreenInfosReturns {
931
932    pub screenInfos: Vec<ScreenInfo>,
933}
934
935/// Add a new screen to the device. Only supported in headless mode.
936
937#[derive(Debug, Clone, Serialize, Deserialize, Default)]
938#[serde(rename_all = "camelCase")]
939pub struct AddScreenParams {
940    /// Offset of the left edge of the screen in pixels.
941
942    pub left: i64,
943    /// Offset of the top edge of the screen in pixels.
944
945    pub top: i64,
946    /// The width of the screen in pixels.
947
948    pub width: u64,
949    /// The height of the screen in pixels.
950
951    pub height: i64,
952    /// Specifies the screen's work area. Default is entire screen.
953
954    #[serde(skip_serializing_if = "Option::is_none")]
955    pub workAreaInsets: Option<WorkAreaInsets>,
956    /// Specifies the screen's device pixel ratio. Default is 1.
957
958    #[serde(skip_serializing_if = "Option::is_none")]
959    pub devicePixelRatio: Option<f64>,
960    /// Specifies the screen's rotation angle. Available values are 0, 90, 180 and 270. Default is 0.
961
962    #[serde(skip_serializing_if = "Option::is_none")]
963    pub rotation: Option<i64>,
964    /// Specifies the screen's color depth in bits. Default is 24.
965
966    #[serde(skip_serializing_if = "Option::is_none")]
967    pub colorDepth: Option<i64>,
968    /// Specifies the descriptive label for the screen. Default is none.
969
970    #[serde(skip_serializing_if = "Option::is_none")]
971    pub label: Option<String>,
972    /// Indicates whether the screen is internal to the device or external, attached to the device. Default is false.
973
974    #[serde(skip_serializing_if = "Option::is_none")]
975    pub isInternal: Option<bool>,
976}
977
978/// Add a new screen to the device. Only supported in headless mode.
979
980#[derive(Debug, Clone, Serialize, Deserialize, Default)]
981#[serde(rename_all = "camelCase")]
982pub struct AddScreenReturns {
983
984    pub screenInfo: ScreenInfo,
985}
986
987/// Updates specified screen parameters. Only supported in headless mode.
988
989#[derive(Debug, Clone, Serialize, Deserialize, Default)]
990#[serde(rename_all = "camelCase")]
991pub struct UpdateScreenParams {
992    /// Target screen identifier.
993
994    pub screenId: ScreenId,
995    /// Offset of the left edge of the screen in pixels.
996
997    #[serde(skip_serializing_if = "Option::is_none")]
998    pub left: Option<i64>,
999    /// Offset of the top edge of the screen in pixels.
1000
1001    #[serde(skip_serializing_if = "Option::is_none")]
1002    pub top: Option<i64>,
1003    /// The width of the screen in pixels.
1004
1005    #[serde(skip_serializing_if = "Option::is_none")]
1006    pub width: Option<u64>,
1007    /// The height of the screen in pixels.
1008
1009    #[serde(skip_serializing_if = "Option::is_none")]
1010    pub height: Option<i64>,
1011    /// Specifies the screen's work area.
1012
1013    #[serde(skip_serializing_if = "Option::is_none")]
1014    pub workAreaInsets: Option<WorkAreaInsets>,
1015    /// Specifies the screen's device pixel ratio.
1016
1017    #[serde(skip_serializing_if = "Option::is_none")]
1018    pub devicePixelRatio: Option<f64>,
1019    /// Specifies the screen's rotation angle. Available values are 0, 90, 180 and 270.
1020
1021    #[serde(skip_serializing_if = "Option::is_none")]
1022    pub rotation: Option<i64>,
1023    /// Specifies the screen's color depth in bits.
1024
1025    #[serde(skip_serializing_if = "Option::is_none")]
1026    pub colorDepth: Option<i64>,
1027    /// Specifies the descriptive label for the screen.
1028
1029    #[serde(skip_serializing_if = "Option::is_none")]
1030    pub label: Option<String>,
1031    /// Indicates whether the screen is internal to the device or external, attached to the device. Default is false.
1032
1033    #[serde(skip_serializing_if = "Option::is_none")]
1034    pub isInternal: Option<bool>,
1035}
1036
1037/// Updates specified screen parameters. Only supported in headless mode.
1038
1039#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1040#[serde(rename_all = "camelCase")]
1041pub struct UpdateScreenReturns {
1042
1043    pub screenInfo: ScreenInfo,
1044}
1045
1046/// Remove screen from the device. Only supported in headless mode.
1047
1048#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1049#[serde(rename_all = "camelCase")]
1050pub struct RemoveScreenParams {
1051
1052    pub screenId: ScreenId,
1053}
1054
1055/// Set primary screen. Only supported in headless mode.
1056/// Note that this changes the coordinate system origin to the top-left
1057/// of the new primary screen, updating the bounds and work areas
1058/// of all existing screens accordingly.
1059
1060#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1061#[serde(rename_all = "camelCase")]
1062pub struct SetPrimaryScreenParams {
1063
1064    pub screenId: ScreenId,
1065}