Skip to content

armgit / moli

Public Imported from GitHub
0

Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust

feat(cdp): support Emulation.setScrollbarsHidden

ldm0a789da8a0d39
diff --git a/moli-core/src/page/settings_support.rs b/moli-core/src/page/settings_support.rs
index 36c515424..4161565f9 100644
--- a/moli-core/src/page/settings_support.rs
+++ b/moli-core/src/page/settings_support.rs
@@ -326,6 +326,29 @@ impl Page {
)
}
+ /// Updates the DevTools hiding override; the browser startup flag remains effective.
+ pub async fn set_scrollbars_hidden_async(&mut self, hidden: bool) -> Result<()> {
+ self.dispatch_unit_page_command_async(
+ RendererPageCommand::SetScrollbarsHidden(hidden),
+ "set scrollbars hidden",
+ )
+ .await
+ }
+
+ pub fn start_set_scrollbars_hidden(&self, hidden: bool) -> Result<PendingPageCommand> {
+ self.start_page_command(RendererPageCommand::SetScrollbarsHidden(hidden))
+ }
+
+ pub fn finish_set_scrollbars_hidden(&mut self, completion: CompletedPageCommand) -> Result<()> {
+ let reply = self.finish_page_command(completion);
+ expect_page_reply!(
+ reply,
+ "set scrollbars hidden",
+ "a unit reply",
+ RendererPageReply::Unit => Ok(()),
+ )
+ }
+
pub async fn set_emulated_media_async(
&mut self,
overrides: &EmulatedMediaOverrides,
diff --git a/moli-core/src/runtime/navigation_engine.rs b/moli-core/src/runtime/navigation_engine.rs
index 5fa689464..0db735f91 100644
--- a/moli-core/src/runtime/navigation_engine.rs
+++ b/moli-core/src/runtime/navigation_engine.rs
@@ -200,6 +200,7 @@ pub struct PreparedDocumentPageCommitConfiguration {
pub permission_overrides: Vec<PermissionOverrideRegistration>,
pub extra_http_headers: moli_fetch::RequestHeaders,
pub script_execution_disabled: bool,
+ pub emulated_scrollbars_hidden: bool,
pub bypass_content_security_policy: bool,
pub emulated_media: EmulatedMediaOverrides,
pub idle_override: Option<crate::page::EmulatedIdleOverride>,
@@ -261,6 +262,7 @@ impl PreparedDocumentPage {
permission_overrides: configuration.permission_overrides,
extra_http_headers: configuration.extra_http_headers,
script_execution_disabled: configuration.script_execution_disabled,
+ emulated_scrollbars_hidden: configuration.emulated_scrollbars_hidden,
bypass_content_security_policy: configuration.bypass_content_security_policy,
emulated_media: configuration.emulated_media,
idle_override: configuration.idle_override,
@@ -434,6 +436,7 @@ pub struct NavigationEngine {
page_network_policy: PageNetworkPolicy,
layout_policy: LayoutPolicy,
scrollbars_hidden: bool,
+ emulated_scrollbars_hidden: bool,
js_runtime: JsRuntime,
resource_runtime: Option<BrowserResourceRuntime>,
browser_context_access: RendererBrowserContextRuntimeOwnerAccess,
@@ -595,6 +598,7 @@ impl NavigationEngine {
),
layout_policy,
scrollbars_hidden,
+ emulated_scrollbars_hidden: false,
js_runtime,
resource_runtime: Some(resource_runtime),
browser_context_access,
@@ -649,6 +653,7 @@ impl NavigationEngine {
),
layout_policy,
scrollbars_hidden,
+ emulated_scrollbars_hidden: false,
js_runtime: renderer_owner_source.js_runtime.clone(),
resource_runtime: Some(resource_runtime),
browser_context_access: renderer_owner_source.browser_context_access.clone(),
@@ -678,6 +683,11 @@ impl NavigationEngine {
self.document_activity = activity;
}
+ /// Seeds target-local scrollbar emulation before the next Document starts.
+ pub fn set_emulated_scrollbars_hidden(&mut self, hidden: bool) {
+ self.emulated_scrollbars_hidden = hidden;
+ }
+
pub fn document_isolate_accounting_for_diagnostics(
&self,
) -> crate::page::RendererDocumentIsolateAccountingDiagnostics {
@@ -1560,6 +1570,7 @@ impl NavigationEngine {
runtime_bindings,
extra_http_headers,
script_execution_disabled,
+ emulated_scrollbars_hidden: self.emulated_scrollbars_hidden,
bypass_content_security_policy,
emulated_media,
viewport_surface,
@@ -1840,6 +1851,7 @@ impl NavigationEngine {
runtime_bindings,
extra_http_headers,
script_execution_disabled,
+ emulated_scrollbars_hidden: self.emulated_scrollbars_hidden,
bypass_content_security_policy,
emulated_media,
viewport_surface,
@@ -2093,6 +2105,7 @@ impl NavigationEngine {
runtime_bindings: options.runtime_bindings,
extra_http_headers: options.extra_http_headers,
script_execution_disabled: options.script_execution_disabled,
+ emulated_scrollbars_hidden: self.emulated_scrollbars_hidden,
bypass_content_security_policy: options.bypass_content_security_policy,
emulated_media: options.emulated_media,
viewport_surface: options.viewport_surface,
diff --git a/moli-protocol/src/conn/browser_context/emulation_owner.rs b/moli-protocol/src/conn/browser_context/emulation_owner.rs
index e3600769c..13cce0fdd 100644
--- a/moli-protocol/src/conn/browser_context/emulation_owner.rs
+++ b/moli-protocol/src/conn/browser_context/emulation_owner.rs
@@ -65,6 +65,17 @@ impl TargetEmulationStateUpdate<'_> {
self.raw.script_execution_disabled = disabled;
self.effective.script_execution_disabled = disabled;
}
+
+ pub(crate) fn set_scrollbars_hidden(&mut self, hidden: bool) -> bool {
+ // Blink ignores a setter that repeats this handler's raw value, even
+ // when another handler has since changed the shared renderer value.
+ if self.raw.scrollbars_hidden == hidden {
+ return false;
+ }
+ self.raw.scrollbars_hidden = hidden;
+ self.effective.scrollbars_hidden = hidden;
+ true
+ }
}
impl TargetSessionOwnerMut<'_> {
diff --git a/moli-protocol/src/conn/browser_context/target_session_owner.rs b/moli-protocol/src/conn/browser_context/target_session_owner.rs
index 5c2abcac4..91d6b3b14 100644
--- a/moli-protocol/src/conn/browser_context/target_session_owner.rs
+++ b/moli-protocol/src/conn/browser_context/target_session_owner.rs
@@ -167,6 +167,7 @@ pub(crate) struct TargetNavigationLoadInputs {
Vec<RendererInspectorSessionRestoreSnapshot>,
pub(crate) extra_http_headers: moli_fetch::RequestHeaders,
pub(crate) script_execution_disabled: bool,
+ pub(crate) scrollbars_hidden: bool,
pub(crate) bypass_content_security_policy: bool,
pub(crate) emulated_media: moli_core::page::EmulatedMediaOverrides,
pub(crate) viewport_surface: Option<moli_core::page::ViewportSurface>,
@@ -321,6 +322,7 @@ impl TargetNavigationLoadInputs {
script_execution_disabled: page_state
.effective_emulation_state
.script_execution_disabled,
+ scrollbars_hidden: page_state.effective_emulation_state.scrollbars_hidden,
bypass_content_security_policy: page_state.devtools_sessions.page_bypass_csp_enabled(),
emulated_media: (&page_state.effective_emulation_state.emulated_media).into(),
viewport_surface: emulated_device_metrics
@@ -401,6 +403,7 @@ impl TargetNavigationLoadInputs {
runtime_inspector_session_restore_snapshots: Vec::new(),
extra_http_headers: Default::default(),
script_execution_disabled: false,
+ scrollbars_hidden: false,
bypass_content_security_policy: false,
emulated_media: Default::default(),
viewport_surface: None,
diff --git a/moli-protocol/src/conn/runtime_load.rs b/moli-protocol/src/conn/runtime_load.rs
index 6b5109e78..1f83974d0 100644
--- a/moli-protocol/src/conn/runtime_load.rs
+++ b/moli-protocol/src/conn/runtime_load.rs
@@ -1490,6 +1490,7 @@ impl CdpConnection {
permission_overrides: load_inputs.permission_overrides,
extra_http_headers: load_inputs.extra_http_headers,
script_execution_disabled: load_inputs.script_execution_disabled,
+ emulated_scrollbars_hidden: load_inputs.scrollbars_hidden,
bypass_content_security_policy: load_inputs.bypass_content_security_policy,
emulated_media: load_inputs.emulated_media,
idle_override,
@@ -2377,6 +2378,7 @@ impl CdpConnection {
.expect("navigation load target must retain its resident NavigationEngine")
.clone();
engine.set_document_activity(load_inputs.document_activity);
+ engine.set_emulated_scrollbars_hidden(load_inputs.scrollbars_hidden);
// The handle may publish lifecycle or resource activity before the
// DCL-bound navigation result is committed into a target slot.
self.apply_scheduler_senders_to_navigation_engine(&engine);
@@ -3774,6 +3776,9 @@ async fn apply_navigation_load_input_overrides_async(
.await
.context("failed to apply page permission overrides")?;
}
+ page.set_scrollbars_hidden_async(load_inputs.scrollbars_hidden)
+ .await
+ .context("failed to apply page scrollbar emulation")?;
if mode == NavigationLoadInputOverrideMode::FreshlyBuiltPage {
return Ok(());
}
diff --git a/moli-protocol/src/conn/state/devtools_session.rs b/moli-protocol/src/conn/state/devtools_session.rs
index 5cf0535df..eda85606c 100644
--- a/moli-protocol/src/conn/state/devtools_session.rs
+++ b/moli-protocol/src/conn/state/devtools_session.rs
@@ -687,6 +687,7 @@ pub(crate) struct DevToolsEmulationSessionState {
pub(crate) emit_touch_events_for_mouse: bool,
pub(crate) focus_emulation_enabled: bool,
pub(crate) script_execution_disabled: bool,
+ pub(crate) scrollbars_hidden: bool,
}
#[derive(Clone, Debug, PartialEq)]
diff --git a/moli-protocol/src/conn/state/emulation.rs b/moli-protocol/src/conn/state/emulation.rs
index 1c6cf993d..a37bb913d 100644
--- a/moli-protocol/src/conn/state/emulation.rs
+++ b/moli-protocol/src/conn/state/emulation.rs
@@ -141,6 +141,7 @@ pub(crate) struct EffectiveTargetEmulationState {
pub(crate) emit_touch_events_for_mouse: bool,
pub(crate) focus_emulation_enabled: bool,
pub(crate) script_execution_disabled: bool,
+ pub(crate) scrollbars_hidden: bool,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
@@ -153,6 +154,7 @@ pub(crate) struct EffectiveTargetEmulationStateDelta {
pub(crate) navigator_queries: bool,
pub(crate) focus_emulation_enabled: bool,
pub(crate) script_execution_disabled: bool,
+ pub(crate) scrollbars_hidden: bool,
}
impl EffectiveTargetEmulationStateDelta {
@@ -200,6 +202,9 @@ impl EffectiveTargetEmulationState {
// Blink also sends the shared renderer an unconditional script
// execution reset when any Emulation handler is disabled.
self.script_execution_disabled = false;
+ if raw.scrollbars_hidden {
+ self.scrollbars_hidden = false;
+ }
EffectiveTargetEmulationStateDelta {
network_conditions: previous.network_conditions != self.network_conditions,
geolocation_override: previous.geolocation_override != self.geolocation_override,
@@ -212,6 +217,7 @@ impl EffectiveTargetEmulationState {
!= self.focus_emulation_enabled,
script_execution_disabled: previous.script_execution_disabled
!= self.script_execution_disabled,
+ scrollbars_hidden: previous.scrollbars_hidden != self.scrollbars_hidden,
}
}
}
diff --git a/moli-protocol/src/domains/actions.rs b/moli-protocol/src/domains/actions.rs
index 82f6f7b1f..6a5d5a5f9 100644
--- a/moli-protocol/src/domains/actions.rs
+++ b/moli-protocol/src/domains/actions.rs
@@ -181,6 +181,7 @@ pub(crate) enum EmulationAction {
SetAutomationOverride,
SetEmitTouchEventsForMouse,
SetScriptExecutionDisabled,
+ SetScrollbarsHidden,
SetGeolocationOverride,
ClearGeolocationOverride,
SetIdleOverride,
diff --git a/moli-protocol/src/domains/emulation.rs b/moli-protocol/src/domains/emulation.rs
index cda13fe86..0a8d349db 100644
--- a/moli-protocol/src/domains/emulation.rs
+++ b/moli-protocol/src/domains/emulation.rs
@@ -97,6 +97,7 @@ enum PendingEmulationPageOperation {
SetNavigatorOverrides,
SetNavigatorAndDocumentActivity,
SetEmulatedMedia,
+ SetScrollbarsHidden,
SetViewportSurface,
SetUserAgentLoader,
ReplaceBrowserResourceRuntime,
@@ -110,6 +111,7 @@ impl PendingEmulationPageOperation {
| Self::SetNavigatorAndDocumentActivity
| Self::SetNetworkConditions
| Self::SetEmulatedMedia
+ | Self::SetScrollbarsHidden
| Self::SetViewportSurface
| Self::SetUserAgentLoader
| Self::ReplaceBrowserResourceRuntime => true,
@@ -220,6 +222,9 @@ pub(crate) fn try_start_emulation_command_dispatch(
Some(EmulationAction::SetScriptExecutionDisabled) => {
Some(start_script_execution_disabled_command(conn, cmd))
}
+ Some(EmulationAction::SetScrollbarsHidden) => {
+ Some(start_scrollbars_hidden_command(conn, cmd))
+ }
Some(EmulationAction::SetGeolocationOverride) => {
Some(start_geolocation_override_command(conn, cmd))
}
@@ -841,6 +846,64 @@ fn default_background_color_command(conn: &mut CdpConnection, cmd: &Cmd<'_>) ->
}
}
+fn start_scrollbars_hidden_command(
+ conn: &mut CdpConnection,
+ cmd: &Cmd<'_>,
+) -> EmulationCommandTaskStep {
+ let params: params::SetScrollbarsHiddenParams = match cmd.get_params() {
+ Ok(Some(params)) => params,
+ _ => {
+ return EmulationCommandTaskStep::Complete(CommandOutputPlan::error(
+ -32602,
+ "InvalidParams",
+ ));
+ }
+ };
+ if !conn.layout_policy().uses_real_layout() {
+ return EmulationCommandTaskStep::Complete(CommandOutputPlan::error(
+ -32000,
+ "Emulation.setScrollbarsHidden requires --layout",
+ ));
+ }
+ let mut changed = false;
+ if let Err(message) =
+ page_session::update_page_emulation_state(conn, cmd.session_id, |mut state| {
+ changed = state.set_scrollbars_hidden(params.hidden);
+ })
+ {
+ return EmulationCommandTaskStep::Complete(CommandOutputPlan::error(-31998, message));
+ }
+ if !changed {
+ return EmulationCommandTaskStep::Complete(CommandOutputPlan::success());
+ }
+ if let Some(step) = native_configuration::try_start(
+ conn,
+ cmd,
+ native_configuration::unit(moli_core::RendererPageCommand::SetScrollbarsHidden(
+ params.hidden,
+ )),
+ PendingEmulationPageOperation::SetScrollbarsHidden,
+ ) {
+ return step;
+ }
+ let owner_scope = CommandOwnerScope::capture(conn, cmd.session_id);
+ let Some(page) = loaded_page_mut_for_target_configuration(conn, cmd.session_id) else {
+ return EmulationCommandTaskStep::Complete(CommandOutputPlan::success());
+ };
+ match page.start_set_scrollbars_hidden(params.hidden) {
+ Ok(pending) => EmulationCommandTaskStep::Pending(single_pending_emulation_dispatch(
+ cmd.id,
+ owner_scope,
+ PendingEmulationPageOperation::SetScrollbarsHidden,
+ pending,
+ None,
+ )),
+ Err(error) => {
+ EmulationCommandTaskStep::Complete(CommandOutputPlan::error(-32000, error.to_string()))
+ }
+ }
+}
+
fn start_emulated_media_command(
conn: &mut CdpConnection,
cmd: &Cmd<'_>,
@@ -2598,6 +2661,14 @@ pub(crate) async fn dispose_page_session_async(
.await,
);
}
+ if delta.scrollbars_hidden {
+ record_emulation_disposal_result(
+ &mut first_error,
+ "scrollbar visibility",
+ page.set_scrollbars_hidden_async(load_inputs.scrollbars_hidden)
+ .await,
+ );
+ }
if delta.network_conditions {
record_emulation_disposal_result(
&mut first_error,
@@ -2940,6 +3011,9 @@ fn finish_emulation_page_operation(
PendingEmulationPageOperation::SetEmulatedMedia => page
.finish_set_emulated_media(completion)
.map_err(|error| error.to_string()),
+ PendingEmulationPageOperation::SetScrollbarsHidden => page
+ .finish_set_scrollbars_hidden(completion)
+ .map_err(|error| error.to_string()),
PendingEmulationPageOperation::SetViewportSurface => page
.finish_set_viewport_surface(completion)
.map_err(|error| error.to_string()),
diff --git a/moli-protocol/src/domains/emulation/params.rs b/moli-protocol/src/domains/emulation/params.rs
index 2310e0de7..3eefdc98f 100644
--- a/moli-protocol/src/domains/emulation/params.rs
+++ b/moli-protocol/src/domains/emulation/params.rs
@@ -4,7 +4,8 @@ pub(super) use chromiumoxide_cdp::cdp::browser_protocol::emulation::{
SetDefaultBackgroundColorOverrideParams, SetEmitTouchEventsForMouseParams,
SetEmulatedMediaParams, SetFocusEmulationEnabledParams, SetGeolocationOverrideParams,
SetHardwareConcurrencyOverrideParams, SetIdleOverrideParams, SetLocaleOverrideParams,
- SetScriptExecutionDisabledParams, SetTimezoneOverrideParams, SetTouchEmulationEnabledParams,
+ SetScriptExecutionDisabledParams, SetScrollbarsHiddenParams, SetTimezoneOverrideParams,
+ SetTouchEmulationEnabledParams,
};
use chromiumoxide_cdp::cdp::browser_protocol::{
diff --git a/moli-protocol/src/domains/emulation/tests.rs b/moli-protocol/src/domains/emulation/tests.rs
index e9adbff07..69ebbe7ff 100644
--- a/moli-protocol/src/domains/emulation/tests.rs
+++ b/moli-protocol/src/domains/emulation/tests.rs
@@ -21,6 +21,7 @@ use tokio::{
mod device_geometry;
mod native_navigator;
+mod scrollbars;
async fn evaluate(ctx: &mut TestContext, expression: &str) -> serde_json::Value {
ctx.process_async(json!({
diff --git a/moli-protocol/src/domains/emulation/tests/scrollbars.rs b/moli-protocol/src/domains/emulation/tests/scrollbars.rs
new file mode 100644
index 000000000..09ab38619
--- /dev/null
+++ b/moli-protocol/src/domains/emulation/tests/scrollbars.rs
@@ -0,0 +1,255 @@
+use super::*;
+
+const HTML: &str = r#"<!doctype html><style>html,body{margin:0}
+#viewport{width:100vw;height:2000px;background:lime}
+.scroller{position:absolute;top:0;width:200px;height:100px;overflow:scroll}
+.content{width:400px;height:300px}
+#stable{left:220px;scrollbar-gutter:stable both-edges}</style>
+<div id=viewport></div><div id=scroller class=scroller><div class=content></div></div>
+<div id=stable class=scroller><div class=content></div></div>"#;
+
+async fn set_hidden(ctx: &mut TestContext, session: &str, hidden: bool) {
+ expect_session_command_result(
+ ctx,
+ 88500,
+ session,
+ "Emulation.setScrollbarsHidden",
+ json!({"hidden":hidden}),
+ )
+ .await;
+}
+
+async fn metrics(ctx: &mut TestContext) -> serde_json::Value {
+ evaluate(
+ ctx,
+ "[innerWidth,document.documentElement.clientWidth,document.documentElement.scrollWidth,scroller.clientWidth,scroller.clientHeight,stable.clientWidth,stable.clientHeight]",
+ )
+ .await
+}
+
+async fn load_fixture(ctx: &mut TestContext) {
+ load_session_page_for_pending_emulation_test(ctx).await;
+ expect_session_command_result(
+ ctx,
+ 88501,
+ "SID-1",
+ "Emulation.setDeviceMetricsOverride",
+ json!({"width":1280,"height":720,"deviceScaleFactor":1,"mobile":false}),
+ )
+ .await;
+ ctx.install_buffered_navigation_fixture_for_session_owner(
+ url::Url::parse("https://scrollbars.example/page").unwrap(),
+ HTML.to_owned(),
+ Some("SID-1"),
+ )
+ .await;
+ ctx.capture_fixture_layout(Some("SID-1")).await;
+}
+
+#[tokio::test(flavor = "multi_thread")]
+async fn scrollbars_hidden_updates_live_geometry_and_keeps_scrolling_and_author_styles() {
+ let mut ctx = TestContext::new();
+ load_fixture(&mut ctx).await;
+ assert_eq!(
+ metrics(&mut ctx).await,
+ json!([1280, 1265, 1280, 185, 85, 170, 85])
+ );
+ evaluate(
+ &mut ctx,
+ "scroller.scrollLeft=20;scroller.scrollTop=40;scrollTo(0,100);undefined",
+ )
+ .await;
+ for hidden in [true, false, true] {
+ set_hidden(&mut ctx, "SID-1", hidden).await;
+ // No screenshot or test-only refresh between the command and this
+ // read: acknowledgement must publish the new live geometry.
+ assert_eq!(
+ metrics(&mut ctx).await,
+ if hidden {
+ json!([1280, 1280, 1280, 200, 100, 170, 100])
+ } else {
+ json!([1280, 1265, 1280, 185, 85, 170, 85])
+ },
+ );
+ assert_eq!(
+ evaluate(&mut ctx, "[scroller.scrollLeft,scroller.scrollTop,scrollY,getComputedStyle(scroller).overflow,getComputedStyle(scroller).scrollbarWidth,getComputedStyle(stable).scrollbarGutter]").await,
+ json!([20,40,100,"scroll","auto","stable both-edges"]),
+ );
+ }
+}
+
+#[tokio::test(flavor = "multi_thread")]
+async fn scrollbars_hidden_validates_params_and_requires_layout_without_changing_policy() {
+ let mut ctx = TestContext::new();
+ load_fixture(&mut ctx).await;
+ for params in [
+ json!({}),
+ json!({"hidden":null}),
+ json!({"hidden":0}),
+ json!({"hidden":"true"}),
+ ] {
+ ctx.process_async(json!({"id":88502,"sessionId":"SID-1","method":"Emulation.setScrollbarsHidden","params":params})).await;
+ ctx.expect_error(88502, -32602, "InvalidParams");
+ }
+ assert_eq!(
+ metrics(&mut ctx).await,
+ json!([1280, 1265, 1280, 185, 85, 170, 85])
+ );
+
+ let mut mock = TestContext::new_with_layout_policy(moli_core::LayoutPolicy::Mock);
+ let mut bc = BrowserContext::new("BID-1".into());
+ bc.set_active_target_id("TID-1");
+ bc.attach_active_session("SID-1");
+ mock.conn.install_browser_context_fixture_for_test(bc);
+ expect_session_command_error(
+ &mut mock,
+ 88503,
+ "SID-1",
+ "Emulation.setScrollbarsHidden",
+ json!({"hidden":true}),
+ "Emulation.setScrollbarsHidden requires --layout",
+ )
+ .await;
+ assert!(
+ !mock
+ .conn
+ .emulation_session_state_for_session_owner(Some("SID-1"))
+ .unwrap()
+ .scrollbars_hidden
+ );
+}
+
+#[tokio::test(flavor = "multi_thread")]
+async fn scrollbars_hidden_is_replayed_before_navigation_scripts_and_initial_page_creation() {
+ let mut ctx = TestContext::new();
+ let mut bc = BrowserContext::new("BID-1".into());
+ bc.set_active_target_id("TID-1");
+ bc.set_target_url("about:blank".to_owned());
+ bc.attach_active_session("SID-1");
+ ctx.conn.install_browser_context_fixture_for_test(bc);
+ set_hidden(&mut ctx, "SID-1", true).await;
+ // Materialize the staged about:blank Page first, then navigate to a new
+ // Document. Both direct HTML creation and prepared commit must inherit.
+ let owner = crate::conn::CommandOwnerScope::for_session("SID-1");
+ let pending = ctx
+ .conn
+ .start_initial_document_page_ensure_for_owner(&owner)
+ .expect("initial Page ensure")
+ .expect("staged initial Page");
+ let completed = pending.wait().await.expect("initial Page creation");
+ ctx.conn
+ .complete_initial_document_page_build_for_owner(completed)
+ .await
+ .expect("initial Page installation");
+ assert_eq!(
+ evaluate(
+ &mut ctx,
+ "document.documentElement.clientWidth === innerWidth"
+ )
+ .await,
+ json!(true)
+ );
+ for hidden in [true, false, true] {
+ set_hidden(&mut ctx, "SID-1", hidden).await;
+ let html = format!(
+ "{HTML}<script>globalThis.__initial = [innerWidth,document.documentElement.clientWidth,scroller.clientWidth];</script>"
+ );
+ ctx.install_buffered_navigation_fixture_for_session_owner(
+ url::Url::parse("https://scrollbars.example/next").unwrap(),
+ html,
+ Some("SID-1"),
+ )
+ .await;
+ assert_eq!(
+ evaluate(&mut ctx, "__initial[1] === __initial[0]").await,
+ json!(hidden)
+ );
+ assert_eq!(
+ evaluate(&mut ctx, "__initial[2]").await,
+ json!(if hidden { 200 } else { 185 })
+ );
+ }
+}
+
+#[tokio::test(flavor = "multi_thread")]
+async fn scrollbars_hidden_respects_session_noops_and_detach_cleanup() {
+ let mut ctx = TestContext::new();
+ load_fixture(&mut ctx).await;
+ ctx.process_async(json!({"id":88504,"method":"Target.attachToTarget","params":{"targetId":"TID-1","flatten":true}})).await;
+ let b = ctx.take_response_by_id(88504)["result"]["sessionId"]
+ .as_str()
+ .unwrap()
+ .to_owned();
+ for (session, hidden, expected) in [
+ ("SID-1", true, 200),
+ (b.as_str(), false, 200),
+ (b.as_str(), true, 200),
+ ("SID-1", false, 185),
+ (b.as_str(), true, 185),
+ (b.as_str(), false, 185),
+ ("SID-1", true, 200),
+ ] {
+ set_hidden(&mut ctx, session, hidden).await;
+ assert_eq!(
+ evaluate(&mut ctx, "scroller.clientWidth").await,
+ json!(expected)
+ );
+ }
+ ctx.process_async(
+ json!({"id":88505,"method":"Target.detachFromTarget","params":{"sessionId":b}}),
+ )
+ .await;
+ ctx.expect_result(88505, json!({}), None);
+ assert_eq!(evaluate(&mut ctx, "scroller.clientWidth").await, json!(200));
+ ctx.process_async(json!({"id":88506,"method":"Target.attachToTarget","params":{"targetId":"TID-1","flatten":true}})).await;
+ let c = ctx.take_response_by_id(88506)["result"]["sessionId"]
+ .as_str()
+ .unwrap()
+ .to_owned();
+ set_hidden(&mut ctx, &c, true).await;
+ ctx.process_async(
+ json!({"id":88507,"method":"Target.detachFromTarget","params":{"sessionId":c}}),
+ )
+ .await;
+ ctx.expect_result(88507, json!({}), None);
+ assert_eq!(evaluate(&mut ctx, "scroller.clientWidth").await, json!(185));
+ set_hidden(&mut ctx, "SID-1", true).await;
+ assert_eq!(
+ evaluate(&mut ctx, "scroller.clientWidth").await,
+ json!(185),
+ "repeating the remaining handler's raw true is a no-op"
+ );
+}
+
+#[tokio::test(flavor = "multi_thread")]
+async fn scrollbars_hidden_false_and_detach_preserve_the_browser_startup_flag() {
+ let conn = crate::CdpConnection::new_with_initial_storage_partition_and_runtime_config(
+ crate::CdpInitialStoragePartition::memory(),
+ moli_core::runtime::NavigationRuntimeConfig::new(
+ moli_fetch::FetchConfig::default(),
+ moli_core::OptionalResourceFetchMask::NONE,
+ true,
+ moli_core::LayoutPolicy::OnDemand,
+ )
+ .with_scrollbars_hidden(true),
+ );
+ let mut ctx = TestContext::from_conn(conn);
+ load_fixture(&mut ctx).await;
+ for hidden in [false, true, false, true] {
+ set_hidden(&mut ctx, "SID-1", hidden).await;
+ assert_eq!(
+ metrics(&mut ctx).await,
+ json!([1280, 1280, 1280, 200, 100, 170, 100])
+ );
+ }
+ super::super::dispose_page_session_async(&mut ctx.conn, "SID-1")
+ .await
+ .unwrap();
+ // Disposing this handler also clears its device metrics override. Capture
+ // the resulting default viewport before checking scrollbar geometry.
+ ctx.capture_fixture_layout(Some("SID-1")).await;
+ assert_eq!(
+ evaluate(&mut ctx,"[innerWidth===document.documentElement.clientWidth,scroller.clientWidth,scroller.clientHeight,stable.clientWidth,stable.clientHeight]").await,
+ json!([true, 200, 100, 170, 100])
+ );
+}
diff --git a/moli-renderer-v8/src/devtools/command/nested.rs b/moli-renderer-v8/src/devtools/command/nested.rs
index b93e9c9f7..a786fbd33 100644
--- a/moli-renderer-v8/src/devtools/command/nested.rs
+++ b/moli-renderer-v8/src/devtools/command/nested.rs
@@ -189,6 +189,7 @@ impl RendererPageCommand {
| Self::SetNavigatorAndDocumentActivity { .. }
| Self::SetDocumentActivity(..)
| Self::SetEmulatedMedia(..)
+ | Self::SetScrollbarsHidden(..)
| Self::SetViewportSurface(..) => OwnerOnly,
#[cfg(test)]
diff --git a/moli-renderer-v8/src/native_bridge/context_host/layout.rs b/moli-renderer-v8/src/native_bridge/context_host/layout.rs
index 256efa8af..5100ea8ad 100644
--- a/moli-renderer-v8/src/native_bridge/context_host/layout.rs
+++ b/moli-renderer-v8/src/native_bridge/context_host/layout.rs
@@ -58,7 +58,13 @@ impl JsContextHost {
}
pub(crate) fn set_scrollbars_hidden(&mut self, hidden: bool) {
- self.scrollbars_hidden = hidden;
+ if self.scrollbars_hidden != hidden {
+ self.scrollbars_hidden = hidden;
+ self.clear_layout_rect_cache();
+ self.document_layout_state
+ .get_mut()
+ .mark_visual_state_dirty();
+ }
}
pub(crate) const fn scrollbars_hidden(&self) -> bool {
diff --git a/moli-renderer-v8/src/runtime/owner.rs b/moli-renderer-v8/src/runtime/owner.rs
index 7dc7646f8..06a02c525 100644
--- a/moli-renderer-v8/src/runtime/owner.rs
+++ b/moli-renderer-v8/src/runtime/owner.rs
@@ -113,6 +113,7 @@ pub struct RendererPreparedDocumentCommitConfiguration {
pub permission_overrides: Vec<crate::protocol_types::PermissionOverrideRegistration>,
pub extra_http_headers: moli_fetch::RequestHeaders,
pub script_execution_disabled: bool,
+ pub emulated_scrollbars_hidden: bool,
pub bypass_content_security_policy: bool,
pub emulated_media: crate::protocol_types::EmulatedMediaOverrides,
pub idle_override: Option<crate::protocol_types::EmulatedIdleOverride>,
@@ -172,6 +173,7 @@ pub struct RendererCreateHtmlPageRequest {
pub fetch_subresource_interception_resource_type: Option<crate::SubresourceResourceType>,
pub layout_policy: LayoutPolicy,
pub scrollbars_hidden: bool,
+ pub emulated_scrollbars_hidden: bool,
pub wpt_extensions_enabled: bool,
pub stage: PageVmInitStage,
pub reply_boundary: crate::RendererReplyBoundary,
@@ -223,6 +225,7 @@ pub struct RendererCreateStreamingRawPageRequest {
pub fetch_subresource_interception_resource_type: Option<crate::SubresourceResourceType>,
pub layout_policy: LayoutPolicy,
pub scrollbars_hidden: bool,
+ pub emulated_scrollbars_hidden: bool,
pub wpt_extensions_enabled: bool,
pub stage: PageVmInitStage,
pub reply_boundary: crate::RendererReplyBoundary,
diff --git a/moli-renderer-v8/src/runtime/owner/page_creation.rs b/moli-renderer-v8/src/runtime/owner/page_creation.rs
index 40b6db810..25141e026 100644
--- a/moli-renderer-v8/src/runtime/owner/page_creation.rs
+++ b/moli-renderer-v8/src/runtime/owner/page_creation.rs
@@ -697,6 +697,7 @@ impl RendererOwnerHandle {
.fetch_subresource_interception_resource_type,
layout_policy,
scrollbars_hidden,
+ emulated_scrollbars_hidden: options.emulated_scrollbars_hidden,
wpt_extensions_enabled: false,
stage,
reply_boundary: crate::RendererReplyBoundary::Stage,
@@ -763,6 +764,7 @@ impl RendererOwnerHandle {
.fetch_subresource_interception_resource_type,
layout_policy,
scrollbars_hidden,
+ emulated_scrollbars_hidden: options.emulated_scrollbars_hidden,
wpt_extensions_enabled: false,
stage,
reply_boundary: crate::RendererReplyBoundary::Stage,
@@ -837,6 +839,7 @@ impl RendererOwnerHandle {
fetch_subresource_interception_resource_type,
layout_policy,
scrollbars_hidden,
+ emulated_scrollbars_hidden,
wpt_extensions_enabled,
stage,
reply_boundary,
@@ -927,6 +930,7 @@ impl RendererOwnerHandle {
fetch_subresource_interception_resource_type,
layout_policy,
scrollbars_hidden,
+ emulated_scrollbars_hidden,
wpt_extensions_enabled,
root_frame_id,
main_document_commit,
@@ -1151,6 +1155,7 @@ impl RendererOwnerHandle {
fetch_subresource_interception_resource_type,
layout_policy,
scrollbars_hidden,
+ emulated_scrollbars_hidden,
wpt_extensions_enabled,
stage,
reply_boundary,
@@ -1229,6 +1234,7 @@ impl RendererOwnerHandle {
fetch_subresource_interception_resource_type,
layout_policy,
scrollbars_hidden,
+ emulated_scrollbars_hidden,
wpt_extensions_enabled,
root_frame_id,
main_document_commit,
diff --git a/moli-renderer-v8/src/runtime/owner_local_store/mod.rs b/moli-renderer-v8/src/runtime/owner_local_store/mod.rs
index b699d9278..fa315c9c3 100644
--- a/moli-renderer-v8/src/runtime/owner_local_store/mod.rs
+++ b/moli-renderer-v8/src/runtime/owner_local_store/mod.rs
@@ -911,6 +911,7 @@ impl RendererOwnerLocalStore {
request.permission_overrides = configuration.permission_overrides;
request.extra_http_headers = configuration.extra_http_headers;
request.script_execution_disabled = configuration.script_execution_disabled;
+ request.emulated_scrollbars_hidden = configuration.emulated_scrollbars_hidden;
request.bypass_content_security_policy =
configuration.bypass_content_security_policy;
request.emulated_media = configuration.emulated_media;
diff --git a/moli-renderer-v8/src/runtime/page.rs b/moli-renderer-v8/src/runtime/page.rs
index bcb693307..076204e46 100644
--- a/moli-renderer-v8/src/runtime/page.rs
+++ b/moli-renderer-v8/src/runtime/page.rs
@@ -34,6 +34,7 @@ pub struct RendererDocumentOptions {
pub runtime_bindings: Vec<crate::protocol_types::RuntimeBindingRegistration>,
pub extra_http_headers: moli_fetch::RequestHeaders,
pub script_execution_disabled: bool,
+ pub emulated_scrollbars_hidden: bool,
pub bypass_content_security_policy: bool,
pub emulated_media: crate::protocol_types::EmulatedMediaOverrides,
pub viewport_surface: Option<crate::protocol_types::ViewportSurface>,
diff --git a/moli-renderer-v8/src/runtime/page_commands.rs b/moli-renderer-v8/src/runtime/page_commands.rs
index 5ece901c1..f26d2caf8 100644
--- a/moli-renderer-v8/src/runtime/page_commands.rs
+++ b/moli-renderer-v8/src/runtime/page_commands.rs
@@ -1119,6 +1119,10 @@ impl PageVm {
self.set_script_execution_disabled(disabled);
Ok(RendererPageReply::Unit)
}
+ RendererPageCommand::SetScrollbarsHidden(hidden) => {
+ self.set_scrollbars_hidden(hidden)?;
+ Ok(RendererPageReply::Unit)
+ }
RendererPageCommand::SetBypassContentSecurityPolicy(bypass) => {
self.set_bypass_content_security_policy(bypass);
Ok(RendererPageReply::Unit)
diff --git a/moli-renderer-v8/src/runtime/page_network.rs b/moli-renderer-v8/src/runtime/page_network.rs
index f49e6a602..21e2191c6 100644
--- a/moli-renderer-v8/src/runtime/page_network.rs
+++ b/moli-renderer-v8/src/runtime/page_network.rs
@@ -153,6 +153,19 @@ impl PageVm {
self.vm_mut().set_script_execution_disabled(disabled);
}
+ pub(crate) fn set_scrollbars_hidden(&mut self, hidden: bool) -> anyhow::Result<()> {
+ let previous = self.scrollbars_hidden || self.emulated_scrollbars_hidden;
+ self.emulated_scrollbars_hidden = hidden;
+ let hidden = self.scrollbars_hidden || hidden;
+ if previous == hidden {
+ return Ok(());
+ }
+ self.vm_mut().set_scrollbars_hidden(hidden);
+ // Emulation changes the published geometry of this live Page. Finish
+ // that update before acknowledging the command to subsequent reads.
+ self.vm_mut().publish_layout()
+ }
+
pub(crate) fn set_bypass_content_security_policy(&mut self, bypass: bool) {
self.bypass_content_security_policy = bypass;
self.vm_mut().set_bypass_content_security_policy(bypass);
diff --git a/moli-renderer-v8/src/runtime/page_surface.rs b/moli-renderer-v8/src/runtime/page_surface.rs
index fbdcd8c97..12440d2a8 100644
--- a/moli-renderer-v8/src/runtime/page_surface.rs
+++ b/moli-renderer-v8/src/runtime/page_surface.rs
@@ -5165,6 +5165,7 @@ pub enum RendererPageCommand {
},
SetDocumentActivity(moli_page_types::DocumentActivity),
SetScriptExecutionDisabled(bool),
+ SetScrollbarsHidden(bool),
SetBypassContentSecurityPolicy(bool),
SetEmulatedMedia(crate::protocol_types::EmulatedMediaOverrides),
SetViewportSurface(Option<crate::protocol_types::ViewportSurface>),
diff --git a/moli-renderer-v8/src/runtime/page_vm/followed_navigation.rs b/moli-renderer-v8/src/runtime/page_vm/followed_navigation.rs
index 07c0ea6ba..68fa48123 100644
--- a/moli-renderer-v8/src/runtime/page_vm/followed_navigation.rs
+++ b/moli-renderer-v8/src/runtime/page_vm/followed_navigation.rs
@@ -1208,6 +1208,7 @@ impl PageVm {
.fetch_subresource_interception_resource_type,
layout_policy: self.layout_policy,
scrollbars_hidden: self.scrollbars_hidden,
+ emulated_scrollbars_hidden: self.emulated_scrollbars_hidden,
wpt_extensions_enabled: self.wpt_extensions_enabled,
root_frame_id: self.vm().root_frame_id().map(str::to_owned),
top_level_storage_key: None,
diff --git a/moli-renderer-v8/src/runtime/page_vm/mod.rs b/moli-renderer-v8/src/runtime/page_vm/mod.rs
index 918741224..d8baddd17 100644
--- a/moli-renderer-v8/src/runtime/page_vm/mod.rs
+++ b/moli-renderer-v8/src/runtime/page_vm/mod.rs
@@ -1096,6 +1096,7 @@ pub(crate) struct PageVmEnvConfig {
pub(crate) fetch_subresource_interception_resource_type: Option<crate::SubresourceResourceType>,
pub(crate) layout_policy: LayoutPolicy,
pub(crate) scrollbars_hidden: bool,
+ pub(crate) emulated_scrollbars_hidden: bool,
pub(crate) wpt_extensions_enabled: bool,
pub(crate) navigation_bootstrap_entry: Option<crate::native_bridge::NavigationHistoryEntrySeed>,
pub(crate) reserved_service_worker_client_id:
@@ -1618,6 +1619,7 @@ pub(crate) struct PageVm {
pub(super) fetch_subresource_interception_resource_type: Option<crate::SubresourceResourceType>,
pub(super) layout_policy: LayoutPolicy,
pub(super) scrollbars_hidden: bool,
+ pub(super) emulated_scrollbars_hidden: bool,
pub(super) wpt_extensions_enabled: bool,
pub(crate) runtime_hooks: PageVmRuntimeHooks,
pub(super) navigation_response: Option<PageVmNavigationResponse>,
@@ -4296,7 +4298,7 @@ impl PageVm {
let mut vm = vm_bootstrap.finish()?;
vm.set_document_navigator_identity(&env.navigator_identity);
vm.set_layout_policy(env.layout_policy);
- vm.set_scrollbars_hidden(env.scrollbars_hidden);
+ vm.set_scrollbars_hidden(env.scrollbars_hidden || env.emulated_scrollbars_hidden);
vm.install_page_task_capabilities(page_task_capabilities);
vm.set_root_document_lifecycle(document_lifecycle.clone());
let dom_agent_state = vm.renderer_dom_agent_state();
@@ -4361,6 +4363,7 @@ impl PageVm {
.fetch_subresource_interception_resource_type,
layout_policy: env.layout_policy,
scrollbars_hidden: env.scrollbars_hidden,
+ emulated_scrollbars_hidden: env.emulated_scrollbars_hidden,
wpt_extensions_enabled: env.wpt_extensions_enabled,
runtime_hooks,
navigation_response: None,
diff --git a/moli-renderer-v8/src/runtime/page_vm/test_support.rs b/moli-renderer-v8/src/runtime/page_vm/test_support.rs
index a4fa9c533..dd1d6f62f 100644
--- a/moli-renderer-v8/src/runtime/page_vm/test_support.rs
+++ b/moli-renderer-v8/src/runtime/page_vm/test_support.rs
@@ -698,6 +698,7 @@ fn minimal_test_page_vm_env_config() -> PageVmEnvConfig {
fetch_subresource_interception_resource_type: None,
layout_policy: crate::real_layout_test_policy(),
scrollbars_hidden: false,
+ emulated_scrollbars_hidden: false,
wpt_extensions_enabled: false,
navigation_bootstrap_entry: None,
reserved_service_worker_client_id: None,
diff --git a/moli-renderer-v8/src/runtime/page_vm/tests/extracted/page_task_dispatch.rs b/moli-renderer-v8/src/runtime/page_vm/tests/extracted/page_task_dispatch.rs
index f3d5b32c9..f0b7a4014 100644
--- a/moli-renderer-v8/src/runtime/page_vm/tests/extracted/page_task_dispatch.rs
+++ b/moli-renderer-v8/src/runtime/page_vm/tests/extracted/page_task_dispatch.rs
@@ -40,6 +40,7 @@ fn default_runtime_hooks_reject_direct_no_owner_page_vm_construction() {
fetch_subresource_interception_resource_type: None,
layout_policy: crate::real_layout_test_policy(),
scrollbars_hidden: false,
+ emulated_scrollbars_hidden: false,
wpt_extensions_enabled: false,
navigation_bootstrap_entry: None,
reserved_service_worker_client_id: None,
diff --git a/moli-renderer-v8/src/runtime/page_vm/tests/mod.rs b/moli-renderer-v8/src/runtime/page_vm/tests/mod.rs
index 2c759693c..27f668a13 100644
--- a/moli-renderer-v8/src/runtime/page_vm/tests/mod.rs
+++ b/moli-renderer-v8/src/runtime/page_vm/tests/mod.rs
@@ -690,6 +690,7 @@ fn test_page_vm_with_loader_dom_host_hooks_and_response_referrer_policy(
fetch_subresource_interception_resource_type: None,
layout_policy: crate::real_layout_test_policy(),
scrollbars_hidden: false,
+ emulated_scrollbars_hidden: false,
wpt_extensions_enabled: false,
navigation_bootstrap_entry: None,
reserved_service_worker_client_id: None,
diff --git a/moli-renderer-v8/src/runtime/page_vm/tests/rendering_update/scrollbars.rs b/moli-renderer-v8/src/runtime/page_vm/tests/rendering_update/scrollbars.rs
index 59e443776..5f7600a2e 100644
--- a/moli-renderer-v8/src/runtime/page_vm/tests/rendering_update/scrollbars.rs
+++ b/moli-renderer-v8/src/runtime/page_vm/tests/rendering_update/scrollbars.rs
@@ -1,5 +1,67 @@
use super::*;
+#[tokio::test(flavor = "current_thread")]
+async fn scrollbar_emulation_republishes_frames_hit_targets_and_screencast_pixels() {
+ run_page_vm_async_test(async move {
+ let loader = crate::network::ResourceRequestClient::new(&FetchConfig::default())?;
+ let mut page = test_page_vm_with_loader_and_document_url(
+ &loader, Vec::new(), Url::parse("https://example.com/scrollbar-emulation.html")?,
+ );
+ page.set_viewport_surface(Some(crate::protocol_types::ViewportSurface {
+ inner_width:800,inner_height:600,device_pixel_ratio:1.0,..Default::default()
+ }))?;
+ page.vm_mut().eval(r#"
+document.body.style.margin='0';
+document.body.innerHTML=`<div style='width:100vw;height:2000px;background:lime'></div>
+<div id=scroller style='position:absolute;top:0;width:200px;height:100px;overflow:scroll'>
+<div style='width:400px;height:300px;background:red'></div></div>
+<iframe id=child style='position:absolute;left:0;top:160px;width:300px;height:150px;border:0'></iframe>`;
+const childDoc=document.getElementById('child').contentDocument;
+childDoc.body.style.margin='0';
+childDoc.body.innerHTML='<div style="width:100vw;height:2000px"></div>';
+'installed'
+"#)?;
+ let crate::runtime::RendererCaptureScreencastFrameReply::Captured(initial) =
+ page.capture_screencast_frame(viewport_screencast_request(None))?
+ else { panic!("initial screencast frame"); };
+ let metrics = "JSON.stringify([document.documentElement.clientWidth,scroller.clientWidth,scroller.clientHeight,document.getElementById('child').contentDocument.documentElement.clientWidth])";
+ assert_eq!(page.vm_mut().eval(metrics)?,"[785,185,85,285]");
+ let initial_pixels = moli_image::decode_png(&initial.image.bytes)?;
+ let edge = ((300 * initial_pixels.width + 795) * 4) as usize;
+ assert_ne!(&initial_pixels.rgba[edge..edge+4],[0,255,0,255]);
+
+ page.set_scrollbars_hidden(true)?;
+ assert_eq!(page.vm_mut().eval(metrics)?,"[800,200,100,300]");
+ let crate::runtime::RendererCaptureScreencastFrameReply::Captured(hidden) =
+ page.capture_screencast_frame(viewport_screencast_request(Some(initial.visual_state)))?
+ else { panic!("scrollbar visibility must invalidate the screencast token"); };
+ let pixels = moli_image::decode_png(&hidden.image.bytes)?;
+ assert_eq!(&pixels.rgba[edge..edge+4],[0,255,0,255]);
+ let host = page.vm().context_host_weak_for_test().upgrade().unwrap();
+ assert!(host.borrow().with_latest_layout_tree_for_document(host.borrow().document_handle(),|tree| {
+ assert!(tree.scrollbar_hit_test(moli_layout::LayoutPoint::new(795.0,300.0)).is_none());
+ assert!(tree.scrollbar_hit_test(moli_layout::LayoutPoint::new(190.0,30.0)).is_none());
+ }).is_some());
+ page.set_scrollbars_hidden(true)?;
+ assert_eq!(
+ page.capture_screencast_frame(viewport_screencast_request(Some(hidden.visual_state.clone())))?,
+ crate::runtime::RendererCaptureScreencastFrameReply::Unchanged,
+ );
+ page.set_scrollbars_hidden(false)?;
+ assert_eq!(page.vm_mut().eval(metrics)?,"[785,185,85,285]");
+ let crate::runtime::RendererCaptureScreencastFrameReply::Captured(restored) =
+ page.capture_screencast_frame(viewport_screencast_request(Some(hidden.visual_state.clone())))?
+ else { panic!("restoring scrollbars must capture a fresh frame"); };
+ assert_ne!(restored.visual_state,hidden.visual_state);
+ let pixels = moli_image::decode_png(&restored.image.bytes)?;
+ assert_ne!(&pixels.rgba[edge..edge+4],[0,255,0,255]);
+ assert!(host.borrow().with_latest_layout_tree_for_document(host.borrow().document_handle(),|tree| {
+ assert!(tree.scrollbar_hit_test(moli_layout::LayoutPoint::new(795.0,300.0)).is_some());
+ }).is_some());
+ Ok::<_,anyhow::Error>(())
+ }).await.expect("scrollbar emulation updates all visual surfaces");
+}
+
#[tokio::test(flavor = "current_thread")]
async fn hidden_scrollbars_preserve_geometry_scrolling_and_computed_css_in_all_frames() {
run_page_vm_async_test(async move {
diff --git a/moli-renderer-v8/src/runtime/phase_one/mod.rs b/moli-renderer-v8/src/runtime/phase_one/mod.rs
index e31a6bd06..f499c63cd 100644
--- a/moli-renderer-v8/src/runtime/phase_one/mod.rs
+++ b/moli-renderer-v8/src/runtime/phase_one/mod.rs
@@ -681,6 +681,7 @@ mod tests {
fetch_subresource_interception_resource_type: None,
layout_policy: moli_page_types::LayoutPolicy::default(),
scrollbars_hidden: false,
+ emulated_scrollbars_hidden: false,
wpt_extensions_enabled: false,
navigation_bootstrap_entry: None,
reserved_service_worker_client_id: None,
diff --git a/moli-renderer-v8/src/runtime/phase_one/streaming.rs b/moli-renderer-v8/src/runtime/phase_one/streaming.rs
index a32e1a008..80a12e649 100644
--- a/moli-renderer-v8/src/runtime/phase_one/streaming.rs
+++ b/moli-renderer-v8/src/runtime/phase_one/streaming.rs
@@ -1084,6 +1084,7 @@ mod tests {
fetch_subresource_interception_resource_type: None,
layout_policy: moli_page_types::LayoutPolicy::default(),
scrollbars_hidden: false,
+ emulated_scrollbars_hidden: false,
wpt_extensions_enabled: false,
navigation_bootstrap_entry: None,
reserved_service_worker_client_id: None,
diff --git a/moli-renderer-v8/src/runtime/phase_one/tests/extracted/parser_blocking_scripts.rs b/moli-renderer-v8/src/runtime/phase_one/tests/extracted/parser_blocking_scripts.rs
index 98af0487b..af0b6b642 100644
--- a/moli-renderer-v8/src/runtime/phase_one/tests/extracted/parser_blocking_scripts.rs
+++ b/moli-renderer-v8/src/runtime/phase_one/tests/extracted/parser_blocking_scripts.rs
@@ -754,6 +754,7 @@ fn parser_owner_boundary_with_live_backend_queues_document_turn_before_runtime_w
fetch_subresource_interception_resource_type: None,
layout_policy: moli_page_types::LayoutPolicy::default(),
scrollbars_hidden: false,
+ emulated_scrollbars_hidden: false,
wpt_extensions_enabled: false,
navigation_bootstrap_entry: None,
reserved_service_worker_client_id: None,
@@ -1046,6 +1047,7 @@ fn parser_connected_head_script_does_not_push_later_head_tokens_into_body() {
fetch_subresource_interception_resource_type: None,
layout_policy: moli_page_types::LayoutPolicy::default(),
scrollbars_hidden: false,
+ emulated_scrollbars_hidden: false,
wpt_extensions_enabled: false,
navigation_bootstrap_entry: None,
reserved_service_worker_client_id: None,
@@ -1226,6 +1228,7 @@ fn parser_connected_external_head_script_with_live_head_and_body_mutation_keeps_
fetch_subresource_interception_resource_type: None,
layout_policy: moli_page_types::LayoutPolicy::default(),
scrollbars_hidden: false,
+ emulated_scrollbars_hidden: false,
wpt_extensions_enabled: false,
navigation_bootstrap_entry: None,
reserved_service_worker_client_id: None,
@@ -1828,6 +1831,7 @@ fn parser_owner_body_stylesheet_pause_preserves_unconsumed_tail_on_live_page_vm(
fetch_subresource_interception_resource_type: None,
layout_policy: moli_page_types::LayoutPolicy::default(),
scrollbars_hidden: false,
+ emulated_scrollbars_hidden: false,
wpt_extensions_enabled: false,
navigation_bootstrap_entry: None,
reserved_service_worker_client_id: None,
diff --git a/moli-renderer-v8/src/runtime/phase_one/tests/extracted/parser_script_handoffs.rs b/moli-renderer-v8/src/runtime/phase_one/tests/extracted/parser_script_handoffs.rs
index b55624399..702c22a09 100644
--- a/moli-renderer-v8/src/runtime/phase_one/tests/extracted/parser_script_handoffs.rs
+++ b/moli-renderer-v8/src/runtime/phase_one/tests/extracted/parser_script_handoffs.rs
@@ -361,6 +361,7 @@ fn external_async_handoff_marks_parser_stream_already_started_on_live_backend()
fetch_subresource_interception_resource_type: None,
layout_policy: moli_page_types::LayoutPolicy::default(),
scrollbars_hidden: false,
+ emulated_scrollbars_hidden: false,
wpt_extensions_enabled: false,
navigation_bootstrap_entry: None,
reserved_service_worker_client_id: None,
@@ -488,6 +489,7 @@ fn blocking_classic_handoff_registers_parser_owned_handle_on_live_backend() {
fetch_subresource_interception_resource_type: None,
layout_policy: moli_page_types::LayoutPolicy::default(),
scrollbars_hidden: false,
+ emulated_scrollbars_hidden: false,
wpt_extensions_enabled: false,
navigation_bootstrap_entry: None,
reserved_service_worker_client_id: None,
@@ -625,6 +627,7 @@ fn non_async_post_parse_handoff_registers_pending_before_source_and_seals_withou
fetch_subresource_interception_resource_type: None,
layout_policy: moli_page_types::LayoutPolicy::default(),
scrollbars_hidden: false,
+ emulated_scrollbars_hidden: false,
wpt_extensions_enabled: false,
navigation_bootstrap_entry: None,
reserved_service_worker_client_id: None,
@@ -797,6 +800,7 @@ fn parser_owned_external_module_handoff_starts_pending_script_tree_root_fetch()
fetch_subresource_interception_resource_type: None,
layout_policy: moli_page_types::LayoutPolicy::default(),
scrollbars_hidden: false,
+ emulated_scrollbars_hidden: false,
wpt_extensions_enabled: false,
navigation_bootstrap_entry: None,
reserved_service_worker_client_id: None,
@@ -1115,6 +1119,7 @@ fn parser_owned_inline_importmap_handoff_registers_parser_owned_handle_on_live_b
fetch_subresource_interception_resource_type: None,
layout_policy: moli_page_types::LayoutPolicy::default(),
scrollbars_hidden: false,
+ emulated_scrollbars_hidden: false,
wpt_extensions_enabled: false,
navigation_bootstrap_entry: None,
reserved_service_worker_client_id: None,
@@ -1283,6 +1288,7 @@ fn parser_owner_style_import_handoff_is_stylesheet_gated_on_live_page_vm() {
fetch_subresource_interception_resource_type: None,
layout_policy: moli_page_types::LayoutPolicy::default(),
scrollbars_hidden: false,
+ emulated_scrollbars_hidden: false,
wpt_extensions_enabled: false,
navigation_bootstrap_entry: None,
reserved_service_worker_client_id: None,
diff --git a/moli-renderer-v8/src/runtime/phase_one/tests/extracted/tree_mutations_and_document_write.rs b/moli-renderer-v8/src/runtime/phase_one/tests/extracted/tree_mutations_and_document_write.rs
index 3690f00e0..41dd54dc3 100644
--- a/moli-renderer-v8/src/runtime/phase_one/tests/extracted/tree_mutations_and_document_write.rs
+++ b/moli-renderer-v8/src/runtime/phase_one/tests/extracted/tree_mutations_and_document_write.rs
@@ -1155,6 +1155,7 @@ fn parser_connected_head_document_write_keeps_later_head_tokens_in_head() {
fetch_subresource_interception_resource_type: None,
layout_policy: moli_page_types::LayoutPolicy::default(),
scrollbars_hidden: false,
+ emulated_scrollbars_hidden: false,
wpt_extensions_enabled: false,
navigation_bootstrap_entry: None,
reserved_service_worker_client_id: None,
diff --git a/moli-renderer-v8/src/runtime/tests/extracted/navigation_streaming.rs b/moli-renderer-v8/src/runtime/tests/extracted/navigation_streaming.rs
index cffd37554..3bcb656aa 100644
--- a/moli-renderer-v8/src/runtime/tests/extracted/navigation_streaming.rs
+++ b/moli-renderer-v8/src/runtime/tests/extracted/navigation_streaming.rs
@@ -196,6 +196,7 @@ async fn streaming_unstyled_xml_converts_live_document_before_domcontentloaded()
permission_overrides: Vec::new(),
extra_http_headers: Default::default(),
script_execution_disabled: false,
+ emulated_scrollbars_hidden: false,
bypass_content_security_policy: false,
emulated_media: Default::default(),
idle_override: None,
@@ -331,6 +332,7 @@ async fn prepared_streaming_xml_document_waits_for_permit_and_uses_latest_config
permission_overrides: Vec::new(),
extra_http_headers: Default::default(),
script_execution_disabled: false,
+ emulated_scrollbars_hidden: false,
bypass_content_security_policy: false,
emulated_media: Default::default(),
idle_override: None,
@@ -789,6 +791,7 @@ globalThis.__preparedCommitObserved = JSON.stringify([
}],
extra_http_headers: Default::default(),
script_execution_disabled: false,
+ emulated_scrollbars_hidden: false,
bypass_content_security_policy: false,
emulated_media: Default::default(),
idle_override: None,