mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
feat: introduce chromiumSandbox launch option (#3067)
The option is intended to be used instead of the `--no-sandbox` argument that is accepted exclusively by Chromium and crashes WebKit. References #2745
This commit is contained in:
parent
af20d2704f
commit
47e30f047b
@ -3983,6 +3983,7 @@ This methods attaches Playwright to an existing browser instance.
|
|||||||
- `username` <[string]> Optional username to use if HTTP proxy requires authentication.
|
- `username` <[string]> Optional username to use if HTTP proxy requires authentication.
|
||||||
- `password` <[string]> Optional password 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.
|
- `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`.
|
||||||
- `firefoxUserPrefs` <[Object]> Firefox user preferences. Learn more about the Firefox user preferences at [`about:config`](https://support.mozilla.org/en-US/kb/about-config-editor-firefox).
|
- `firefoxUserPrefs` <[Object]> 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`.
|
- `handleSIGINT` <[boolean]> Close the browser process on Ctrl-C. Defaults to `true`.
|
||||||
- `handleSIGTERM` <[boolean]> Close the browser process on SIGTERM. Defaults to `true`.
|
- `handleSIGTERM` <[boolean]> Close the browser process on SIGTERM. Defaults to `true`.
|
||||||
@ -4024,6 +4025,7 @@ const browser = await chromium.launch({ // Or 'firefox' or 'webkit'.
|
|||||||
- `password` <[string]> Optional password to use if HTTP proxy requires authentication.
|
- `password` <[string]> Optional password to use if HTTP proxy requires authentication.
|
||||||
- `acceptDownloads` <[boolean]> Whether to automatically download all the attachments. Defaults to `false` where all the downloads are canceled.
|
- `acceptDownloads` <[boolean]> Whether to automatically download all the attachments. Defaults to `false` where all the downloads are canceled.
|
||||||
- `downloadsPath` <[string]> If specified, accepted downloads are downloaded into this folder. Otherwise, temporary folder is created and is deleted when browser is closed.
|
- `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`.
|
||||||
- `handleSIGINT` <[boolean]> Close the browser process on Ctrl-C. Defaults to `true`.
|
- `handleSIGINT` <[boolean]> Close the browser process on Ctrl-C. Defaults to `true`.
|
||||||
- `handleSIGTERM` <[boolean]> Close the browser process on SIGTERM. Defaults to `true`.
|
- `handleSIGTERM` <[boolean]> Close the browser process on SIGTERM. Defaults to `true`.
|
||||||
- `handleSIGHUP` <[boolean]> Close the browser process on SIGHUP. Defaults to `true`.
|
- `handleSIGHUP` <[boolean]> Close the browser process on SIGHUP. Defaults to `true`.
|
||||||
@ -4072,6 +4074,7 @@ Launches browser that uses persistent storage located at `userDataDir` and retur
|
|||||||
- `username` <[string]> Optional username to use if HTTP proxy requires authentication.
|
- `username` <[string]> Optional username to use if HTTP proxy requires authentication.
|
||||||
- `password` <[string]> Optional password 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.
|
- `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`.
|
||||||
- `firefoxUserPrefs` <[Object]> Firefox user preferences. Learn more about the Firefox user preferences at [`about:config`](https://support.mozilla.org/en-US/kb/about-config-editor-firefox).
|
- `firefoxUserPrefs` <[Object]> 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`.
|
- `handleSIGINT` <[boolean]> Close the browser process on Ctrl-C. Defaults to `true`.
|
||||||
- `handleSIGTERM` <[boolean]> Close the browser process on SIGTERM. Defaults to `true`.
|
- `handleSIGTERM` <[boolean]> Close the browser process on SIGTERM. Defaults to `true`.
|
||||||
|
|||||||
@ -178,11 +178,11 @@ Bitbucket Pipelines can use public [Docker images as build environments](https:/
|
|||||||
image: mcr.microsoft.com/playwright:bionic
|
image: mcr.microsoft.com/playwright:bionic
|
||||||
```
|
```
|
||||||
|
|
||||||
While the Docker image supports sandboxing for Chromium, it does not work in the Bitbucket Pipelines environment. To launch Chromium on Bitbucket Pipelines, use the `--no-sandbox` launch argument.
|
While the Docker image supports sandboxing for Chromium, it does not work in the Bitbucket Pipelines environment. To launch Chromium on Bitbucket Pipelines, use the `chromiumSandbox: false` launch argument.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const { chromium } = require('playwright');
|
const { chromium } = require('playwright');
|
||||||
const browser = await chromium.launch({ args: ['--no-sandbox'] });
|
const browser = await chromium.launch({ chromiumSandbox: false });
|
||||||
```
|
```
|
||||||
|
|
||||||
### GitLab CI
|
### GitLab CI
|
||||||
|
|||||||
@ -140,10 +140,10 @@ the host should be configured first. If there's no good sandbox for Chrome to us
|
|||||||
with the error `No usable sandbox!`.
|
with the error `No usable sandbox!`.
|
||||||
|
|
||||||
If you **absolutely trust** the content you open in Chrome, you can launch Chrome
|
If you **absolutely trust** the content you open in Chrome, you can launch Chrome
|
||||||
with the `--no-sandbox` argument:
|
with the `chromiumSandbox: false` option:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const browser = await playwright.chromium.launch({args: ['--no-sandbox', '--disable-setuid-sandbox']});
|
const browser = await playwright.chromium.launch({ chromiumSandbox: false });
|
||||||
```
|
```
|
||||||
|
|
||||||
> **NOTE**: Running without a sandbox is **strongly discouraged**. Consider configuring a sandbox instead.
|
> **NOTE**: Running without a sandbox is **strongly discouraged**. Consider configuring a sandbox instead.
|
||||||
|
|||||||
@ -115,6 +115,8 @@ export class Chromium extends BrowserTypeBase {
|
|||||||
'--mute-audio'
|
'--mute-audio'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (options.chromiumSandbox === false)
|
||||||
|
chromeArguments.push('--no-sandbox');
|
||||||
if (proxy) {
|
if (proxy) {
|
||||||
const proxyURL = new URL(proxy.server);
|
const proxyURL = new URL(proxy.server);
|
||||||
const isSocks = proxyURL.protocol === 'socks5:';
|
const isSocks = proxyURL.protocol === 'socks5:';
|
||||||
|
|||||||
@ -295,6 +295,7 @@ export type LaunchOptionsBase = {
|
|||||||
devtools?: boolean,
|
devtools?: boolean,
|
||||||
proxy?: ProxySettings,
|
proxy?: ProxySettings,
|
||||||
downloadsPath?: string,
|
downloadsPath?: string,
|
||||||
|
chromiumSandbox?: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
export type LaunchOptions = LaunchOptionsBase & { slowMo?: number };
|
export type LaunchOptions = LaunchOptionsBase & { slowMo?: number };
|
||||||
|
|||||||
@ -194,10 +194,7 @@ playwright.chromium.launch().then(async browser => {
|
|||||||
// Example with launch options
|
// Example with launch options
|
||||||
(async () => {
|
(async () => {
|
||||||
const browser = await playwright.chromium.launch({
|
const browser = await playwright.chromium.launch({
|
||||||
args: [
|
chromiumSandbox: false,
|
||||||
'--no-sandbox',
|
|
||||||
'--disable-setuid-sandbox',
|
|
||||||
],
|
|
||||||
handleSIGINT: true,
|
handleSIGINT: true,
|
||||||
handleSIGHUP: true,
|
handleSIGHUP: true,
|
||||||
handleSIGTERM: true,
|
handleSIGTERM: true,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user