feat: add --allow-file-access flag for file:// URL support (#375)

* feat: add --allow-file-access flag for file:// URL support

Adds the ability to open and interact with local files using file:// URLs.
This enables use cases like viewing local PDFs, testing local HTML files,
and allowing JavaScript to access other local files via XHR.

The flag adds Chromium's --allow-file-access-from-files and --allow-file-access
launch arguments. Only supported in Chromium browsers.

Fixes #345

* fix: add cli_allow_file_access tracking to prevent spurious warning

When --allow-file-access is set via AGENT_BROWSER_ALLOW_FILE_ACCESS env var
(not CLI), don't warn about the flag being ignored when daemon is already running.
This commit is contained in:
Chris Tate
2026-02-05 00:24:28 -06:00
committed by GitHub
parent 74be667c80
commit 07c2372766
12 changed files with 262 additions and 5 deletions
+8 -1
View File
@@ -205,6 +205,7 @@ fn main() {
flags.proxy.as_deref(),
flags.proxy_bypass.as_deref(),
flags.ignore_https_errors,
flags.allow_file_access,
flags.profile.as_deref(),
flags.state.as_deref(),
flags.provider.as_deref(),
@@ -267,6 +268,7 @@ fn main() {
None
},
flags.ignore_https_errors.then(|| "--ignore-https-errors"),
flags.cli_allow_file_access.then(|| "--allow-file-access"),
]
.into_iter()
.flatten()
@@ -417,7 +419,8 @@ fn main() {
|| flags.state.is_some()
|| flags.proxy.is_some()
|| flags.args.is_some()
|| flags.user_agent.is_some())
|| flags.user_agent.is_some()
|| flags.allow_file_access)
&& flags.cdp.is_none()
&& flags.provider.is_none()
{
@@ -470,6 +473,10 @@ fn main() {
launch_cmd["ignoreHTTPSErrors"] = json!(true);
}
if flags.allow_file_access {
launch_cmd["allowFileAccess"] = json!(true);
}
match send_command(launch_cmd, &flags.session) {
Ok(resp) if !resp.success => {
// Launch command failed (e.g., invalid state file, profile error)