Commit graph

82 commits

Author SHA1 Message Date
Dmitry Gozman 655013d025
chore: move shared utilities to src/utils (#3575) 2020-08-22 07:07:13 -07:00
Dmitry Gozman 0a22e2758a
fix(chromium): disable lazy loading iframes (#3535)
These do not play nicely with our "page is loaded when all frames
are loaded" logic.
2020-08-19 15:58:13 -07:00
Dmitry Gozman 9790ea5b5d
chore: align more server-side options with rpc protocol (#3506)
This touches:
- noDefaultViewport;
- ignoreAllDefaultArgs;
- env;
- validateXYZ logic that was copying objects - we do not need that anymore;
- shuffles some converters closer to their usage.
2020-08-18 09:37:40 -07:00
Dmitry Gozman 58fc6b4003
chore: align some server-side methods with rpc calls (#3504)
- Never write to console on the server side - we use stdout for
  communication. This includes logPolitely and deprecate.
- Pass undefined instead of null in some BrowserContext methods.
- Use explicit _setFileChooserIntercepted instead of on/off magic.
2020-08-17 16:19:21 -07:00
Dmitry Gozman bc23324878
chore: remove apiName plumbing and some unused methods from server side (#3481)
We append apiName where needed on the client instead.
2020-08-14 18:25:32 -07:00
Dmitry Gozman 9b52ca8676
chore: remove unused non-rpc code, test options, infra, bots (#3444) 2020-08-13 16:00:23 -07:00
Andrey Lushnikov ea5dfdbec7
fix: re-write Chromium startup error with clear instructions (#3070)
This patch detects Chromium crash with a sandboxing error and re-writes
the error to surface information nicely.

#### Error Before:

```sh
pwuser@23592d09b3bd:~/tmp$ node a.js
(node:324) UnhandledPromiseRejectionWarning: browserType.launch: Protocol error (Browser.getVersion): Target closed.
=========================== logs ===========================
[browser] <launching> /home/pwuser/.cache/ms-playwright/chromium-790602/chrome-linux/chrome --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disab
le-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=TranslateUI,BlinkGenPropertyTrees,ImprovedCookieControls,SameSiteByDefaultCookies --disable-hang-monitor --disab
le-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --user-data-dir=/tmp/playwrig
ht_chromiumdev_profile-mjSfr2 --remote-debugging-pipe --headless --hide-scrollbars --mute-audio --no-startup-window
[browser] <launched> pid=401
[browser] [0722/170825.030020:FATAL:zygote_host_impl_linux.cc(117)] No usable sandbox! Update your kernel or see https://chromium.googlesource.com/chromium/src/+/master/docs/linux/suid_sandbox_development.md for more information on developing with the SUID sandbox. If you want to live
dangerously and need an immediate workaround, you can try using --no-sandbox.
[browser] #0 0x55ac4f8c7be9 base::debug::CollectStackTrace()
[browser] #1 0x55ac4f841c13 base::debug::StackTrace::StackTrace()
[browser] #2 0x55ac4f853680 logging::LogMessage::~LogMessage()
[browser] #3 0x55ac4df2307e content::ZygoteHostImpl::Init()
[browser] #4 0x55ac4f40dd47 content::ContentMainRunnerImpl::Initialize()
[browser] #5 0x55ac4f45c9fa service_manager::Main()
[browser] #6 0x55ac4f40c361 content::ContentMain()
[browser] #7 0x55ac4f45b5bd headless::(anonymous namespace)::RunContentMain()
[browser] #8 0x55ac4f45b2bc headless::HeadlessShellMain()
[browser] #9 0x55ac4ccc22e7 ChromeMain
[browser] #10 0x7f0f3d736b97 __libc_start_main
[browser] #11 0x55ac4ccc212a _start
[browser]
[browser] Received signal 6
[browser] #0 0x55ac4f8c7be9 base::debug::CollectStackTrace()
[browser] #1 0x55ac4f841c13 base::debug::StackTrace::StackTrace()
[browser] #2 0x55ac4f8c7785 base::debug::(anonymous namespace)::StackDumpSignalHandler()
[browser] #3 0x7f0f437b3890 (/lib/x86_64-linux-gnu/libpthread-2.27.so+0x1288f)
[browser] #4 0x7f0f3d753e97 gsignal
[browser] #5 0x7f0f3d755801 abort
[browser] #6 0x55ac4f8c66e5 base::debug::BreakDebugger()
[browser] #7 0x55ac4f853aeb logging::LogMessage::~LogMessage()
[browser] #8 0x55ac4df2307e content::ZygoteHostImpl::Init()
[browser] #9 0x55ac4f40dd47 content::ContentMainRunnerImpl::Initialize()
[browser] #10 0x55ac4f45c9fa service_manager::Main()
[browser] #11 0x55ac4f40c361 content::ContentMain()
[browser] #12 0x55ac4f45b5bd headless::(anonymous namespace)::RunContentMain()
[browser] #13 0x55ac4f45b2bc headless::HeadlessShellMain()
[browser] #14 0x55ac4ccc22e7 ChromeMain
[browser] #15 0x7f0f3d736b97 __libc_start_main
[browser] #16 0x55ac4ccc212a _start
[browser]   r8: 0000000000000000  r9: 00007ffd38a863b0 r10: 0000000000000008 r11: 0000000000000246
[browser]  r12: 00007ffd38a87680 r13: 00007ffd38a86610 r14: 00007ffd38a87690 r15: aaaaaaaaaaaaaaaa
[browser]   di: 0000000000000002  si: 00007ffd38a863b0  bp: 00007ffd38a86600  bx: 00007ffd38a86e44
[browser]   dx: 0000000000000000  ax: 0000000000000000  cx: 00007f0f3d753e97  sp: 00007ffd38a863b0
[browser]   ip: 00007f0f3d753e97 efl: 0000000000000246 cgf: 002b000000000033 erf: 0000000000000000
[browser]  trp: 0000000000000000 msk: 0000000000000000 cr2: 0000000000000000
[browser] [end of stack trace]
[browser] Calling _exit(1). Core file will not be generated.
============================================================
Note: use DEBUG=pw:api environment variable and rerun to capture Playwright logs.Error
    at /home/pwuser/tmp/node_modules/playwright/lib/chromium/crConnection.js:131:63
    at new Promise (<anonymous>)
    at CRSession.send (/home/pwuser/tmp/node_modules/playwright/lib/chromium/crConnection.js:130:16)
    at CRSession.send (/home/pwuser/tmp/node_modules/playwright/lib/helper.js:78:31)
    at Function.connect (/home/pwuser/tmp/node_modules/playwright/lib/chromium/crBrowser.js:54:39)
    at Chromium._connectToTransport (/home/pwuser/tmp/node_modules/playwright/lib/server/chromium.js:52:38)
    at Chromium._innerLaunch (/home/pwuser/tmp/node_modules/playwright/lib/server/browserType.js:87:36)
    at async ProgressController.run (/home/pwuser/tmp/node_modules/playwright/lib/progress.js:75:28)
    at async Chromium.launch (/home/pwuser/tmp/node_modules/playwright/lib/server/browserType.js:60:25)
    at async /home/pwuser/tmp/a.js:4:19
(node:324) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise reject
ion, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:324) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
```


#### Error After:

```sh
pwuser@23592d09b3bd:~/tmp$ node a.js
(node:222) UnhandledPromiseRejectionWarning: browserType.launch: Chromium sandboxing failed!
================================
To workaround sandboxing issues, do either of the following:
  - (preferred): Configure environment to support sandboxing: https://github.com/microsoft/playwright/blob/master/docs/troubleshooting.md
  - (alternative): Launch Chromium without sandbox using 'chromiumSandbox: false' option
================================
Error
    at /home/pwuser/tmp/node_modules/playwright/lib/chromium/crConnection.js:131:63
    at new Promise (<anonymous>)
    at CRSession.send (/home/pwuser/tmp/node_modules/playwright/lib/chromium/crConnection.js:130:16)
    at CRSession.send (/home/pwuser/tmp/node_modules/playwright/lib/helper.js:78:31)
    at Function.connect (/home/pwuser/tmp/node_modules/playwright/lib/chromium/crBrowser.js:54:27)
    at Chromium._connectToTransport (/home/pwuser/tmp/node_modules/playwright/lib/server/chromium.js:53:38)
    at Chromium._innerLaunch (/home/pwuser/tmp/node_modules/playwright/lib/server/browserType.js:89:36)
    at async ProgressController.run (/home/pwuser/tmp/node_modules/playwright/lib/progress.js:75:28)
    at async Chromium.launch (/home/pwuser/tmp/node_modules/playwright/lib/server/browserType.js:61:25)
    at async /home/pwuser/tmp/a.js:4:19
(node:222) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise reject
ion, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:222) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
```

References #2745
2020-07-22 10:57:58 -07:00
Andrey Lushnikov 47e30f047b
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
2020-07-21 13:49:09 -07:00
Andrey Lushnikov af20d2704f
fix: auto-add --no-sandbox when running Chromium under root (#3064)
References #2745
2020-07-21 13:21:42 -07:00
Pavel Feldman bc3050776e
chore: prepare library types for rpc (#2706) 2020-06-25 08:30:56 -07:00
Pavel Feldman c220fc7f46
chore(logs): rework logs for simplicity (#2592) 2020-06-16 17:11:19 -07:00
Pavel Feldman 894826dec0
chore: form the debug script for authoring hints / helpers (#2551) 2020-06-11 18:18:33 -07:00
Pavel Feldman 17433d1881
chore: verify launch options (#2530) 2020-06-10 20:48:54 -07:00
Pavel Feldman 903de2582a
chore(websocket): extract common socket part (#2506) 2020-06-10 16:33:27 -07:00
Pavel Feldman 9aa9d6bc1d
feat(downloads): accept downloads in persistent, allow specifying the downloadsPath (#2503) 2020-06-08 21:45:35 -07:00
Pavel Feldman fb058ffe0d
feat(proxy): allow specifying proxy (#2485) 2020-06-05 13:50:15 -07:00
Dmitry Gozman 724d73c03b
feat(debug): chromium debugging port (#2246)
This exposes Chromium remote debugging pipe under the port PLAYWRIGHT_CHROMIUM_DEBUG_PORT.
2020-06-04 16:40:07 -07:00
Dmitry Gozman 8f0f32b5e6
chore: move debug-related code to src/debug (#2309) 2020-05-26 14:08:32 -07:00
Dmitry Gozman 27d30fe162
chore: encapsulate more launching logic in BrowserType (#2339) 2020-05-22 16:06:00 -07:00
Dmitry Gozman 55d47fd48f
chore: unify launching server between browser types (#2338) 2020-05-22 07:03:42 -07:00
Dmitry Gozman 3aca21c13b
chore: simplify launch routine a bit more (#2336) 2020-05-21 19:16:13 -07:00
Dmitry Gozman aae3f1e75d
feat(default context): support selected options for default context (#2177) 2020-05-21 15:13:16 -07:00
Pavel Feldman 2ede4bce12
chore: further unify launching and connection (#2320) 2020-05-21 09:43:10 -07:00
Pavel Feldman f9b437a49e
chore: pull common functionality into the BrowserTypeBase (#2312) 2020-05-20 16:30:04 -07:00
Dmitry Gozman 48440f7ed7
test: unflake fixtures test (#2313)
Drive-by: ensure we call onkill before manually exiting the process.
2020-05-20 14:58:27 -07:00
Pavel Feldman e558f0516b
chore: print the launch error message to console (#2304) 2020-05-20 00:10:10 -07:00
Dmitry Gozman 7efc22c062
fix(chromium): websocket wrapper leaks child sessions (#2291)
When a parent session is detached, we do not always get Target.detachedFromTarget
for child sessions. This is especially true when the socket disconnects, leaving
all child sessions in the maps.

Flakily reproducible by browserType.connect multiclient tests.
2020-05-19 15:02:13 -07:00
Dmitry Gozman 481643409e
feat(debug): persist devtools preferences in Chromium (#2266)
We store devtools-preferences.json file in the downloaded browser directory.
2020-05-19 14:55:11 -07:00
Dmitry Gozman 82cab094e8
feat(logging): add logging to websocket transport (#2289) 2020-05-18 19:00:38 -07:00
Dmitry Gozman e8e761f77f
chore: use internal BrowserOptions to unify browsers (#2230) 2020-05-14 13:22:33 -07:00
Yury Semikhatsky f10e8c4d47
chore(chromium): nicer error when running as root without --no-sandbox (#2214) 2020-05-12 16:43:15 -07:00
Dmitry Gozman a2bee2ca73
fix(launch): handle timeout and exceptions during launch (#2185) 2020-05-11 15:00:13 -07:00
Dmitry Gozman 8c083486a0
fix(launch): handle websocket connect exceptions (#2184) 2020-05-11 13:49:57 -07:00
Dmitry Gozman ae8d97cdf9
feat(persistent context): ensure initial about:blank (#2161)
We declare only the initial about:blank to be a supported usecase, so that
we can support options for the default context in the future.
2020-05-10 15:23:53 -07:00
Pavel Feldman 710c156d48
fix(chromium): disable same site by default and improved controls (#2097) 2020-05-04 13:43:44 -07:00
Pavel Feldman 2cdf297245
chore: remove uncompiled download-browser (#2018) 2020-04-28 17:06:01 -07:00
Pavel Feldman 2fcc2b5552
chore(chromium): resize browser frame when emulating viewport (#1924) 2020-04-23 10:38:58 -07:00
Pavel Feldman 5b085fdf03
feat(logger): introduce context-level logger (#1896) 2020-04-20 23:24:53 -07:00
Pavel Feldman 1f43ae692f
feat(logging): introduce logger sink api (#1861) 2020-04-20 07:52:26 -07:00
Yury Semikhatsky c359116a3b
fix: create _defaultContext only in persistent mode (#1854) 2020-04-18 19:58:11 -07:00
Pavel Feldman 022bc67c07
chore(chromium): allow passing --remote-debugging-port for debugging (#1857) 2020-04-18 19:06:42 -07:00
Andrey Lushnikov e15fc08d46
chore: migrate node types to 10.17.17 (#1690) 2020-04-07 07:40:57 -07:00
Pavel Feldman 75571e8eb8
feat(downloads): support downloads on cr and wk (#1632) 2020-04-02 17:56:14 -07:00
Joel Einbinder 3d6d9db44a
fix: wait for the process to close when closing the browser (#1629) 2020-04-02 16:57:12 -07:00
Pavel Feldman e241c1bef8
chore: remove web mode (#1625) 2020-04-01 14:42:47 -07:00
Joel Einbinder 6053784188
feat: add missing slowMo to launchPersistentContext (#1597)
`slowMo` was missing in `launchPersistentContext`, and I refactored the types a bit.
2020-03-31 16:34:59 -07:00
Andrey Lushnikov 950d427927
fix: catch websocket error events (#1595) 2020-03-30 18:18:38 -07:00
Pavel Feldman 1f08b72a27
test: add web socket leak test coverage (#1586) 2020-03-30 13:49:52 -07:00
Pavel Feldman 5499b1844d
feat(websocket): wrap firefox web socket too (#1580) 2020-03-28 10:14:59 -07:00
Pavel Feldman 48516ed7ed
feat(websocket): use proxy web socket on chromium (#1573) 2020-03-27 15:18:34 -07:00