Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/src/api/class-electron.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,6 @@ Maximum time in milliseconds to wait for the application to start. Defaults to `

### option: Electron.launch.tracesDir = %%-browser-option-tracesdir-%%
* since: v1.36

### option: Electron.launch.chromiumSandbox = %%-browser-option-chromiumsandbox-%%
* since: v1.59
5 changes: 5 additions & 0 deletions packages/playwright-client/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19566,6 +19566,11 @@ export interface Electron {
*/
bypassCSP?: boolean;

/**
* Enable Chromium sandboxing. Defaults to `false`.
*/
chromiumSandbox?: boolean;

/**
* Emulates [prefers-colors-scheme](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme)
* media feature, supported values are `'light'` and `'dark'`. See
Expand Down
1 change: 1 addition & 0 deletions packages/playwright-core/src/protocol/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2529,6 +2529,7 @@ scheme.ElectronInitializer = tOptional(tObject({}));
scheme.ElectronLaunchParams = tObject({
executablePath: tOptional(tString),
args: tOptional(tArray(tString)),
chromiumSandbox: tOptional(tBoolean),
cwd: tOptional(tString),
env: tOptional(tArray(tType('NameValue'))),
timeout: tFloat,
Expand Down
3 changes: 1 addition & 2 deletions packages/playwright-core/src/server/electron/electron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ export class Electron extends SdkObject {
let electronArguments = ['--inspect=0', '--remote-debugging-port=0', ...(options.args || [])];

if (os.platform() === 'linux') {
const runningAsRoot = process.geteuid && process.geteuid() === 0;
if (runningAsRoot && electronArguments.indexOf('--no-sandbox') === -1)
if (!options.chromiumSandbox && electronArguments.indexOf('--no-sandbox') === -1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

won't it spam into the terminal now if running not as root?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When running as non-root it won't use sandbox. I don't think it spams.

electronArguments.unshift('--no-sandbox');
}

Expand Down
5 changes: 5 additions & 0 deletions packages/playwright-core/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19566,6 +19566,11 @@ export interface Electron {
*/
bypassCSP?: boolean;

/**
* Enable Chromium sandboxing. Defaults to `false`.
*/
chromiumSandbox?: boolean;

/**
* Emulates [prefers-colors-scheme](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme)
* media feature, supported values are `'light'` and `'dark'`. See
Expand Down
2 changes: 2 additions & 0 deletions packages/protocol/src/channels.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4429,6 +4429,7 @@ export interface ElectronChannel extends ElectronEventTarget, Channel {
export type ElectronLaunchParams = {
executablePath?: string,
args?: string[],
chromiumSandbox?: boolean,
cwd?: string,
env?: NameValue[],
timeout: number,
Expand Down Expand Up @@ -4465,6 +4466,7 @@ export type ElectronLaunchParams = {
export type ElectronLaunchOptions = {
executablePath?: string,
args?: string[],
chromiumSandbox?: boolean,
cwd?: string,
env?: NameValue[],
acceptDownloads?: 'accept' | 'deny' | 'internal-browser-default',
Expand Down
1 change: 1 addition & 0 deletions packages/protocol/src/protocol.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3869,6 +3869,7 @@ Electron:
args:
type: array?
items: string
chromiumSandbox: boolean?
cwd: string?
env:
type: array?
Expand Down
Loading