pub struct ViewportManager { /* private fields */ }Expand description
Manages viewport and device emulation
Implementations§
Source§impl ViewportManager
impl ViewportManager
Sourcepub async fn set_device_metrics(&self, config: &ViewportConfig) -> Result<()>
pub async fn set_device_metrics(&self, config: &ViewportConfig) -> Result<()>
Set device metrics override (emulate a specific device viewport)
Sourcepub async fn clear_device_metrics(&self) -> Result<()>
pub async fn clear_device_metrics(&self) -> Result<()>
Clear device metrics override (restore default viewport)
Sourcepub async fn set_touch_emulation(&self, enabled: bool) -> Result<()>
pub async fn set_touch_emulation(&self, enabled: bool) -> Result<()>
Set touch emulation
Sourcepub async fn set_user_agent(
&self,
user_agent: &str,
accept_language: Option<&str>,
) -> Result<()>
pub async fn set_user_agent( &self, user_agent: &str, accept_language: Option<&str>, ) -> Result<()>
Set user agent override
Sourcepub async fn set_geolocation(
&self,
latitude: f64,
longitude: f64,
accuracy: Option<f64>,
) -> Result<()>
pub async fn set_geolocation( &self, latitude: f64, longitude: f64, accuracy: Option<f64>, ) -> Result<()>
Set geolocation override
Sourcepub async fn clear_geolocation(&self) -> Result<()>
pub async fn clear_geolocation(&self) -> Result<()>
Clear geolocation override
Sourcepub async fn set_timezone(&self, timezone_id: &str) -> Result<()>
pub async fn set_timezone(&self, timezone_id: &str) -> Result<()>
Set timezone override
Sourcepub async fn set_media_features(
&self,
media_type: Option<&str>,
features: Vec<MediaFeature>,
) -> Result<()>
pub async fn set_media_features( &self, media_type: Option<&str>, features: Vec<MediaFeature>, ) -> Result<()>
Set emulated media features (prefers-color-scheme, prefers-reduced-motion, etc.)
Sourcepub async fn clear_media_features(&self) -> Result<()>
pub async fn clear_media_features(&self) -> Result<()>
Clear emulated media (restore defaults)
Sourcepub async fn set_color_scheme(&self, scheme: ColorScheme) -> Result<()>
pub async fn set_color_scheme(&self, scheme: ColorScheme) -> Result<()>
Set color scheme (convenience wrapper for prefers-color-scheme)
Sourcepub async fn set_vision_deficiency(
&self,
deficiency: VisionDeficiency,
) -> Result<()>
pub async fn set_vision_deficiency( &self, deficiency: VisionDeficiency, ) -> Result<()>
Set vision deficiency emulation for accessibility testing
Sourcepub async fn set_locale(&self, locale: &str) -> Result<()>
pub async fn set_locale(&self, locale: &str) -> Result<()>
Set locale override (affects navigator.language and date formatting)
Sourcepub async fn clear_locale(&self) -> Result<()>
pub async fn clear_locale(&self) -> Result<()>
Clear locale override (restore system default)
Sourcepub async fn override_languages_and_fonts(
&self,
languages: Vec<String>,
font_families: Option<Vec<String>>,
) -> Result<()>
pub async fn override_languages_and_fonts( &self, languages: Vec<String>, font_families: Option<Vec<String>>, ) -> Result<()>
Override navigator.languages and optionally font-family lists via JS.
This ensures font rendering consistency across environments.
Sourcepub async fn preset_device(&self, preset: &DevicePreset) -> Result<()>
pub async fn preset_device(&self, preset: &DevicePreset) -> Result<()>
Apply a device preset (viewport + user agent + touch in one call)
Sourcepub async fn get_metrics(&self) -> Result<DeviceMetrics>
pub async fn get_metrics(&self) -> Result<DeviceMetrics>
Get current device metrics via JavaScript
Trait Implementations§
Source§impl Clone for ViewportManager
impl Clone for ViewportManager
Source§fn clone(&self) -> ViewportManager
fn clone(&self) -> ViewportManager
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more