mirror of
https://github.com/zhom/donutbrowser.git
synced 2026-09-28 12:12:14 +02:00
fix: properly handle headless mode
This commit is contained in:
@@ -156,7 +156,7 @@ impl BrowserRunner {
|
|||||||
url: Option<String>,
|
url: Option<String>,
|
||||||
_local_proxy_settings: Option<&ProxySettings>,
|
_local_proxy_settings: Option<&ProxySettings>,
|
||||||
remote_debugging_port: Option<u16>,
|
remote_debugging_port: Option<u16>,
|
||||||
_headless: bool,
|
headless: bool,
|
||||||
) -> Result<BrowserProfile, Box<dyn std::error::Error + Send + Sync>> {
|
) -> Result<BrowserProfile, Box<dyn std::error::Error + Send + Sync>> {
|
||||||
// Handle Camoufox profiles using CamoufoxManager
|
// Handle Camoufox profiles using CamoufoxManager
|
||||||
if profile.browser == "camoufox" {
|
if profile.browser == "camoufox" {
|
||||||
@@ -335,6 +335,7 @@ impl BrowserRunner {
|
|||||||
camoufox_config,
|
camoufox_config,
|
||||||
url,
|
url,
|
||||||
override_profile_path,
|
override_profile_path,
|
||||||
|
headless,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| -> Box<dyn std::error::Error + Send + Sync> {
|
.map_err(|e| -> Box<dyn std::error::Error + Send + Sync> {
|
||||||
@@ -592,6 +593,7 @@ impl BrowserRunner {
|
|||||||
profile.ephemeral,
|
profile.ephemeral,
|
||||||
&extension_paths,
|
&extension_paths,
|
||||||
remote_debugging_port,
|
remote_debugging_port,
|
||||||
|
headless,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| -> Box<dyn std::error::Error + Send + Sync> {
|
.map_err(|e| -> Box<dyn std::error::Error + Send + Sync> {
|
||||||
|
|||||||
@@ -207,6 +207,7 @@ impl CamoufoxManager {
|
|||||||
profile_path: &str,
|
profile_path: &str,
|
||||||
config: &CamoufoxConfig,
|
config: &CamoufoxConfig,
|
||||||
url: Option<&str>,
|
url: Option<&str>,
|
||||||
|
headless: bool,
|
||||||
) -> Result<CamoufoxLaunchResult, Box<dyn std::error::Error + Send + Sync>> {
|
) -> Result<CamoufoxLaunchResult, Box<dyn std::error::Error + Send + Sync>> {
|
||||||
let custom_config = if let Some(existing_fingerprint) = &config.fingerprint {
|
let custom_config = if let Some(existing_fingerprint) = &config.fingerprint {
|
||||||
log::info!("Using existing fingerprint from profile metadata");
|
log::info!("Using existing fingerprint from profile metadata");
|
||||||
@@ -251,8 +252,9 @@ impl CamoufoxManager {
|
|||||||
args.push(url.to_string());
|
args.push(url.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add headless flag for tests
|
// Add headless flag when requested via the API or via the CAMOUFOX_HEADLESS
|
||||||
if std::env::var("CAMOUFOX_HEADLESS").is_ok() {
|
// env var (used by integration tests)
|
||||||
|
if headless || std::env::var("CAMOUFOX_HEADLESS").is_ok() {
|
||||||
args.push("--headless".to_string());
|
args.push("--headless".to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -617,6 +619,7 @@ impl CamoufoxManager {
|
|||||||
config: CamoufoxConfig,
|
config: CamoufoxConfig,
|
||||||
url: Option<String>,
|
url: Option<String>,
|
||||||
override_profile_path: Option<std::path::PathBuf>,
|
override_profile_path: Option<std::path::PathBuf>,
|
||||||
|
headless: bool,
|
||||||
) -> Result<CamoufoxLaunchResult, String> {
|
) -> Result<CamoufoxLaunchResult, String> {
|
||||||
// Get profile path
|
// Get profile path
|
||||||
let profile_path = if let Some(ref override_path) = override_profile_path {
|
let profile_path = if let Some(ref override_path) = override_profile_path {
|
||||||
@@ -716,6 +719,7 @@ impl CamoufoxManager {
|
|||||||
&profile_path_str,
|
&profile_path_str,
|
||||||
&config,
|
&config,
|
||||||
url.as_deref(),
|
url.as_deref(),
|
||||||
|
headless,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| format!("Failed to launch Camoufox: {e}"))
|
.map_err(|e| format!("Failed to launch Camoufox: {e}"))
|
||||||
|
|||||||
@@ -504,6 +504,7 @@ impl WayfernManager {
|
|||||||
ephemeral: bool,
|
ephemeral: bool,
|
||||||
extension_paths: &[String],
|
extension_paths: &[String],
|
||||||
remote_debugging_port: Option<u16>,
|
remote_debugging_port: Option<u16>,
|
||||||
|
headless: bool,
|
||||||
) -> Result<WayfernLaunchResult, Box<dyn std::error::Error + Send + Sync>> {
|
) -> Result<WayfernLaunchResult, Box<dyn std::error::Error + Send + Sync>> {
|
||||||
let executable_path = BrowserRunner::instance()
|
let executable_path = BrowserRunner::instance()
|
||||||
.get_browser_executable_path(profile)
|
.get_browser_executable_path(profile)
|
||||||
@@ -672,7 +673,7 @@ impl WayfernManager {
|
|||||||
let profile_path_ref = std::path::Path::new(profile_path);
|
let profile_path_ref = std::path::Path::new(profile_path);
|
||||||
let mut launcher = chromium.persistent_context_launcher(profile_path_ref);
|
let mut launcher = chromium.persistent_context_launcher(profile_path_ref);
|
||||||
launcher = launcher.executable(executable_path.as_ref());
|
launcher = launcher.executable(executable_path.as_ref());
|
||||||
launcher = launcher.headless(false);
|
launcher = launcher.headless(headless);
|
||||||
launcher = launcher.chromium_sandbox(true);
|
launcher = launcher.chromium_sandbox(true);
|
||||||
launcher = launcher.args(&args);
|
launcher = launcher.args(&args);
|
||||||
launcher = launcher.timeout(0.0);
|
launcher = launcher.timeout(0.0);
|
||||||
@@ -1151,6 +1152,7 @@ impl WayfernManager {
|
|||||||
profile.ephemeral,
|
profile.ephemeral,
|
||||||
&[],
|
&[],
|
||||||
None,
|
None,
|
||||||
|
false,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user