Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
Revert "chore: rename --no-sandbox to --no-chromium-sandbox (#39208)" (#39277)
Yury Semikhatskyc6385e174b4b
diff --git a/packages/playwright/src/mcp/browser/config.ts b/packages/playwright/src/mcp/browser/config.tsindex 2dbecdc8a5..a8b30227b2 100644--- a/packages/playwright/src/mcp/browser/config.ts+++ b/packages/playwright/src/mcp/browser/config.ts@@ -44,7 +44,6 @@ export type CLIOptions = {cdpEndpoint?: string;cdpHeader?: Record<string, string>;cdpTimeout?: number;- chromiumSandbox?: boolean;codegen?: 'typescript' | 'none';config?: string;consoleLevel?: 'error' | 'warning' | 'info' | 'debug';@@ -59,6 +58,7 @@ export type CLIOptions = {initPage?: string[];isolated?: boolean;imageResponses?: 'allow' | 'omit';+ sandbox?: boolean;outputDir?: string;outputMode?: 'file' | 'stdout';port?: number;@@ -223,10 +223,10 @@ export function configFromCLIOptions(cliOptions: CLIOptions): Config & { configFheadless: cliOptions.headless,};- // --chromium-sandbox was passed, enable the chromium sandbox- // --no-chromium-sandbox was passed, disable the chromium sandbox- if (cliOptions.chromiumSandbox !== undefined)- launchOptions.chromiumSandbox = cliOptions.chromiumSandbox;+ // --sandbox was passed, enable the sandbox+ // --no-sandbox was passed, disable the sandbox+ if (cliOptions.sandbox !== undefined)+ launchOptions.chromiumSandbox = cliOptions.sandbox;if (cliOptions.proxyServer) {launchOptions.proxy = {@@ -338,7 +338,7 @@ export function configFromEnv(): Config & { configFile?: string } {options.isolated = envToBoolean(process.env.PLAYWRIGHT_MCP_ISOLATED);if (process.env.PLAYWRIGHT_MCP_IMAGE_RESPONSES)options.imageResponses = enumParser<'allow' | 'omit'>('--image-responses', ['allow', 'omit'], process.env.PLAYWRIGHT_MCP_IMAGE_RESPONSES);- options.chromiumSandbox = envToBoolean(process.env.PLAYWRIGHT_MCP_CHROMIUM_SANDBOX);+ options.sandbox = envToBoolean(process.env.PLAYWRIGHT_MCP_SANDBOX);options.outputDir = envToString(process.env.PLAYWRIGHT_MCP_OUTPUT_DIR);options.port = numberParser(process.env.PLAYWRIGHT_MCP_PORT);options.proxyBypass = envToString(process.env.PLAYWRIGHT_MCP_PROXY_BYPASS);diff --git a/packages/playwright/src/mcp/program.ts b/packages/playwright/src/mcp/program.tsindex fda9347a8d..63d66a6855 100644--- a/packages/playwright/src/mcp/program.ts+++ b/packages/playwright/src/mcp/program.ts@@ -37,8 +37,6 @@ export function decorateMCPCommand(command: Command, version: string) {.option('--cdp-endpoint <endpoint>', 'CDP endpoint to connect to.').option('--cdp-header <headers...>', 'CDP headers to send with the connect request, multiple can be specified.', headerParser).option('--cdp-timeout <timeout>', 'timeout in milliseconds for connecting to CDP endpoint, defaults to 30000ms', numberParser)- .option('--chromium-sandbox', 'enable the chromium sandbox. disable with --no-chromium-sandbox.')- .option('--no-chromium-sandbox', 'disable the chromium sandbox.').option('--codegen <lang>', 'specify the language to use for code generation, possible values: "typescript", "none". Default is "typescript".', enumParser.bind(null, '--codegen', ['none', 'typescript'])).option('--config <path>', 'path to the configuration file.').option('--console-level <level>', 'level of console messages to return: "error", "warning", "info", "debug". Each level includes the messages of more severe levels.', enumParser.bind(null, '--console-level', ['error', 'warning', 'info', 'debug']))@@ -53,11 +51,13 @@ export function decorateMCPCommand(command: Command, version: string) {.option('--init-script <path...>', 'path to JavaScript file to add as an initialization script. The script will be evaluated in every page before any of the page\'s scripts. Can be specified multiple times.').option('--isolated', 'keep the browser profile in memory, do not save it to disk.').option('--image-responses <mode>', 'whether to send image responses to the client. Can be "allow" or "omit", Defaults to "allow".', enumParser.bind(null, '--image-responses', ['allow', 'omit']))+ .option('--no-sandbox', 'disable the sandbox for all process types that are normally sandboxed.').option('--output-dir <path>', 'path to the directory for output files.').option('--output-mode <mode>', 'whether to save snapshots, console messages, network logs to a file or to the standard output. Can be "file" or "stdout". Default is "stdout".', enumParser.bind(null, '--output-mode', ['file', 'stdout'])).option('--port <port>', 'port to listen on for SSE transport.').option('--proxy-bypass <bypass>', 'comma-separated domains to bypass proxy, for example ".com,chromium.org,.domain.com"').option('--proxy-server <proxy>', 'specify proxy server, for example "http://myproxy:3128" or "socks5://myproxy:8080"')+ .option('--sandbox', 'enable the sandbox for all process types that are normally not sandboxed.').option('--save-session', 'Whether to save the Playwright MCP session into the output directory.').option('--save-trace', 'Whether to save the Playwright Trace of the session into the output directory.').option('--save-video <size>', 'Whether to save the video of the session into the output directory. For example "--save-video=800x600"', resolutionParser.bind(null, '--save-video'))@@ -74,8 +74,8 @@ export function decorateMCPCommand(command: Command, version: string) {.addOption(new ProgramOption('--vision', 'Legacy option, use --caps=vision instead').hideHelp()).action(async options => {- // normalize the --no-chromium-sandbox option: chromiumSandbox = true => nothing was passed, chromiumSandbox = false => --no-chromium-sandbox was passed.- options.chromiumSandbox = options.chromiumSandbox === true ? undefined : false;+ // normalize the --no-sandbox option: sandbox = true => nothing was passed, sandbox = false => --no-sandbox was passed.+ options.sandbox = options.sandbox === true ? undefined : false;setupExitWatchdog();diff --git a/tests/mcp/config.spec.ts b/tests/mcp/config.spec.tsindex 25ae88ae4d..9e0eaadfe8 100644--- a/tests/mcp/config.spec.ts+++ b/tests/mcp/config.spec.ts@@ -78,15 +78,15 @@ test.describe(() => {});});-test('test chromiumSandbox configuration', async ({}) => {- async function sandboxOption(cli: any) {- const config: any = await resolveCLIConfig(cli);- return config.browser.launchOptions.chromiumSandbox;- }+async function sandboxOption(cli: any) {+ const config: any = await resolveCLIConfig(cli);+ return config.browser.launchOptions.chromiumSandbox;+}+test('test sandbox configuration', async ({}) => {expect(await sandboxOption({ browser: 'chromium' })).toBe(process.platform !== 'linux');- expect(await sandboxOption({ browser: 'chromium', chromiumSandbox: true })).toBe(true);- expect(await sandboxOption({ browser: 'chrome', chromiumSandbox: false })).toBe(false);+ expect(await sandboxOption({ browser: 'chromium', sandbox: true })).toBe(true);+ expect(await sandboxOption({ browser: 'chrome', sandbox: false })).toBe(false);expect(await sandboxOption({ browser: 'chrome' })).toBe(true);expect(await sandboxOption({ browser: 'msedge' })).toBe(true);});