Commit Graph

54 Commits

Author SHA1 Message Date
Alex Rudenko
0636513e34
fix: make more files work in strict-mode TypeScript (#7936) 2022-01-28 09:38:36 +00:00
Connor Clark
9f9b4ed72a
fix: clearer jsdoc for behavior of headless when devtools is true (#7748)
The existing comment suggests that only the default changes–however, even if you set `devtools: false` and `headless: true`, Puppeteer will still open with headful.
2021-11-16 21:31:24 +01:00
Henrik Skupin
fc94a28778
fix: try to remove the temporary user data directory after the process has been killed (#7761) 2021-11-15 11:52:09 +00:00
Henrik Skupin
51e61696c1
fix: only kill the process when there is no browser instance available (#7762)
When the browser has been started and we have a valid reference lets make use of it instead of force-killing the process. A force kill should probably be the last resort in cleaning up the process.

This will help with Firefox as described on #7668 (comment).
2021-11-11 09:19:23 +01:00
Henrik Skupin
790c7a0eb9
feat: support for custom user data (profile) directory for Firefox (#7684)
When using a custom Firefox profile for Puppeteer the modified
preferences as present in prefs.js need to be reset once the
profile is no longer needed by Puppeteer. If not done this could
cause side-effects when the profile is used next time outside
of Puppeteer.

As ride-along fix the "--foreground" argument for Firefox will
only be used on MacOS because that's the only supported platform.
2021-11-10 13:31:15 +01:00
Christopher Patty
b8806d5625
Adds default flag to export tagged PDFs in anticipation of Chrome 81 (#5337)
Co-authored-by: Jan Scheffler <janscheffler@chromium.org>
2021-10-12 14:07:18 +00:00
Henrik Skupin
5c592913a8
chore: ignore stdout when dumpio isn't used (#7644)
When the browser child process has logging enabled
and output on stdout isn't constantly processed,
the brower process is about to freeze.

To avoid such a situation at least the stdout
pipe shouldn't be set by default but only if
dumpio is enabled.

Co-authored-by: Jan Scheffler <janscheffler@chromium.org>
2021-10-07 21:43:57 +00:00
Henrik Skupin
e7f82626ca
chore: disable certain Fission features for Firefox (#7610) 2021-10-07 12:13:54 +02:00
Nadhir
eebf452d38
fix: add support for relative install paths to BrowserFetcher (#7613)
This patch fixes the BrowserFetcher._getFolderPath method so that it supports relative download paths using PUPPETEER_DOWNLOAD_PATH or npm config

Issues: #7592
2021-09-29 14:21:38 +00:00
Tan Li Hau
26145e9a24
feat: add custom debugging port option (#4993) 2021-09-29 16:05:18 +02:00
Jan Scheffler
113489d3b5
fix(launcher): launcher.launch() should pass 'timeout' option #5180 (#7596)
Co-authored-by: Bob Jamison <bob.jamison@pearson.com>
2021-09-27 10:01:35 +02:00
Kiko Beats
b1f6e8692b
feat: allow to customize tmpdir (#7243) 2021-09-23 09:26:00 +02:00
Ben Elliott
9399c9786f
fix(install): respect environment proxy config when downloading Firef… (#6577)
Issues: #6573
2021-09-15 19:41:03 +00:00
headlesstesting
6a2bf0aaba
feat: add User-Agent with Puppeteer version to WebSocket request (#5614)
This will add the User-Agent header to WebSocket requests.
2021-09-15 07:40:43 +00:00
Mathias Bynens
686030fe0d
chore: remove references to upstream master branches (#7412)
Chromium had its branch renamed to `main`, and for other projects we can just point to the `HEAD`.
2021-09-14 15:02:39 +00:00
Voltrex
57d1bd4240
refactor(node): apply optimizations (#7557)
Replaced unnecessary template strings and used less calls for optimization.
2021-09-13 09:14:23 +00:00
pyoor
2aec35553b
fix: update firefox prefs documentation link (#7539) 2021-09-10 18:59:43 +00:00
Theodore Messinezis
5735f31d78
chore: enable followRedirects for NodeWebSocket (#7555) 2021-09-10 20:34:25 +02:00
Andres Rondon
5eb20e29a2
fix(browser-runner): reject promise on error (#7338)
This patch adds a reject callback to the _processClosing promise and executes it if it catches an error on removeFolderAsync(...).

Co-authored-by: Mathias Bynens <mathias@qiwi.be>
2021-07-30 09:32:53 +02:00
TASNEEM KOUSHAR
c65b10c524
chore: remove more ts-doc warnings (#7422) 2021-07-19 10:39:40 +01:00
Yusuke Iwaki
d70f60e061
feat: add channel parameter for puppeteer.launch (#7389)
This change adds a new `channel` parameter to `puppeteer.launch`. When specified, Puppeteer will search for the locally installed release channel of Google Chrome and use it to launch. Available values are `chrome`, `chrome-beta`, `chrome-canary`, `chrome-dev`. This parameter is mutually exclusive with `executablePath`.
2021-07-09 12:43:42 +00:00
Julian Descottes
bba3f41286
chore: synchronize Bug 1710839: update comment about firefox preference remote.enabled (#7324) 2021-06-14 10:41:25 +02:00
TASNEEM KOUSHAR
159d283545
fix: modified comment for method product, platform and newPage (#7262) 2021-05-24 14:14:51 +01:00
Jack Franklin
3204f2780f
chore: fix eslint warnings around type defs (#7230)
This PR updates some code to remove constant ESLint warnings. It also
upgrades those warnings to errors - so that they have to be resolved
as part of the PR, rather than landing as a warning and causing noise.

Fixes #7229.
2021-05-12 17:43:05 +01:00
Jack Franklin
523aa0aafa
chore: upgrade and pin prettier dependencies (#7232)
We're seeing odd failures with Prettier on some CI branches; my hunch is that they are installing different versions of the package and therefore getting formatting conflicts. This PR updates them all and pins them to specific versions - something we should probably consider generally, or remove our `package-lock.json` from the gitignore.
2021-05-12 16:48:30 +02:00
Peng-Yu Chen
2605309f74
feat(launcher): add new launcher option waitForInitialPage (#7105)
The existing behavior is expected to be unchanged as the value defaults to true.
Adding such option would allow user to skip the initial wait.

Issue: #3630
2021-05-06 20:30:04 +00:00
Mathias Bynens
cf8c08d991 chore: fix lint issues 2021-04-19 13:17:20 +02:00
Marvin Hagemeister
c239d9edc7
feat(launcher): fix installation error on Apple M1 chips (#7099)
* feat(launcher): fix installation error on Apple M1 chips

The previous logic assumed that an arm64 arch is only available in Linux. WIth Apple's arm64 M1 Chip this assumption isn't true anymore.

Currently there are no official macOS arm64 chromium builds available, but we can make use of the excellent Rosetta feature in macOS which allows us to run x86 binaries on M1.

Once native macOS arm64 Chromium builds are available we should switch to those.

Issue: #6622
Co-authored-by: Mathias Bynens <mathias@qiwi.be>
2021-04-19 09:00:43 +02:00
Henrik Skupin
669f04a7a6
chore: enable unit tests for Firefox on Windows (#6895)
Co-authored-by: Jan Scheffler <janscheffler@chromium.org>
2021-03-05 09:00:56 +00:00
Jack Franklin
98c81458c2
fix: improve TS types for launching browsers (#6888)
This commit tidies up the quite confusing state of all the various types
required to launch a browser. As we saw when upgrading DevTools
(https://source.chromium.org/chromium/chromium/src/+/master:third_party/devtools-frontend/src/test/conductor/hooks.ts;l=77),
we had to define our launch options variable like so:

```ts
const opts: puppeteer.LaunchOptions & puppeteer.ChromeArgOptions & puppeteer.BrowserOptions = {
  ...
};
```

This commit fixes that by introducing `AllNodeLaunchOptions`, which is
defined as the intersection of all the above types.

Additionally, the types defined as `ChromeArgOptions` are actually used
for launching both Chrome and Firefox, so I have renamed them to
`BrowserArgOptions`, and therefore this change is breaking because
anyone using `ChromeArgOptions` in their types will need to switch.

BREAKING CHANGE: renamed type `ChromeArgOptions` to `BrowserLaunchArgumentOptions`
BREAKING CHANGE: renamed type `BrowserOptions` to `BrowserConnectOptions`
2021-02-16 09:39:31 +00:00
Jack Franklin
6c61874797
fix(launcher): output correct error message for browser (#6815)
* fix(launcher): output correct error message for browser

When running `npm run release` today I got this error logged:

```
Error: Could not find browser revision 848005. Run "PUPPETEER_PRODUCT=firefox npm install" or "PUPPETEER_PRODUCT=firefox yarn install" to download a supported Firefox browser binary.
    at ChromeLauncher.launch (/Users/jacktfranklin/src/puppeteer/lib/cjs/puppeteer/node/Launcher.js:80:27)
```

The error is only partially correct; I did have the browser revision
missing, but I needed the Chromium browser, not Firefox. It turns out
the logic in `Launcher.ts` didn't take this into account; it mistakenly
had been hardcoded to always log out the error as if the Firefox binary
was missing.

This PR updates the message depending on the browser:

Chrome error:
> Error: Could not find expected browser (chrome) locally. Run npm
> install or yarn install to download the correct Chromium revision
> (848005).

Firefox error:
> Error: Could not find expected browser (firefox) locally. Run
> "PUPPETEER_PRODUCT=firefox npm install" or "PUPPETEER_PRODUCT=firefox
> yarn install" to download a supported Firefox browser binary.

* Update src/node/Launcher.ts

Co-authored-by: Mathias Bynens <mathias@qiwi.be>

Co-authored-by: Mathias Bynens <mathias@qiwi.be>
2021-02-04 11:59:01 +00:00
Alex Smith
9a8479a52a feat: support fetching and launching on Apple M1
Issue: #6495, #6634, #6641, #6614
2021-01-08 10:36:11 +01:00
Henrik Skupin
a732e7ac8f
chore: disable experimental Firefox cookie feature sameSite=Lax by default (#6690) 2021-01-08 10:11:41 +01:00
Paul Irish
d901696e0d
fix(launcher): rename TranslateUI to Translate to match Chrome (#6692) 2020-12-23 08:59:26 +01:00
Henrik Skupin
6f73db8858
chore: force-disable Firefox Fission (Site Isolation mode) (#6642) 2020-12-02 09:56:26 +01:00
Dr
3bf5a55289
fix: update to https-proxy-agent@^5.0.0 to fix ERR_INVALID_PROTOCOL (#6555)
With `nodejs@15.0.1`, install puppeteer with `https_proxy` set causes an error like:

```
> puppeteer@5.4.1 install node_modules/puppeteer
> node install.js

ERROR: Failed to set up Chromium r809590! Set "PUPPETEER_SKIP_DOWNLOAD" env variable to skip download.
TypeError [ERR_INVALID_PROTOCOL]: Protocol "https:" not supported. Expected "http:"
    at new NodeError (node:internal/errors:258:15)
    at new ClientRequest (node:_http_client:155:11)
    at Object.request (node:https:313:10)
    at httpRequest (node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserFetcher.js:488:17)
    at downloadFile (node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserFetcher.js:357:21)
    at BrowserFetcher.download (node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserFetcher.js:239:19)
    at async downloadBrowser (node_modules/puppeteer/lib/cjs/puppeteer/node/install.js:48:5) {
  code: 'ERR_INVALID_PROTOCOL'
}
```

The related issue is at https://github.com/TooTallNate/node-agent-base/pull/47, from package `agent-base` under `https-proxy-agent`

And the version bump is for `Refactor to TypeScript` is here: https://github.com/TooTallNate/node-https-proxy-agent/compare/4.0.0...5.0.0
2020-11-26 12:42:18 +01:00
Jack Franklin
f63a123ece
chore(agnostification): agnostify web socket connections (#6520)
This PR updates the socket transport code to swap between a Node web
socket transport or a web one based on the `isNode` environment. It also
adds unit tests to the browser tests that show we can connect in a
browser.
2020-10-19 10:32:41 +01:00
Jack Franklin
e655bb6ca2
chore(agnostification): split up root Puppeteer class (#6504)
The `Puppeteer` class had two concerns:

* connect to an existing browser
* launch a new browser

The first of those concerns is needed in all environments, but the
second is only needed in Node.
https://github.com/puppeteer/puppeteer/pull/6484 landing enabled us to
pull the `Puppeteer` class apart into two:

1. `Puppeteer` which hosts the behaviour for connecting to existing
   browsers.
2. `PuppeteerNode`, which extends `Puppeteer` and also adds the ability
   to launch a new browser.

This is a non-breaking change, because Node users will still get an
instance of a class with all the methods they expect, but it'll be a
`PuppeteerNode` rather than `Puppeteer`. I don't expect this to cause
people any issues.

We also now have new files that are effectively the entry points for
Puppeteer:

* `node.ts`: the main entry point for Puppeteer on Node.
* `web.ts`: the main entry point for Puppeteer on the web.
* `node-puppeteer-core.ts`: for those using puppeteer-core (which only
  exists in Node, not on the web).
2020-10-13 16:19:26 +01:00
Ralf Vogler
f3086d7c97
fix(launcher): support relative userDataDir on headless Windows (#6506)
Launching headless with a relative `userDataDir` hangs on Windows. Fix by calling `path.resolve` (idempotent) to add an absolute path instead in `defaultArgs`.

Issues: #3453
2020-10-13 12:59:58 +02:00
Jack Franklin
4846b8723c
chore(agnostification): split up launcher class (#6484)
The `Launcher` class was serving two purposes:

1. Launch browsers
2. Connect to browsers

Number 1) only needs to be done in Node land, but 2) is agnostic; in a
browser version of Puppeteer we'll need the ability to connect over a
websocket to send commands back and forth.

As part of the agnostification work we needed to split the `Launcher` up
so that the connection part can be made agnostic. Additionally, I
removed dependencies on `https`, `http` and `URL` from Node, instead
leaning on fetch (via `node-fetch` if in Node land) and the browser
`URL` API (which was added to Node in Node 10).
2020-10-12 10:08:57 +01:00
Tim van der Lippe
1ed38af79a
chore(node): move install.ts into node/ (#6490)
This file contains logic that is unique to the Node.js environment and therefore should be moved into the `node` sub-folder.
2020-10-12 08:56:29 +02:00
Maja Frydrychowicz
41ef3eec90
fix: update preferences in default Firefox profile (#6465) 2020-10-05 07:17:21 +02:00
Maksim Sadym
17960e5d8d
feat(page): emulate idle state (#6410)
* https://bugs.chromium.org/p/chromium/issues/detail?id=1090802
* added `page.emulateIdleState(...)` allowing emulate or remove emulation of the idle state;
* added test `emulate idle` -> `remove emulation` -> `emulate idle` -> `remove emulation`;
* added launch argument `--enable-blink-features=IdleDetection` to turn IdleDetection on.
2020-09-14 11:31:23 +02:00
lcabral37
13ea347c7d
feat: support configuring the browser download path (#6014)
By adding support for an environment variable `PUPPETEER_DOWNLOAD_PATH` it is possible to support downloading the browser binaries into a folder outside the `node_modules` folder. This makes it possible to preserve previously downloaded binaries in order to skip downloading them again.
2020-08-10 10:37:31 +02:00
Maja Frydrychowicz
054d782c82
fix(Launcher): use wait-for-process Firefox option (#6315) 2020-08-10 10:23:17 +02:00
Christian Bromann
82645e85c7
docs: better describe how to install Firefox Nightly with Puppeteer (#6226)
Co-authored-by: Mathias Bynens <mathias@qiwi.be>
2020-07-16 14:28:09 +02:00
Jack Franklin
ffec2475d0
chore: enforce file extensions on imports (#6202)
* chore: enforce file extensions on imports

To make our output agnostic it should include file extensions in the
output, as per the ESM spec. It's a bit odd for Node packages but makes
it easier to publish a browser build.
2020-07-13 10:22:26 +01:00
Jack Franklin
29f7e161b1
chore(docs): reduce warnings when generating docs (#6138)
* chore(docs): reduce warnings when generating docs

This is a bunch of small miscellaneous fixes that reduce the amount of
warnings logged when generating our new docs. The long term goal is to
get this list down to 0 warnings, but I'll do it in multiple PRs.

* satisfy doclint
2020-07-02 12:15:39 +01:00
Jack Franklin
a4d12a2b21 chore: remove helper.promisify (#6100)
It was just re-exporting the built-in Node module so let's just import
from that directly.
2020-06-25 13:01:46 +02:00
Martin Splitt
73b97956cc
docs(new): add TSDoc comments to BrowserFetcher (#6078) 2020-06-24 09:33:19 +01:00