From 29ac29e6bb6371cc7d1879185eb492e71cdde6d3 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Fri, 18 Jul 2025 13:56:01 -0700 Subject: [PATCH] fix: no-sandbox flag logic to only disable sandbox when explicitly passed (#709) --- src/config.ts | 2 +- tests/config.spec.ts | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/config.ts b/src/config.ts index 0af91cd..994cd4f 100644 --- a/src/config.ts +++ b/src/config.ts @@ -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) { diff --git a/tests/config.spec.ts b/tests/config.spec.ts index e378bc7..4e3a464 100644 --- a/tests/config.spec.ts +++ b/tests/config.spec.ts @@ -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); + }); +});