Commit Graph

262 Commits

Author SHA1 Message Date
Jack Franklin
20c22ad9ad
chore: fix installing from GitHub URL (#5669)
The change to the install script to require TypeScript works fine when
installing from npm (because on npm the `lib` directory with the
compiled code already exists) but doesn't if you install from a GitHub
URL. By default it seems npm uses the `files` list when you install from
GitHub which means it's missing a bunch of files that we need to
compile.

Additionally by default when installing from a GitHub URL npm doesn't
install the dependencies which is an issue for us when we need to
compile TypeScript.

The fix is to create a `prepare` script that runs TypeScript if
required. From the npm docs [1]:

> `prepare`: Run both BEFORE the package is packed and published, on
> local npm install without any arguments, and when installing git
> dependencies

And from the npm docs on install [2], it confirms that if a package has
a `prepare` script it is run when installing from GitHub:

> As with regular git dependencies, dependencies and devDependencies
> will be installed if the package has a prepare script, before the
> package is done installing.

Despite having the `prepare` script we still need the TypeScript check
in `install.js` to satisfy the 3rd scenario below where we need to force
a compile:

* If I'm a user installing `puppeteer@X` from npm, the module is
published with the `lib/` directory of compiled code, so I'm set.
* If I'm a user installing Puppeteer from GitHub, the `prepare` script
will run TypeScript for me so I'm set.
* If I'm a developer working on Puppeteer, the `prepare` script also
runs but _after_ `npm install` which means `install.js` fails as it
requires `./lib/helper.js`. So in `install.js` we call
`compileTypeScriptIfRequired` to catch this case.

[1]: https://docs.npmjs.com/misc/scripts
[2]: https://docs.npmjs.com/cli/install

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

Fixes #5660.
2020-04-17 11:29:40 +02:00
Mathias Bynens
80348dc574
chore: bump version to v3.0.0-post (#5649) 2020-04-16 11:23:26 +02:00
Changhao Han
6760b9225e
chore: mark version v3.0.0 (#5642)
Co-authored-by: Mathias Bynens <mathias@qiwi.be>
2020-04-16 10:43:12 +02:00
Changhao Han
3387aab37f feat(chromium): roll Chromium to r737027 (#5644)
This corresponds to Chromium 81.0.4044.0.

This roll includes:

- [DevTools] Add Cookie Priority support to CDP
  https://chromium-review.googlesource.com/c/chromium/src/+/1959029
- Reject cookies with empty names and values
  https://chromium-review.googlesource.com/c/chromium/src/+/1982549
2020-04-16 09:54:00 +02:00
Jack Franklin
df8125056a
chore: update ws library (#5638)
Updates `ws` and `@types/ws` to version 7.

The breaking changes in version 7 are not ones that impact this project
[1].

[1]: https://github.com/websockets/ws/releases/tag/7.0.0
2020-04-14 15:13:38 +01:00
Jack Franklin
2529ee6508
chore(eslint): add eslint typescript linting (#5635)
This commit adds linting for `*.ts` files and loads up the recommended
list of TS rules from the ESLint TypeScript plugin. We can adjust the
exact rules overtime, but starting with the recommended list seems
sensible.
2020-04-14 12:08:52 +01:00
Tim van der Lippe
1ce4fe7169
chore(deps): update extract-zip to version 2 (#5610)
extract-zip removed support for callbacks and instead uses promises. Moreover, it has TypeScript support which allows us to remove the @types/extract-zip package.

This update allows downstream users to remove their installation of mkdirp, which uses a vulnerable version of minimist.

For more info, see https://github.com/maxogden/extract-zip/releases/tag/v2.0.0

Co-authored-by: Mathias Bynens <mathias@qiwi.be>
2020-04-09 21:13:25 +02:00
Jack Franklin
0bcc5a7ad8
chore: migrate remaining tests to Mocha (#5616)
This commit updates all the non-Puppeteer unit tests to run using Mocha and then deletes the custom test runner framework from this repository. The documentation has also been updated.
2020-04-09 20:12:32 +02:00
Jack Franklin
17cd8703f9
chore: migrate unit tests to Mocha (#5600)
Rather than maintain our own test runner we should instead lean on the community and use Mocha which is very popular and also our test runner of choice in DevTools too.

Note that this commit doesn't remove the TestRunner source as it's still used for other unit tests, but they will be updated in a future PR and then we can remove the TestRunner.

The main bulk of this PR is updating the tests as the old TestRunner passed in contextual data via the `it` function callback whereas Mocha does not, so we introduce some helpers for the tests to make it easier.
2020-04-09 07:56:25 +02:00
Jack Franklin
88446df724
chore: fix missed src/ vs lib/ documentation (#5591)
Co-authored-by: Mathias Bynens <mathias@qiwi.be>
2020-04-06 10:32:42 +02:00
Jack Franklin
6522e4f524
chore: Use expect for assertions (#5581)
Rather than use our own custom expect library, we can use expect from npm [1], which has an API almost identical to the one Puppeteer has, but with more options, better diffing, and is used by many in the community as it's the default assertions library that comes with Jest.

It's also thoroughly documented [2].

[1]: https://www.npmjs.com/package/expect
[2]: https://jestjs.io/docs/en/expect
2020-04-03 13:22:55 +02:00
Jack Franklin
7a2a41f208
chore: move code to src/ and emit with TypeScript (#5568)
This updates our `tsconfig.json` so it emits our JavaScript files as
well as type checking them. We compile into `./lib` which we then ship
in our npm package. The source code has moved from `./lib` into `./src`.

Because the `src/` directory is exclusively JS files, this change is a
no-op in terms of code functionality but is the first step towards being
able to replace `src/X.js` with `src/X.ts` in a way that allows us to
migrate incrementally.

The `lib` directory is gitignored, and the `src` directory is
npmignored. On `npm publish` we will now run `npm run tsc` in order to
generate the outputted code.
2020-04-02 16:25:19 +02:00
Jack Franklin
d678013368
chore: upgrade TypeScript to 3.8 (#5566)
Easy upgrade this one! No changes that affect us so this change simply bumps TS in `package.json`.
2020-04-01 11:34:50 +02:00
Christian Bromann
3dff24ad35
chore: upgrade eslint to v6.8.0 (#5563) 2020-03-31 18:43:06 +02:00
Jack Franklin
4b0fd8bc30
chore: upgrade to TypeScript 3.7 (#5562)
TypeScript seems to struggle to understand `Promise.all` when the items in the array return different types. If we were authoring in TS we could fix this with TS generics (`Promise.all<OurTypeHere>(...)`) but for now we can typecast the result. We'll fix this properly when we author in TS.
2020-03-31 18:42:32 +02:00
Jack Franklin
29b626aa94
chore: upgrade TypeScript to 3.6 (#5559)
Continues the work to get up to TS 3.8 (latest release at time of writing).

This version of TS introduced built in definitions for web workers that include an `interface Worker` so TS gets confused when it sees us reference a `Worker`. I have renamed the imports to `PuppeteerWorker` as I couldn't figure out a way to tell TS to not load in the worker types; longer term we might consider renaming `Worker` to `PuppeteerWorker` (or an alternative) but that would be a breaking change that we don't need right now.

The other fix is similar; TypeScript doesn't differentiate between the built-in `WebSocket` type and the `ws` library. Renaming the import solves this too.
2020-03-31 15:46:54 +02:00
Jack Franklin
5e8d79bf98
chore: upgrade to TypeScript 3.5 (#5556)
TS 3.5 got much stricter on writing changes to objects with varied types [1] so we have to do a bit of typecasting work to convince TS about the types of keys and values that we are setting.

Longer term we should think about a better data structure that avoids us having to jump through some hoops but for now I think this is a reasonable step to get us onto 3.5.

Same story regarding bindings on `window`: the easiest fix is to cast `window` to `any` for the code that adds to it. I'm sure we can come up with a more type-safe way of doing this in the future.

[1]: https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#fixes-to-unsound-writes-to-indexed-access-types
2020-03-31 10:48:09 +02:00
Andrey Lushnikov
b9240b1664
chore: bump rimraf to v3.0.2 (#5431)
`rimraf` version 3.0.2 doesn't throw any more when used
in Jest environment.

Fixes #5425
2020-03-12 22:17:47 +01:00
Maja Frydrychowicz
33f1967072
(feat) Add option to fetch Firefox Nightly (#5467)
* (feat) Add option to fetch Firefox Nightly

Add Firefox support to BrowserFetcher and the install script.
By default, the latest Firefox Nightly is downloaded
directly from archive.mozilla.org (dmg, tar.bz2 and zip)

This also required changes that impact `puppeteer.launch()`
and `puppeteer.executablePath()`

Fixes #5151

* Update docs/api.md

Co-Authored-By: Mathias Bynens <mathias@qiwi.be>

* Clean up revision promise

* Improve error handling in revision check

* Remove matchAll

* Use explicit octal mode

* Update .gitignore

Co-authored-by: Mathias Bynens <mathias@qiwi.be>
2020-03-10 21:59:03 +01:00
Changhao Han
807fbbdc20
chore: drop Node.js v8 support (#5365)
* chore: update relevant Node.js versions from 8 to 10

* chore: remove node6 and node8 folders from puppeteer-firefox ci

* fix: loosen definition for proc.stdio

* fix: update typescript version used in npm run test-types
2020-03-10 21:55:32 +01:00
Maja Frydrychowicz
0b1a9ceee2
chore: Replace Juggler with Firefox Nightly in CI (#5395)
Fixes #5150.
2020-02-20 13:57:15 +01:00
Changhao Han
5ffcde2b7b
chore: bump version to v2.1.1.-post (#5390) 2020-02-06 16:28:15 +01:00
Changhao Han
46386eb866
chore: mark version v2.1.1 (#5388) 2020-02-05 14:36:04 +01:00
Mathias Bynens
b45f8e4703
chore: bump version to v2.1.0-post (#5349) 2020-01-27 16:00:07 +01:00
Mathias Bynens
a30cf05e3a chore: mark version v2.1.0 (#5347)
This changes the Chromium revision to r722234 (Chrome 80.0.3987.0),
since that's the most recent version in the Chromium 80 range for
which a download exists for all supported platforms.
2020-01-27 15:48:40 +01:00
Mathias Bynens
013a86cf28
feat(chromium): roll Chromium to r722269 (#5289)
This corresponds to Chromium 80.0.3987.0.

This roll includes:

- Implement support for the new ARIA `generic` role
  https://chromium-review.googlesource.com/c/chromium/src/+/1872305
- Expose button's children to accessibility tree
  https://chromium-review.googlesource.com/c/chromium/src/+/1845810
- Remove `Page.handleFileChooser` from CDP
  https://chromium-review.googlesource.com/c/chromium/src/+/1935410
2020-01-27 14:44:53 +01:00
Danny Guo
80b5c44d89 chore: upgrade https-proxy-agent (#5243)
https-proxy-agent requires agent-base, which currently monkey-patches the core `https` Node module, causing problems in unrelated code. The latest version of https-proxy-agent uses the latest version of agent-base which no longer does this monkey patching.
2019-12-11 15:40:22 +01:00
Mathias Bynens
6091a34a36
fix: prepare jsHandle.uploadFile for CDP Page.handleFileChooser removal (#5196)
* fix: prepare jsHandle.uploadFile for CDP Page.handleFileChooser removal

https://chromium-review.googlesource.com/c/chromium/src/+/1935410
removes Page.handleFileChooser from the CDP.

* fix: improve binary file support

UTF-8-decoding the input file could fail for binary files, and so we
now read the raw file buffer and base64-encode it. To base64-decode it
within the page context, we use the Fetch API in combination with a
data URL. This requires knowing the proper MIME type for the input
file, which we now figure out using the new mime-types dependency.
2019-12-03 09:18:18 +01:00
Mathias Bynens
eddb23b521
chore: update URLs (#5185) 2019-11-26 13:12:25 +01:00
Maja Frydrychowicz
c5a72e9887 feat(launcher): add option to run Puppeteer with different browsers (#5137)
* feat: Set which browser to launch via PUPPETEER_PRODUCT

This change introduces a PUPPETEER_PRODUCT environment
variable as a first step toward using Puppeteer with
many different browsers. Setting PUPPETEER_PRODUCT=firefox, for
example, enables Firefox-specific Launcher settings.

The state is also exposed as `puppeteer.product` in the API
to support adding other product-specific behaviour as needed.

The bulk of the change is a refactoring in Launcher
to decouple generic browser start-up from product-specific
configuration.

Respecting the puppeteer-core restriction for PUPPETEER_
environment variables, lazily instantiate the Launcher
based on a `product` Puppeteer.launch option, if available.

* test: Distinguish Juggler unit tests from Firefox

The funit script is renamed to fjunit (j for Juggler, which is
used only by the experimental puppeteer-firefox package.

In contrast, the funit script now refers to running Puppeteer
unit tests against the main puppeteer package with Firefox.
To do so with Firefox Nightly, run:

`BINARY=path/to/firefox npm run funit`

A number of changes in this patch make it easier to run
Puppeteer unit tests in Mozilla's CI.
2019-11-26 10:23:19 +01:00
Mathias Bynens
7032472af7 chore: bump version to v2.0.0-post 2019-10-24 17:38:39 +02:00
Mathias Bynens
aa246973b9
chore: mark version v2.0.0 (#5078) 2019-10-24 14:46:50 +02:00
Mathias Bynens
81d2600236 feat(chromium): roll Chromium to r705776 (#5058)
This corresponds to Chromium 79.0.3942.0.

This roll includes:

- Support CSS media feature emulation in CDP
  https://chromium-review.googlesource.com/c/chromium/src/+/1821608
- Implement timezone ID verification
  https://chromium-review.googlesource.com/c/chromium/src/+/1822557
- Allow aria-hidden objects into the browser-side ax tree
  https://chromium-review.googlesource.com/c/chromium/src/+/1760862
- Remove pre-BlinkGenPropertyTrees codepaths (affects screenshot clipping)
  https://chromium-review.googlesource.com/c/chromium/src/+/1752244
- Terminate some asynchronous waiting commands on cross-process navigation
  https://chromium-review.googlesource.com/c/chromium/src/+/1766001/21#message-a6a61261b97ffca6ecb180c0a2303b538f7a6476

Per upstream Chromium changes, `page.screenshot` now clips elements to the viewport. This matches the clipping behavior of elements in inner scrollers (i.e., document and overflow scroll clipping now work the same).
2019-10-23 11:41:44 +02:00
Mathias Bynens
11ff374ca3
chore: drop Node.js v6 support (#5045)
Node.js v6 was end-of-life'd in April, 2019, with AWS Lambda prohibiting updaets to the Node.js v6 runtime since June 30, 2019.

This makes it quite safe for us to remove the Node 6 support from the repository.
2019-10-16 17:00:20 +02:00
Alexander Kachkaev
5b34028e63 chore: bump https-proxy-agent to mitigate a security issue (#5016) 2019-10-10 11:43:06 +01:00
Mathias Bynens
387a532707 chore: bump version to v1.20.0-post (#4939) 2019-09-13 19:58:13 -07:00
Mathias Bynens
a5f03ce1c8 chore: mark version v1.20.0 (#4928) 2019-09-12 15:21:21 -07:00
Andrey Lushnikov
b6b29502eb
feat(chromium): roll Chromium to r686378 (#4841)
This roll includes:
- https://crrev.com/685152 - [DevTools] Do not debug worker shadow pages
- https://crrev.com/683391 - [CSP] Check inline script CSP in prepare-a-script
- https://chromium-review.googlesource.com/c/v8/v8/+/1707331 - Ignore returnByValue when serializing caught value in promise rejections.
2019-08-14 21:43:18 -07:00
Andrey Lushnikov
0e0a67916d
feat(chromium): roll Chromium to r682225 (#4844)
This roll includes:
- https://crrev.com/681997 - Turn on default SiteInstance by default.

The SiteInstance by default was breaking "devtools: true" option, so
there's a new feature we disable now by default.

This keeps pressuring us towards OOPIF support since that's an
inevitable future.
2019-08-14 15:25:55 -07:00
Andrey Lushnikov
2f205a4446
feat(chromium): roll Chromium to r681777 (#4771)
Just a healthy roll.
2019-07-30 13:20:10 -07:00
Andrey Lushnikov
7406b185d2
chore(testrunner): introduce tests for TestRunner (#4773)
This adds some basic tests for the test runner.
2019-07-30 13:19:12 -07:00
Andrey Lushnikov
62f5dc7375
chore: bump version to v1.19.0-post (#4745) 2019-07-22 22:34:10 -07:00
Andrey Lushnikov
af0d229044
chore: mark version v1.19.0 (#4744) 2019-07-22 22:02:45 -07:00
Andrey Lushnikov
8e0c2fad39
feat(chromium): roll Chromium to r674921 (#4678)
Just a healthy roll.
2019-07-08 07:29:21 +02:00
Andrey Lushnikov
9ef4153f6e
feat(chromium): roll Chromium to r673587 (#4646)
This roll includes:
- https://crrev.com/673121 - DevTools: intercept file chooser requests

References #2946
2019-07-01 11:01:45 +02:00
Andrey Lushnikov
4ccd52c309
chore: bump version to v1.18.1-post (#4630) 2019-06-26 10:57:38 -07:00
Andrey Lushnikov
a2cf81dd78
chore: mark version v1.18.1 (#4628) 2019-06-26 10:40:38 -07:00
Andrey Lushnikov
cf34583be5
feat(chromium): roll Chromium to r672088 (#4626)
This roll includes:
- https://crrev.com/671499 - Build with symbol_level=0 for linux-archive-rel

Fix #4610
2019-06-26 01:18:01 -07:00
Andrey Lushnikov
411347cd7b
chore: bump version to v1.18.0-post (#4608) 2019-06-20 18:46:36 -04:00
Andrey Lushnikov
c96454d42c
chore: mark version v1.18.0 (#4606) 2019-06-20 18:13:45 -04:00