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
2 changes: 1 addition & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4206,7 +4206,7 @@ This methods attaches Playwright to an existing browser instance.
- `username` <[string]> Optional username to use if HTTP proxy requires authentication.
- `password` <[string]> Optional password to use if HTTP proxy requires authentication.
- `downloadsPath` <[string]> If specified, accepted downloads are downloaded into this folder. Otherwise, temporary folder is created and is deleted when browser is closed.
- `chromiumSandbox` <[boolean]> Enable Chromium sandboxing. Defaults to `true`.
- `chromiumSandbox` <[boolean]> Enable Chromium sandboxing. Defaults to `false`.
- `firefoxUserPrefs` <[Object]<[string], [string]|[number]|[boolean]>> Firefox user preferences. Learn more about the Firefox user preferences at [`about:config`](https://support.mozilla.org/en-US/kb/about-config-editor-firefox).
- `handleSIGINT` <[boolean]> Close the browser process on Ctrl-C. Defaults to `true`.
- `handleSIGTERM` <[boolean]> Close the browser process on SIGTERM. Defaults to `true`.
Expand Down
3 changes: 1 addition & 2 deletions src/server/browserType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export abstract class BrowserType {
let browserProcess: BrowserProcess | undefined = undefined;
const { launchedProcess, gracefullyClose, kill } = await launchProcess({
executablePath: executable,
args: this._amendArguments(browserArguments),
args: browserArguments,
env: this._amendEnvironment(env, userDataDir, executable, browserArguments),
handleSIGINT,
handleSIGTERM,
Expand Down Expand Up @@ -212,7 +212,6 @@ export abstract class BrowserType {
abstract _defaultArgs(options: types.LaunchOptions, isPersistent: boolean, userDataDir: string): string[];
abstract _connectToTransport(transport: ConnectionTransport, options: BrowserOptions): Promise<Browser>;
abstract _amendEnvironment(env: Env, userDataDir: string, executable: string, browserArguments: string[]): Env;
abstract _amendArguments(browserArguments: string[]): string[];
abstract _rewriteStartupError(error: Error): Error;
abstract _attemptToGracefullyCloseBrowser(transport: ConnectionTransport): void;
}
Expand Down
17 changes: 1 addition & 16 deletions src/server/chromium/chromium.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/

import * as path from 'path';
import * as os from 'os';
import { CRBrowser } from './crBrowser';
import { Env } from '../processLauncher';
import { kBrowserCloseMessageId } from './crConnection';
Expand Down Expand Up @@ -80,20 +79,6 @@ export class Chromium extends BrowserType {
return env;
}

_amendArguments(browserArguments: string[]): string[] {
// We currently only support Linux.
if (os.platform() !== 'linux')
return browserArguments;

// If there's already --no-sandbox passed in, do nothing.
if (browserArguments.indexOf('--no-sandbox') !== -1)
return browserArguments;
const runningAsRoot = process.geteuid && process.geteuid() === 0;
if (runningAsRoot)
return ['--no-sandbox', ...browserArguments];
return browserArguments;
}

_attemptToGracefullyCloseBrowser(transport: ConnectionTransport): void {
const message: ProtocolRequest = { method: 'Browser.close', id: kBrowserCloseMessageId, params: {} };
transport.send(message);
Expand Down Expand Up @@ -124,7 +109,7 @@ export class Chromium extends BrowserType {
'--blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4',
);
}
if (options.chromiumSandbox === false)
if (options.chromiumSandbox !== true)
chromeArguments.push('--no-sandbox');
if (proxy) {
const proxyURL = new URL(proxy.server);
Expand Down
4 changes: 0 additions & 4 deletions src/server/firefox/firefox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ export class Firefox extends BrowserType {
} : env;
}

_amendArguments(browserArguments: string[]): string[] {
return browserArguments;
}

_attemptToGracefullyCloseBrowser(transport: ConnectionTransport): void {
const message = { method: 'Browser.close', params: {}, id: kBrowserCloseMessageId };
transport.send(message);
Expand Down
4 changes: 0 additions & 4 deletions src/server/webkit/webkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ export class WebKit extends BrowserType {
return { ...env, CURL_COOKIE_JAR_PATH: path.join(userDataDir, 'cookiejar.db') };
}

_amendArguments(browserArguments: string[]): string[] {
return browserArguments;
}

_rewriteStartupError(error: Error): Error {
return error;
}
Expand Down