mirror of
https://github.com/zhom/donutbrowser.git
synced 2026-12-05 10:03:44 +01:00
refactor: drop no-op flags
This commit is contained in:
1 parent
f8eba0d95a
commit
2ff89c5079
5 files changed
+5
-91
No files matched your search
@@ -3581,7 +3581,6 @@ test("custom launch arguments reach only their Wayfern profile", async () => {
|
||||
const disabled = processArgs.match(/--disable-features=(\S+)/g) ?? [];
|
||||
assert.equal(disabled.length, 1, "one merged --disable-features switch");
|
||||
assert.ok(disabled[0].includes("DonutLaunchArgsTest"));
|
||||
assert.ok(disabled[0].includes("AsyncDns"));
|
||||
assert.ok(disabled[0].includes("Prefetch"));
|
||||
assert.ok(
|
||||
processArgs.includes(
|
||||
|
||||
@@ -65,9 +65,8 @@ echo "Every Wayfern library resolves inside the sandbox."
|
||||
in_sandbox "'$chrome' --accept-terms-and-conditions" >"$out/wayfern-terms.log" 2>&1
|
||||
|
||||
port=9333
|
||||
in_sandbox "exec '$chrome' --headless=new --no-sandbox --disable-gpu --disable-dev-shm-usage \
|
||||
--no-first-run --user-data-dir='$dir/profile' --remote-debugging-address=127.0.0.1 \
|
||||
--remote-debugging-port=$port about:blank" >"$out/wayfern-output.log" 2>&1 &
|
||||
in_sandbox "exec '$chrome' --headless=new --no-sandbox --disable-dev-shm-usage \
|
||||
--user-data-dir='$dir/profile' --remote-debugging-port=$port about:blank" >"$out/wayfern-output.log" 2>&1 &
|
||||
wayfern_pid=$!
|
||||
|
||||
answered=0
|
||||
|
||||
@@ -194,16 +194,10 @@ impl LiveBrowser {
|
||||
command
|
||||
.arg("--headless=new")
|
||||
.arg("--remote-debugging-port=0")
|
||||
.arg("--remote-debugging-address=127.0.0.1")
|
||||
.arg(format!(
|
||||
"--user-data-dir={}",
|
||||
user_data_dir.path().display()
|
||||
))
|
||||
.arg("--no-first-run")
|
||||
.arg("--no-default-browser-check")
|
||||
.arg("--disable-background-mode")
|
||||
.arg("--use-mock-keychain")
|
||||
.arg("--password-store=basic")
|
||||
.arg("--window-size=1280,900")
|
||||
.arg("about:blank")
|
||||
.env("WAYFERN_TOKEN", token)
|
||||
|
||||
@@ -79,25 +79,17 @@ async fn browser_session(user_data_dir: &Path, new_cookie: &str) -> Vec<String>
|
||||
let mut command = tokio::process::Command::new(wayfern_executable());
|
||||
command
|
||||
.arg(format!("--remote-debugging-port={port}"))
|
||||
.arg("--remote-debugging-address=127.0.0.1")
|
||||
.arg(format!("--user-data-dir={}", user_data_dir.display()))
|
||||
.arg("--no-first-run")
|
||||
.arg("--no-default-browser-check")
|
||||
.arg("--disable-background-mode")
|
||||
.arg("--disable-component-update")
|
||||
.arg("--use-mock-keychain")
|
||||
.arg("--password-store=basic")
|
||||
.arg("--headless=new")
|
||||
.stdin(std::process::Stdio::null())
|
||||
.stdout(std::process::Stdio::null())
|
||||
.stderr(std::process::Stdio::null());
|
||||
// As a launch does on Linux, where the browser aborts without them.
|
||||
#[cfg(target_os = "linux")]
|
||||
command.args([
|
||||
"--no-sandbox",
|
||||
"--disable-setuid-sandbox",
|
||||
"--disable-dev-shm-usage",
|
||||
]);
|
||||
command.args(["--no-sandbox", "--disable-dev-shm-usage"]);
|
||||
let mut child = command.spawn().expect("the browser starts");
|
||||
let pid = child.id().unwrap();
|
||||
// Reaped as soon as it exits, or the stop below sees a zombie as running.
|
||||
|
||||
@@ -703,24 +703,6 @@ pub fn fit_window_to_work_area(requested: (u32, u32), work_area: Option<(u32, u3
|
||||
}
|
||||
}
|
||||
|
||||
/// Where a 152 browser keeps its entitlement cache: inside donut's own cache
|
||||
/// root rather than the OS default, so it is removed with the app's data and
|
||||
/// never shared between an e2e session and the real installation.
|
||||
pub fn entitlement_cache_switch(version: &str, cache_root: &Path) -> Option<String> {
|
||||
if !supports_wayfern_152(version) {
|
||||
return None;
|
||||
}
|
||||
let dir = cache_root.join("wayfern-entitlements");
|
||||
if let Err(e) = std::fs::create_dir_all(&dir) {
|
||||
log::warn!(
|
||||
"Entitlement cache dir create failed, browser keeps its default path={} err=\"{e}\"",
|
||||
dir.display()
|
||||
);
|
||||
return None;
|
||||
}
|
||||
Some(format!("--wayfern-entitlement-cache-dir={}", dir.display()))
|
||||
}
|
||||
|
||||
pub fn cdp_error_message(detail: &str) -> String {
|
||||
if let Some((_, rest)) = detail.split_once("CDP error: ") {
|
||||
if let Ok(error) = serde_json::from_str::<serde_json::Value>(rest.trim()) {
|
||||
@@ -1221,26 +1203,12 @@ impl HeadlessWayfern {
|
||||
cmd
|
||||
.arg("--headless=new")
|
||||
.arg(format!("--remote-debugging-port={port}"))
|
||||
.arg("--remote-debugging-address=127.0.0.1")
|
||||
.arg(format!("--user-data-dir={}", user_data_dir.display()))
|
||||
.arg("--no-first-run")
|
||||
.arg("--no-default-browser-check")
|
||||
.arg("--disable-background-mode")
|
||||
.arg("--use-mock-keychain")
|
||||
.arg("--password-store=basic")
|
||||
.arg("--disable-features=DialMediaRouteProvider")
|
||||
.arg("--enable-logging=stderr")
|
||||
.arg("--log-level=0");
|
||||
if let Some(switch) = entitlement_cache_switch(&profile.version, &crate::app_dirs::cache_dir())
|
||||
{
|
||||
cmd.arg(switch);
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
cmd
|
||||
.arg("--no-sandbox")
|
||||
.arg("--disable-setuid-sandbox")
|
||||
.arg("--disable-dev-shm-usage");
|
||||
cmd.arg("--no-sandbox").arg("--disable-dev-shm-usage");
|
||||
|
||||
cmd
|
||||
.stdin(Stdio::null())
|
||||
@@ -3301,29 +3269,17 @@ impl WayfernManager {
|
||||
|
||||
let mut args = vec![
|
||||
format!("--remote-debugging-port={port}"),
|
||||
"--remote-debugging-address=127.0.0.1".to_string(),
|
||||
format!("--user-data-dir={profile_path}"),
|
||||
"--no-first-run".to_string(),
|
||||
"--no-default-browser-check".to_string(),
|
||||
"--disable-background-mode".to_string(),
|
||||
"--disable-component-update".to_string(),
|
||||
"--crash-server-url=".to_string(),
|
||||
"--disable-updater".to_string(),
|
||||
"--hide-crash-restore-bubble".to_string(),
|
||||
// Release builds log nothing unless asked. Wayfern reports what it did
|
||||
// with the launch identity, WebRTC and the rest on stderr, and that is
|
||||
// the only channel that carries a refusal's reason.
|
||||
"--enable-logging=stderr".to_string(),
|
||||
"--log-level=0".to_string(),
|
||||
"--disable-infobars".to_string(),
|
||||
// Prefetch* / NoStatePrefetch: cross-site Speculation-Rules prefetch uses
|
||||
// an isolated NetworkContext that defaults to DIRECT egress (real host IP
|
||||
// leaks past the per-profile proxy). Disabling via a LAUNCH FLAG cannot be
|
||||
// re-enabled by an imported/synced network_prediction_options pref (which a
|
||||
// compile-time pref default could be).
|
||||
"--disable-features=DialMediaRouteProvider,DnsOverHttps,AsyncDns,Prefetch,PrefetchProxy,SpeculationRulesPrefetchFuture,NoStatePrefetch".to_string(),
|
||||
"--use-mock-keychain".to_string(),
|
||||
"--password-store=basic".to_string(),
|
||||
"--disable-features=PrefetchProxy".to_string(),
|
||||
];
|
||||
|
||||
if headless {
|
||||
@@ -3348,16 +3304,11 @@ impl WayfernManager {
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
args.push("--no-sandbox".to_string());
|
||||
args.push("--disable-setuid-sandbox".to_string());
|
||||
args.push("--disable-dev-shm-usage".to_string());
|
||||
}
|
||||
|
||||
if ephemeral {
|
||||
args.push("--disk-cache-size=1".to_string());
|
||||
args.push("--disable-breakpad".to_string());
|
||||
args.push("--disable-crash-reporter".to_string());
|
||||
args.push("--no-service-autorun".to_string());
|
||||
args.push("--disable-sync".to_string());
|
||||
}
|
||||
|
||||
if !extension_paths.is_empty() {
|
||||
@@ -3499,7 +3450,6 @@ impl WayfernManager {
|
||||
"data:application/x-ns-proxy-autoconfig,function FindProxyForURL(url,host){{return \"{pac_directive} {host_port}\";}}",
|
||||
);
|
||||
args.push(format!("--proxy-pac-url={pac_data}"));
|
||||
args.push("--dns-prefetch-disable".to_string());
|
||||
}
|
||||
|
||||
// A 152 browser takes the identity on its command line and commits it
|
||||
@@ -3618,10 +3568,6 @@ impl WayfernManager {
|
||||
);
|
||||
}
|
||||
args.extend(webrtc);
|
||||
args.extend(entitlement_cache_switch(
|
||||
&profile.version,
|
||||
&crate::app_dirs::cache_dir(),
|
||||
));
|
||||
// The persona is a property of the profile, so an identity-backed profile
|
||||
// seeds it from the identity and a legacy one from its id: either way the
|
||||
// same profile presents the same person on every launch.
|
||||
@@ -5752,22 +5698,6 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_entitlement_cache_lives_under_the_app_cache_and_only_on_152() {
|
||||
let root = tempfile::tempdir().unwrap();
|
||||
assert_eq!(entitlement_cache_switch("151.0.7922.76", root.path()), None);
|
||||
let switch = entitlement_cache_switch("152.0.7977.64", root.path()).unwrap();
|
||||
let expected = root.path().join("wayfern-entitlements");
|
||||
assert_eq!(
|
||||
switch,
|
||||
format!("--wayfern-entitlement-cache-dir={}", expected.display())
|
||||
);
|
||||
assert!(
|
||||
expected.is_dir(),
|
||||
"the directory exists before the browser starts"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_persona_document_is_written_per_profile_and_only_on_152() {
|
||||
let root = tempfile::tempdir().unwrap();
|
||||
|
||||
Reference in new issue
Block a user