Re-apply the current viewport/geolocation overrides to a session. Mirrors `apply_network_rules_internal` so overrides persist across target switches. No-op for whichever override isn't set.
(&mut self, session_id: &str)
| 342 | /// Mirrors `apply_network_rules_internal` so overrides persist across |
| 343 | /// target switches. No-op for whichever override isn't set. |
| 344 | pub(crate) async fn apply_emulation_internal(&mut self, session_id: &str) -> Result<()> { |
| 345 | if let Some(vp) = self.viewport.clone() { |
| 346 | self.send_to_target( |
| 347 | session_id, |
| 348 | "Emulation.setDeviceMetricsOverride", |
| 349 | json!({ |
| 350 | "width": vp.width, |
| 351 | "height": vp.height, |
| 352 | "deviceScaleFactor": vp.device_scale_factor, |
| 353 | "mobile": vp.mobile, |
| 354 | }), |
| 355 | ) |
| 356 | .await?; |
| 357 | } |
| 358 | if let Some(geo) = self.geolocation.clone() { |
| 359 | self.send_to_target( |
| 360 | session_id, |
| 361 | "Emulation.setGeolocationOverride", |
| 362 | json!({ |
| 363 | "latitude": geo.latitude, |
| 364 | "longitude": geo.longitude, |
| 365 | "accuracy": geo.accuracy, |
| 366 | }), |
| 367 | ) |
| 368 | .await?; |
| 369 | } |
| 370 | Ok(()) |
| 371 | } |
| 372 | |
| 373 | /// Apply the daemon's current `blocklist` to the persistent session via |
| 374 | /// `Network.setBlockedURLs`. Patterns are Chrome-style globs (e.g. `*.png`). |
no test coverage detected