fix: no-sandbox flag logic to only disable sandbox when explicitly passed (#709)

This commit is contained in:
Copilot 2025-07-18 13:56:01 -07:00 committed by GitHub
parent 9f8441daa5
commit 29ac29e6bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 1 deletions

View File

@ -133,7 +133,7 @@ export function configFromCLIOptions(cliOptions: CLIOptions): Config {
};
// --no-sandbox was passed, disable the sandbox
if (!cliOptions.sandbox)
if (cliOptions.sandbox === false)
launchOptions.chromiumSandbox = false;
if (cliOptions.proxyServer) {

View File

@ -61,3 +61,20 @@ test.describe(() => {
})).toContainTextContent(`Firefox`);
});
});
test.describe('sandbox configuration', () => {
test('should enable sandbox by default (no --no-sandbox flag)', async () => {
const { configFromCLIOptions } = await import('../lib/config.js');
const config = configFromCLIOptions({ sandbox: undefined });
// When --no-sandbox is not passed, chromiumSandbox should not be set to false
// This allows the default (true) to be used
expect(config.browser?.launchOptions?.chromiumSandbox).toBeUndefined();
});
test('should disable sandbox when --no-sandbox flag is passed', async () => {
const { configFromCLIOptions } = await import('../lib/config.js');
const config = configFromCLIOptions({ sandbox: false });
// When --no-sandbox is passed, chromiumSandbox should be explicitly set to false
expect(config.browser?.launchOptions?.chromiumSandbox).toBe(false);
});
});