From 0348234a28af09fbea30f850095c1b82a2826f7c Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Wed, 24 Sep 2025 03:19:32 -0400 Subject: [PATCH] Ensure test_multiprocess_preference_observer waits for reload to complete. (#39465) The test could intermittently fail if the second evaluate_javascript() command was received in the script thread before the reloaded page actually existed. By serializing the steps so that the page is completely loaded after the reload command is issued, we avoid this race. Testing: Locally reproduced, could not reproduce after the changes. Fixes: #38920 Signed-off-by: Josh Matthews --- components/servo/tests/common/mod.rs | 7 +++++++ components/servo/tests/multiprocess.rs | 2 ++ 2 files changed, 9 insertions(+) diff --git a/components/servo/tests/common/mod.rs b/components/servo/tests/common/mod.rs index b2df4f13c1f..fd6e99df4da 100644 --- a/components/servo/tests/common/mod.rs +++ b/components/servo/tests/common/mod.rs @@ -143,6 +143,7 @@ pub(crate) struct WebViewDelegateImpl { pub(crate) url_changed: Cell, pub(crate) cursor_changed: Cell, pub(crate) new_frame_ready: Cell, + pub(crate) load_status_changed: Cell, } impl WebViewDelegateImpl { @@ -166,6 +167,12 @@ impl WebViewDelegate for WebViewDelegateImpl { self.new_frame_ready.set(true); webview.paint(); } + + fn notify_load_status_changed(&self, _webview: WebView, status: LoadStatus) { + if status == LoadStatus::Complete { + self.load_status_changed.set(true); + } + } } pub(crate) fn evaluate_javascript( diff --git a/components/servo/tests/multiprocess.rs b/components/servo/tests/multiprocess.rs index cbd1255d110..6dd8a84c6fe 100644 --- a/components/servo/tests/multiprocess.rs +++ b/components/servo/tests/multiprocess.rs @@ -32,7 +32,9 @@ fn test_multiprocess_preference_observer(servo_test: &ServoTest) -> Result<(), a prefs.dom_servo_helpers_enabled = true; prefs::set(prefs); + delegate.load_status_changed.set(false); webview.reload(); + let _ = servo_test.spin(move || Ok(!delegate.load_status_changed.get())); let result = evaluate_javascript(servo_test, webview.clone(), "window.gc"); ensure!(matches!(result, Ok(JSValue::Object(..))));