fix(servo): lease persistent profile data

This commit is contained in:
2026-07-09 23:05:10 -04:00
parent 62ee35a164
commit 755a6aabd8
3 changed files with 60 additions and 3 deletions
+35 -1
View File
@@ -2,7 +2,9 @@
use std::{
error::Error,
io, thread,
io,
process::{Command, Stdio},
thread,
time::{Duration, Instant},
};
@@ -64,6 +66,38 @@ fn live_sidecar_streams_rgba_and_flushes_profile_storage_on_shutdown() -> Result
Ok(())
}
#[test]
fn live_sidecar_leases_profile_data_directory_for_process_lifetime() -> Result<(), Box<dyn Error>> {
let root = TestDirectory::new()?;
let leased_dir = root.path().join("leased");
let independent_dir = root.path().join("independent");
let mut owner = Sidecar::spawn(&leased_dir)?;
assert!(leased_dir.join(".ely-servo-sidecar.lock").is_file());
let rejected = Command::new(env!("CARGO_BIN_EXE_ely_servo_sidecar"))
.arg("live")
.arg("--profile-data-dir")
.arg(&leased_dir)
.stdin(Stdio::null())
.stdout(Stdio::null())
.stderr(Stdio::piped())
.output()?;
let stderr = String::from_utf8(rejected.stderr)?;
assert!(!rejected.status.success(), "second sidecar unexpectedly acquired the profile lease");
assert!(
stderr.contains("ProfileDataDirectoryInUse"),
"second sidecar reported an unexpected error: {stderr}"
);
let mut independent = Sidecar::spawn(&independent_dir)?;
independent.shutdown()?;
owner.shutdown()?;
let mut replacement = Sidecar::spawn(&leased_dir)?;
replacement.shutdown()?;
Ok(())
}
#[test]
fn servo_originated_history_url_does_not_trigger_a_second_navigation() -> Result<(), Box<dyn Error>>
{