mirror of
https://github.com/servo/servo.git
synced 2025-09-25 06:10:08 +01:00
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 <josh@joshmatthews.net>
This commit is contained in:
parent
bb70c35a96
commit
0348234a28
2 changed files with 9 additions and 0 deletions
|
@ -143,6 +143,7 @@ pub(crate) struct WebViewDelegateImpl {
|
|||
pub(crate) url_changed: Cell<bool>,
|
||||
pub(crate) cursor_changed: Cell<bool>,
|
||||
pub(crate) new_frame_ready: Cell<bool>,
|
||||
pub(crate) load_status_changed: Cell<bool>,
|
||||
}
|
||||
|
||||
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(
|
||||
|
|
|
@ -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(..))));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue