Commit Graph

576 Commits

Author SHA1 Message Date
dependabot[bot]
c8a95a12b1
chore(deps-dev): bump @microsoft/api-documenter from 7.13.8 to 7.13.58 (#7642)
Bumps [@microsoft/api-documenter](https://github.com/microsoft/rushstack) from 7.13.8 to 7.13.58.
- [Release notes](https://github.com/microsoft/rushstack/releases)
- [Commits](https://github.com/microsoft/rushstack/compare/@microsoft/api-documenter_v7.13.8...@microsoft/api-documenter_v7.13.58)

---
updated-dependencies:
- dependency-name: "@microsoft/api-documenter"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-10-07 08:51:14 +00:00
Philip Jägenstedt
30ac9d168d
chore: bump node-fetch from 2.6.1 to 2.6.5 (#7619)
This is the last release before 3.0.0.

This is a mitigation for the issue described in https://github.com/puppeteer/puppeteer/issues/7239#issuecomment-932044494.
2021-10-04 06:40:30 +00:00
Jan Scheffler
df36a618f7
chore: bump version to v10.4.0-post (#7588) 2021-09-22 07:22:32 +02:00
Jan Scheffler
5631d3aebc
chore(release): mark v10.4.0 (#7586) 2021-09-21 17:29:27 +02:00
Jan Scheffler
7316086941
feat: extend husky checks (#7574) 2021-09-20 07:10:53 +00:00
Remco Haszing
723052d5bb
feat(typescript): allow using puppeteer without dom lib (#6998)
The dom lib inserts all dom related types into the project, which is often
undesirable when working on a NodeJS project.

This change injects global stubs for the dom types required by puppeteer, so
puppeteer can work without users having to add dom types to their project.

Closes #6989
2021-09-11 20:59:51 +00:00
Jack Franklin
6fde41c6b6
fix(docs): deploy includes website documentation (#7469)
We now generate the docs into `website/docs` such that it's used by
Docusaurus when we build the site, we need to update the deploy script
to generate those docs first.
2021-08-05 10:01:25 +00:00
Maksim Sadym
939ac7f94b
chore: bump version to v10.2.0-post (#7468) 2021-08-04 17:30:25 +02:00
Maksim Sadym
c510df8d8e
chore(release): mark v10.2.0 (#7467) 2021-08-04 14:45:31 +02:00
Jan Scheffler
e10faad4f2
feat(chromium): roll to Chromium 93.0.4577.0 (r901912) (#7387) 2021-08-04 14:22:15 +02:00
TASNEEM KOUSHAR
c5a0d500e4
chore: add documentation to new website 2021-08-04 09:00:48 +00:00
Jack Franklin
39c1f08fd6
chore(docs): basic docusaurus setup (#7438) 2021-07-26 11:52:25 +00:00
TASNEEM KOUSHAR
ea3df80ed1
fix: add script to remove html comments from docs markdown (#7394) 2021-07-06 10:55:42 +01:00
Jan Scheffler
558b35567c
chore: bump version to v10.1.0-post (#7386) 2021-06-29 07:44:38 +00:00
Jan Scheffler
6b13a17ed9
chore(release): mark v10.1.0 (#7331) 2021-06-29 09:26:24 +02:00
Jack Franklin
c07e6d4fa9
chore(docs): ensure old docs are removed when generating (#7308)
I lost time today due to some old docs files lingering for code that is now gone. To avoid that happening, let's remove the directories before generating.

As part of this work I also changed the API Extractor to not output to `temp/X.api.json` and instead `docs-api-json/X.api.json` to make it clearer what that folder is for.
2021-06-10 08:30:40 +00:00
Jan Scheffler
f2ab11c640
chore: bump version to v10.0.0-post (#7302) 2021-05-31 16:07:51 +02:00
Jan Scheffler
9df7b71e3b
chore(release): mark v10.0.0 (#7299) 2021-05-31 14:34:04 +02:00
Rodrigo Bermúdez Schettino
1854192abb
chore: update ws dependency to a non-vulnerable version (#7296)
Issue: https://github.com/advisories/GHSA-6fc8-4gx4-v693
2021-05-31 11:24:48 +02:00
Jan Scheffler
f863f4bfe0
feat(chromium): roll to Chromium 92.0.4512.0 (r884014) (#7288) 2021-05-26 16:44:29 +00:00
Jack Franklin
4796382f01
chore: enforce pinned dependencies (#7238)
* chore: enforce pinned dependencies

Because we don't check our `package-lock.json` in, we can end up with
different versions installed locally vs CI, or even two devs having
different versions. Let's pin and enforce we pin every version to
avoid this.
2021-05-14 12:02:36 +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
Mathias Bynens
d9ace6c664
chore: disable markdownlint for api.md (#7228)
api.md is autogenerated anyhow, and this avoids the recent CI failures.

Issue: #7227
2021-05-12 14:47:27 +02:00
Jan Scheffler
476e9259fe
chore: bump version to v9.1.1-post (#7206) 2021-05-05 09:57:19 +00:00
Jan Scheffler
d615dd3d2c
chore(release): mark v9.1.1 (#7205) 2021-05-05 10:38:53 +02:00
Jan Scheffler
8816645c71
chore: bump version to v9.1.0-post (#7202) 2021-05-03 12:40:47 +00:00
Jan Scheffler
1d473bc79f
chore(release): mark v9.1.0 (#7201) 2021-05-03 14:08:44 +02:00
Jan Scheffler
ad6b736039
fix: change rm -rf to rimraf (#7168)
Currently, `npm clean-lib` fails on windows with `cmd` because it does not now about `rm`.
This change uses the already installed `rimraf` to do the job instead.
2021-04-27 10:32:15 +02:00
Maksim Sadym
0fa0a34802
chore: bump version to v9.0.0-post (#7112) 2021-04-21 11:43:49 +00:00
Maksim Sadym
5872e7178a
chore(release): mark v9.0.0 (#7111) 2021-04-21 11:18:09 +00:00
Maksim Sadym
715e7a8d62
feat(chromium): roll to Chromium 91.0.4469.0 (r869685) (#7110)
* Roll to Chromium 91.0.4469.0 (r869685).
* Update CONTRIBUTING.md.
2021-04-21 10:43:08 +00:00
David Barton
c62b02f177
chore: automate prettier in docs (#7014)
Issue: #7012
Co-authored-by: Mathias Bynens <mathias@qiwi.be>
2021-03-23 10:02:34 +01: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
Alex Rudenko
0c26301bee
chore: bump version to v8.0.0-post (#6929) 2021-02-26 08:51:52 +00:00
Alex Rudenko
0b5969dea9
chore(release): mark v8.0.0 (#6928) 2021-02-26 08:32:27 +00:00
Alex Rudenko
0c688bd75e
feat(chromium): roll Chromium to r856583 (#6927)
* feat(chromium): roll Chromium to r856583

This corresponds to Chromium 90.0.4427.0

This roll includes:
- Add sourceScheme, sourcePort, and sameParty to DevTools backend (https://crbug.com/1170548, https://crbug.com/1142606)
2021-02-26 09:12:43 +01:00
Jack Franklin
8adf5b467d
chore: upgrade TypeScript to 4.1.5 (#6889)
We were blocked on doing this because API Extractor didn't support it,
but now it does, so we can bump TS and the API tooling in one go. None
of the breaking changes in TS4 cause us any issues.
2021-02-16 10:43:32 +00:00
Jack Franklin
29c059427e
chore: bump to 7.1.0-post (#6880) 2021-02-12 11:19:06 +00:00
Jack Franklin
a681aac7e3
chore(release): mark v7.1.0 (#6879) 2021-02-12 10:51:43 +00:00
Jack Franklin
0889b7eb66
chore: upgrade @web/test-runner and increase timeout (#6870)
We've seen the odd timeout on the bots; increasing this in the hope that
it helps stop the flakes.
2021-02-11 12:38:22 +01:00
Jack Franklin
6a0eb7841f
fix: wider compat TS types and CI checks to ensure correct type defs (#6855)
* fix: wider compat TS types and CI checks to ensure correct type defs

This PR improves our TS types further to make sure they are usable in a
TS environment where ES Modules are the target output. Our use of
`export =` is problematic this environment as TypeScript does not allow
`export =` to be used and it errors.

The fix for the type issues to avoid `export =` is to instead define the
functions that you gain access to when you import Puppeteer as top level
functions in our `types.d.ts` file. We can do this by declaring them
explicitly in `src/node.ts`. These are then rolled into `lib/types.d.ts`
at build time. The downside to this is that we have to keep those
declarations in sync with the Puppeteer API; should we add a new method
to the `Puppeteer` class, we must add it to the `nodes.ts` declarations.
However, this could easily be automated by a small script that walks the
AST and generates these. I will do that in a follow-up PR, but I
consider this low risk given how rarely the very top level API of
Puppeteer changes. The nice thing about this approach is we no longer
need our script that hacks on changes to `lib/types.d.ts`.

To avoid yet more releases to fix issues in one particular TS
environment, this PR also includes a suite of example setups that we
test on each CI run. Each sample folder contains `good.ts`, which should
have no TS errors, and `bad.ts`, which should have some errors. The test
first packs Puppeteer into a tar, and then installs it from that tar
into each project. This should replicate how the published package
behaves when it is installed. We then check that we get no errors on
`good.ts`, and the expected errors on `bad.ts`.

We have a variety of test projects that cover both TS and JS source
code, and CJS and ESM imports and outputs.
2021-02-10 12:04:36 +00:00
Jack Franklin
e16741dee2
chore: mark version 7.0.4-post (#6851) 2021-02-09 14:10:28 +00:00
Jack Franklin
db2b4898e1
chore(release): mark v7.0.4 (#6850) 2021-02-09 13:24:44 +01:00
Jack Franklin
fd857474cc
chore: fix doclint violations (#6849) 2021-02-09 11:52:35 +00:00
Jack Franklin
f718b14b64
fix: make publish bot run full build, not just tsc (#6848)
`npm run tsc` is not enough to do a full build now we also include the
`types.d.ts` file, so we need to run `build.`
2021-02-09 11:34:21 +00:00
Jack Franklin
de904db51d
chore: bump version to 7.0.3-post (#6846) 2021-02-09 09:56:17 +01:00
Jack Franklin
27eaf607ce
chore(release): mark v7.0.3 (#6845) 2021-02-09 09:49:44 +01:00
Jack Franklin
a1d4d7f854
chore: bump version to 7.0.2-post (#6843)
Co-authored-by: Mathias Bynens <mathias@qiwi.be>
2021-02-09 09:44:52 +01:00
Jack Franklin
e34f317b37
fix: include lib/types.d.ts in files list (#6844)
Else it's missed when npm publish happens. Didn't pick this up in my testing because a previous PR that changed this hadn't landed at the time of testing so the bug was missed.
2021-02-09 09:44:23 +01:00
Jack Franklin
ff50c86332
chore(release): mark v7.0.2 (#6842) 2021-02-09 08:17:15 +00:00
Jack Franklin
f1b46ab5fa
fix: much better TypeScript definitions (#6837)
This PR aims to vastly improve our TS types and how we ship them.

Our previous attempt at shipping TypeScript was unfortunately flawed for
many reasons when compared to the @types/puppeteer package:

* It only worked if you needed the default export. If you wanted to
  import a type that Puppeteer uses, you'd have to do `import type X
  from 'puppeteer/lib/...'`. This is not something we want to encourage
  because that means our internal file structure becomes almost public
  API.
* It gave absolutely no help to CommonJS users in JS files because it
  would warn people they needed to do `const pptr =
  require('puppeteer').default, which is not correct.
* I found a bug in the `evaluate` types which mean't you couldn't
  override the types to provide more info, and TS would insist the types
  were all `unknown`.

The goal of this PR is to support:

1. In a `ts` file, `import puppeteer from 'puppeteer'`
1. In a `ts` file, `import type {ElementHandle} from 'puppeteer'`
1. In a `ts` file, referencing a type as `puppeteer.ElementHandle`
1. In a `ts` file, you can get good type inference when running
   `foo.evaluate(x => x.clientHeight)`.
1. In a `js` file using CJS, you can do `const puppeteer =
   require('puppeteer')` and get good type help from VSCode.

To test this I created a new empty repository with two test files in,
one `.ts` file with this in:
https://gist.github.com/jackfranklin/22ba2f390f97c7312cd70025a2096fc8,
and a `js` file with this in:
https://gist.github.com/jackfranklin/06bed136fdb22419cb7a8a9a4d4ef32f.

These files included enough code to check that the types were behaving
as I expected.

The fix for our types was to make use of API Extractor, which we already
use for our docs, to "rollup" all the disparate type files that TS
generates into one large `types.d.ts` which contains all the various
types that we define, such as:

```ts
export declare class ElementHandle {...}

export type EvaluateFn ...
```

If we then update our `package.json` `types` field to point to that file
in `lib/types.d.ts`, this then allows a developer to write:

```
import type {ElementHandle} from 'puppeteer'
```

And get the correct type definitions. However, what the `types.d.ts`
file doesn't do out of the box is declare the default export, so
importing Puppeteer's default export to call a method such as `launch`
on it will get you an error.

That's where the `script/add-default-export-to-types.ts` comes in. It
appends the following to the auto-generated `types.d.ts` file:

```ts
declare const puppeteer: PuppeteerNode;
export = puppeteer;
```

This tells TypeScript what the default export is, and by using the
`export =` syntax, we make sure TS understands both in a TS ESM
environment and in a JS CJS environment.

Now the `build` step, which is run by GitHub Actions when we release,
will generate the `.d.ts` file and then extend it with the default
export code.

To ensure that I was generating a valid package, I created a new
repository locally with the two code samples linked in Gists above. I
then ran:

```
npm init -y
npm install --save-dev typescript
npx tsc --init
```

Which gives me a base to test from. In Puppeteer, I ran `npm pack`,
which packs the module into a tar that's almost identical to what would
be published, so I can be confident that the .d.ts files in there are
what would be published.

I then installed it:

```
npm install --save-dev ../../puppeteer/puppeteer-7.0.1-post.tgz
```

And then reloaded VSCode in my dummy project. By deliberately making
typos and hovering over the code, I could confirm that all the goals
listed above were met, and this seems like a vast improvement on our
types.
2021-02-09 08:00:42 +00:00
Jack Franklin
6fec36d8ba
chore: don’t ship tsbuildinfo files in npm package (#6809)
This PR updates our `files` list to be more specific; rather than include everything from `lib`, we include just `.js`, `.d.ts`, and their equivalent sourcemaps. This prevents noisy meta-files like `.tsbuildinfo` sneaking into the package, which are no use to anyone.
2021-02-08 16:21:41 +00:00
Arjen Korevaar
3b13012d1f
chore: update proxy-from-env (#6660) 2021-02-05 09:20:40 +01:00
Jack Franklin
c936b18651
chore: bump version to 7.0.1-post (#6814) 2021-02-04 10:32:11 +00:00
Jack Franklin
eb0d604bf3
chore(release): mark v7.0.1 (#6812) 2021-02-04 10:07:37 +00:00
Jack Franklin
a7e3c2e09e
fix(typescript): ship .d.ts file in npm package (#6811)
In all my excitement about shipping types, we forgot to export the
actual `d.ts` file that makes it all happen... :(

I didn't pick this up locally because I was testing with `npm link`,
which does a symbolic link and therefore doesn't mirror the list of
files that make it into the published package.

To test this change, I made the change and ran `npm pack` to generate a
tar. I then created a new empty directory and did `npm init -y` followed
by `npm install path/to/puppeteer-7.tgz`.

I then initialised TypeScript, and wrote this:

```js
import puppeteer from 'puppeteer';

async function run() {
  const browser = await puppeteer.launch()
  const page = await browser.newPage()
  await page.goto('https://foo.com')
}
run();
```

As I typed I got autocompletions and if I were to make an error, I'd get
a TypeScript error.

There is follow up work to be done because this unfortunately does not
work if you use `require` rather than ES Modules. @AviVahl suggested a
change in https://github.com/puppeteer/puppeteer/issues/6807 but I
cannot get it to work, so I'd like to do more investigation here. In the
mean time, whatever the contents of `cjs-entry.d.ts`, we should
definitely be exporting it as part of the module, so this PR is still
good to land.
2021-02-04 09:45:46 +00:00
Jan Scheffler
9abd459b2a
chore: bump version to v7.0.0-post (#6808) 2021-02-03 15:54:54 +00:00
Jan Scheffler
edd8bcc619
chore(release): mark v7.0.0 (#6804) 2021-02-03 16:33:32 +01:00
Maksim Sadym
890d5c2e57
feat(chromium): roll Chromium to r848005 (#6801)
This corresponds to Chromium 90.0.4403.0
This roll includes:
- Cut screenshot by ViewPort size, not position (crrev.com/c/2643792)

BREAKING CHANGE:
- `page.screenshot` cuts screenshot content by the ViewPort size, not ViewPort position.
2021-02-02 17:24:10 +01:00
Jan Scheffler
20526b57b8
chore: bump version to v6.0.0-post (#6802) 2021-02-02 11:22:53 +00:00
Jan Scheffler
ef4767080a
chore(release): mark v6.0.0 (#6800) 2021-02-02 12:00:09 +01:00
Maksim Sadym
8f9fbdbae6 feat(chromium): roll Chromium to r843427 (#6797)
This corresponds to Chromium 89.0.4389.0.

This roll includes:

- Add `SameParty` attribute to cookies
  https://crrev.com/c/2598846
- Anchor `target=_blank` implies `rel=noopener`
  https://crrev.com/c/1630010
- Don’t expect ignored elements in the AXTree
  https://crrev.com/c/2505362

BREAKING CHANGE: The built-in `aria/` selector query handler doesn’t return ignored elements anymore.

Issue: #6758
2021-02-02 08:40:56 +01:00
Mathias Bynens
53ce52e3b6
chore: automate release commits (#6628)
Issue: #6482
2020-11-30 10:29:38 +01:00
Peter Marshall
46e74ff3f5
test: use sourcemaps in unit tests (#6485)
Introduce the source-map-support package and require it for mocha running unit tests.

Turn on the sourceMap option for tsconfig.base.json so that the sourceMappingURL= line is emitted in the generated files.

Co-authored-by: Mathias Bynens <mathias@qiwi.be>
2020-11-26 14:51:17 +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
Mathias Bynens
470124fb2b
chore: automate version bumps (#6627)
Issue: #6482
2020-11-26 11:38:24 +01:00
Mathias Bynens
0473a2ae32
chore: bump version to v5.5.0-post (#6605) 2020-11-17 11:46:21 +01:00
Mathias Bynens
18143b3573
chore(release): mark v5.5.0 (#6604) 2020-11-16 14:38:50 +01:00
Yash Ladha
8690a77a2b
chore: remove redundant npm script for dependency-graph (#6583)
Remove the redundant rule for dependency graph as the `src/index.ts` is not required. This was introduced in 64c9c709, but the filestructure has changed from since then and it doesn't work as `src/index.ts` is replaced with `src/node.ts` and `src/web.ts` as per the use case.
2020-11-04 17:08:07 +01:00
Mathias Bynens
a0d8a27856
chore: automate versioning + changelog (#6556)
As long as we follow Conventional Commits for our commit messages (which is now enforced since #6483), we can automate the maintenance of this new changelog, which enables us to later automate the release process altogether.

This patch also eliminates the versioning decision-making process by automating it based on our commit messages.

Issue: #6482
2020-10-29 10:53:51 +01:00
Joel Einbinder
b549256952 feat(chromium): roll Chromium to r818858 (#6526)
This corresponds to Chromium 88.0.4298.0.

This roll includes:

- DevTools: Wait for a frame before sending touch and wheel events
  https://chromium-review.googlesource.com/c/chromium/src/+/2437695
2020-10-27 18:15:52 +01:00
Jack Franklin
d3d7cb92eb
chore: mark v5.4.1-post (#6553) 2020-10-27 16:07:36 +00:00
Jack Franklin
562c9c2723
chore: mark version 5.4.1 (#6552) 2020-10-27 15:05:43 +00:00
Johan Bay
d787865066
chore: bump version to v5.4.0-post (#6544) 2020-10-26 08:27:40 +01:00
Johan Bay
729cdfe98a
chore: mark version v5.4.0 (#6542) 2020-10-23 16:28:38 +02:00
Mathias Bynens
8e9970df67
chore: automate publishing on new Git tags (#6536)
Issues: #6482
2020-10-23 14:40:14 +02:00
Jack Franklin
e6b8c77d94
chore: fix travis config (#6537) 2020-10-22 15:37:28 +02:00
Jack Franklin
c2c2bb7e55
chore(agnostification): common/helper.ts (#6515)
* chore(agnostification): common/helper.ts

The `readProtocolStream` method uses `fs` only if you want to write to a
file. So we gate at the start of the function and ensure that if we got
given a path we are not in a Node environment.
2020-10-19 09:57:15 +01:00
Jack Franklin
637a1f7409
chore: gitignore new-docs (#6511)
They are generating a lot of noise in PRs. This commit removes them from git, but updates CI to generate them - to ensure there are no errors when generating the new documentation.

Further commits will:

1. Introduce linting to enforce methods are documented.
2. Generate previews of the new docs via GitHub actions or similar.
2020-10-14 11:44:40 +01:00
Jack Franklin
f04bec5a15
chore: update eslint & eslint plugins (#6487)
Updates ESLint, the TypeScript ESLint plugins, and updates code where
the rules have changed.
2020-10-12 10:30:35 +01: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
Jack Franklin
e94a1e87dc
chore: bump misc dependencies (#6488)
This commit updates some miscellaneous dependencies to their latest
versions (with no other changes required) and also removes the `browser`
section, which was used by Browserify for the now long gone
Puppeteer-Web package that we used to publish.
2020-10-08 16:02:37 +01:00
Mathias Bynens
936ccdca2c
chore: enforce Conventional Commits through commitlint (#6483)
This patch sets up commitlint to enforce the Conventional Commits format. This check runs with the other lint checks as part of npm run lint, and a Git commit hook is set up via Husky for automated local checks.

Issue: #6482
2020-10-08 12:04:15 +02:00
Johan Bay
49f25e2412
feat(chromium) roll Chromium to r809590 (#6458)
This corresponds to Chromium 87.0.4272.0
This roll includes:
- Reland "idle-detection: Implement requestPermission() method"
  (crrev.com/c/2417779)
2020-10-01 08:24:47 +02:00
Jack Franklin
caa9a1cafa
chore(agnostic): Remove use of util.promisify (#6446)
In `src/common` we now use `fs.promises.X` which we can dynamically
`import`. In a browser environment this code will never run because it's
gated on `isNode` (in a future PR we will add tree-shaking to the bundle
step such that this code is eliminated). By using `import`, we ensure
TypeScript still can track types and give good type information.

In `src/node` we continue to use `util.promisify` but that's not a
concern as that code explicitly is never run in the browser.
2020-09-28 10:35:35 +01:00
Jack Franklin
322cc96e7b
chore: remove npm run test-types call (#6447)
It was an old script that doesn't exist any more.
2020-09-25 12:44:34 +02:00
Maksim Sadym
1396c9d4cd
chore: bump version to v5.3.1-post (#6440) 2020-09-23 11:28:08 +02:00
Maksim Sadym
11ab402846
fix: add mime dependency back to fix build (#6441)
* Added back dependency `"mime": "^2.0.3",` to fix build;
* Previous builds passed because of the node package caching.
2020-09-23 09:56:40 +02:00
Maksim Sadym
c7d32cb92f
chore: mark version v5.3.1 (#6439) 2020-09-22 12:49:28 +02:00
Mathias Bynens
bb1c5215a8
chore: remove mime dependency (#6415)
Bug: #5026, #6125
2020-09-14 13:39:33 +02:00
Maksim Sadym
03e41da465
chore: bump version to v5.3.0-post (#6413) 2020-09-14 10:17:05 +02:00
Maksim Sadym
030fcaa075
chore: mark version v5.3.0 (#6412) 2020-09-11 10:43:09 +02:00
Maksim Sadym
4ce600a6f4
chore: Remove target debug-unit and add unit-debug (#6411)
* debug-unit is confusing
* unit-debug runs all tests in debug mode
2020-09-11 10:10:25 +02:00
Maksim Sadym
62ac167339
feat(chromium): roll Chromium to r800071 (#6407)
* roll Chromium to version 86, r800071
* roll Chrome DevTools protocol version to 0.0.799653
* fix HTTPRequest.continue after
  * CDP: accept post data in the binary form in Fetch.continueRequest.
    https://chromium-review.googlesource.com/c/chromium/src/+/2315239
* update new-docs
2020-09-09 21:23:46 +02:00
Jack Franklin
21552f8fe7
feat: page.waitForTimeout (#6268) 2020-07-28 10:37:49 +02:00
Lars den Bakker
15d1906e7c
feat: add web test runner (#6200) 2020-07-22 13:14:35 +02:00
Johan Bay
e3933ddd82
chore: mark 5.2.1-post (#6257) 2020-07-21 16:24:07 +01:00
Johan Bay
4ee4649de6
chore: mark v5.2.1 (#6254) 2020-07-21 14:53:02 +02:00
Johan Bay
e89e264a16
feat(chromium): roll Chromium to r782078 (#6250)
This corresponds to Chromium 85.0.4182.0.

This roll includes: 
- Enable SameSiteByDefaultCookies and CookiesWithoutSameSiteMustBeSecure
   https://crrev.com/c/2231445
- [FlexNG] Enable FlexNG by default
   https://crrev.com/c/2216595

Closes #6151.
2020-07-20 17:17:06 +02:00
Jack Franklin
042c4a23d7
chore: mark 5.2.0-post (#6240) 2020-07-17 14:48:14 +02:00
Jack Franklin
028f144256
chore: mark v5.2.0 (#6238) 2020-07-17 13:44:29 +02:00
Jack Franklin
f1a6b8d66d
chore: vendor Mitt & update project structure (#6209)
* chore: vendor Mitt into src/common/third-party

As discussed in #6203 we need to vendor our common dependencies in so
that when we ship an ESM build all imports point to file paths and do
not rely on Node resolution (e.g. a browser does not understand `import
mitt from 'mitt'`).
2020-07-14 16:57:29 +01: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
Changhao Han
8d6e0d8a79
chore: mark version to v5.1.0-post (#6208) 2020-07-13 10:43:46 +02:00
Changhao Han
8fa18aef99
chore: mark version v5.1.0 (#6206)
Co-authored-by: Changhao Han <changhaohan@chromium.org>
2020-07-13 10:25:14 +02:00
Changhao Han
790c277f0e
feat(chromium): roll Chromium to r768783 (#6201)
* feat(chromium): roll Chromium to r768783

* fix: update unit test for crrev:2135046

* chore: update devtools-protocol revision

Co-authored-by: Changhao Han <changhaohan@chromium.org>
2020-07-10 15:32:44 +02:00
Jack Franklin
31309b0e20
chore: use devtools-protocol package (#6172)
* chore: Use devtools-protocol package

Rather than maintain our own protocol we can instead use the devtools-protocol package and pin it to the version of Chromium that Puppeteer is shipping with.

The only changes are naming changes between the bespoke protocol that Puppeteer created and the devtools-protocol one.
2020-07-10 11:51:52 +01:00
Jack Franklin
f666be3f5f
chore: remove src/api.ts (#6191)
Now the async hooks helper is gone api.ts was only used by the coverage
tools and by doclint.

DocLint is nearing the end of its lifespan with the TSDoc work, so I
focused on how best to define a list of modules for the coverage
tooling. They define an object of classes, and the path to that module.
They need the full path because we also check if the module exports any
events that need to be emitted - the coverage tool asserts that the
emitting of those events is also tested.

It's not _great_ that DocLint relies on a constant defined in the
coverage utils, but it should only be this way for a short period of
time and no one is actively working on DocLint (bar the effort to remove
it) so I don't think this is worth worrying about.

This change also broke the DocLint tests; based on the fact that DocLint is on its way out it doesn't feel worth fixing the tests, so this commit also removes them.
2020-07-10 10:07:28 +01:00
Jack Franklin
928924ed36
chore: mark v5.0.0-post (#6144) 2020-07-02 16:13:04 +01:00
Jack Franklin
6d06adea10
chore: mark v5.0.0 (#6143) 2020-07-02 14:32:43 +01:00
Jack Franklin
221d172843
chore: add typecheck command (#6140)
If you want to run TypeScript only to verify that it's typechecking correctly, this command is quicker as it doesn't output CJS and ESM to disk. Useful for checking during development.
2020-07-02 13:04:55 +02:00
Jack Franklin
1f5e333f00
chore: Don't store revisions in package.json (#6109)
* chore: Don't store revisions in `package.json`

It's quite messy to have to require the `package.json` file in multiple
places purely to find out what revision of a given browser we want to
use. We can also achieve better type safety by placing it in an actual
source file.

This commit makes that change and also tidies up our reliance on
`package.json` within the source code generally; we now only use it to
find the location of the Puppeteer root such that we know where to
install downloaded browsers to.

To avoid using `package.json` to parse the name of the module, we also
now explicitly have an entry point for the Puppeteer module and the
Puppeter Core module. This will make it easier in the future to ship
less code as part of core (e.g. core never needs to download a browser,
so why ship that code?). Core can also then not have any revisions based
info contained in it.

The test install script has also been updated to ensure that
puppeteer-core can be installed correctly too.

Finally, the `install` script has been moved to TypeScript for nicer
typechecking and safety. The functionality of it has not changed.
2020-06-29 16:13:24 +01:00
Jack Franklin
1c0009d2c0
chore(agnostic): ship CJS and ESM builds (#6095)
* chore(agnostic): ship CJS and ESM builds

For our work to enable Puppeteer in other environments (e.g. a browser)
we need to ship an ESM build. This commit changes our config to ship to
`lib/cjs` and `lib/esm` accordingly. The majority of our code stays the
same, with one small fix for the CJS build to ensure that we ship a
version that lets you `require('puppeteer')` rather than have to
`require('puppeteer').default`. We do this with the `cjs-entry.js` which
is what the `main` field in our `package.json` points to.

We also swap to `read-pkg-up` to find the `package.json` file. This is
because the folder structure of `lib/` does not match `src/` now we ship
to `cjs` and `esm`, so you cannot rely on exact paths. This module works
up from the file to find the nearest `package.json` so it will always
find Puppeteer's `package.json`.

Note that we *do not* point any users to the ESM build. We happen to
ship those files so people who know about them can get at them but it's
not expected (nor will we actively support) that people will rely on
them. The CommonJS build is considered our main build.

We may make breaking changes to the structure of the ESM build which we
will do without requiring new major versions. For example the ESM build
currently ships all files that the CJS build does, but given we are
working on the ESM build being able to run in the browser this may
change over time.

Long term once the Node versions catch up we can ditch CJS and ship
exclusively ESM but we are not there yet.
2020-06-25 14:24:46 +01:00
Jack Franklin
70a900e93b
chore: fix ESLint violation and lessen rule strictness (#6081) 2020-06-23 12:55:42 +01:00
Jack Franklin
28797dee41
chore: migrate tests to TypeScript (#6075)
This CL migrates all the tests to TypeScript. The main benefits of this is that we start consuming our TypeScript definitions and therefore find errors in them. The act of migrating found some bugs in our definitions and now we can be sure to avoid them going forwards.

You'll notice the addition of some `TODO`s in the code; I didn't want this CL to get any bigger than it already is but I intend to follow those up once this lands. It's mostly figuring out how to extend the `expect` types with our `toBeGolden` helpers and some other slight confusions with types that the tests exposed.

Co-authored-by: Mathias Bynens <mathias@qiwi.be>
2020-06-23 07:18:46 +02:00
Jack Franklin
ace31d6f58
chore: pin TSDoc related dependencies (#6063)
Without the API-* dependencies pinned different versions may be
installed on local machines vs CI. One of the checks we do is to check
that the checked in docs matches what is generated on CI. Therefore we
need to ensure devs locally run the exact version that CI runs such that
they generate the same output. So in this case we pin to a particular
version of the dependencies.
2020-06-22 09:16:51 +01:00
Jack Franklin
7a4170fe6e
chore: remove top level errors and DeviceDescriptors (#6043)
As far as I can tell these became irrelevant as of v1.15 which added
`puppeteer.errors` and `puppeteer.devices [1]. This is a breaking change
but one that's easily mitigated. We've said that we don't consider
changes to our folder/file structure a breaking change, but we can't
really do that if we have these two top level files that we've
documented.

[1]: e3abb0aa32 (diff-522b24108d7446af4c59873472a90444)
2020-06-19 15:15:13 +02:00
Jack Franklin
5ff698ec98
chore: move index.js into src and TS-ify (#6049)
It was causing some infra issues when trying to migrate tests to
TypeScript (that's WIP in another branch that I'll have up soon). It's
unusual to have the entire src in TS except for the main file, which
then reaches into the compiled `lib` directory for the files it needs.

Much better is to move the entry point into TypeScript itself and update
the `main` entry in our `package.json` to point to the compiled output.

This also has the advantange of hooking up all the TS type defs that we
are shipping and will make that process easier too, along with making it
easier to port our tests to TypeScript.
2020-06-19 15:14:54 +02:00
Jack Franklin
940a5701ec
chore: exclude api.ts from dependency graph (#6052)
`api.ts` is a list of all our modules which is used to install a helper
and by DocLint. It's not that useful for our dep graph because it
literally requires the majority of modules so it just clutters up the diagram.
2020-06-19 13:44:49 +01:00
Jack Franklin
759b28080a
chore: upgrade to Mocha v8 (#5997)
* chore: upgrade to Mocha v8

Mocha v8 has some nice improvements and also unlocks the potential
to have parallel test runs which may speed up CI.
2020-06-18 16:26:30 +01:00
Jack Franklin
f6af7b8df0
chore: fix dependency chart generation (#6039)
`--max-depth` stopped the chart including our own modules. What we want
instead is the `do-not-follow` option to make it go to infinite depth in
our code but stop at the top level of a node module.
2020-06-18 14:31:05 +01:00
Jack Franklin
64c9c709c3
chore: add dependency chart generation as script (#6034) 2020-06-17 15:29:39 +02:00
Mathias Bynens
56742ebe8c
chore: bump version to v4.0.0-post (#6024) 2020-06-16 08:52:56 +02:00
Jack Franklin
2ffe710177
chore: mark version 4.0.0 (#6018) 2020-06-15 14:48:37 +01:00
Jack Franklin
b659969a38
chore: migrate away from Node's EventEmitter (#5979) 2020-06-15 11:52:19 +01:00
Tim van der Lippe
c701ea194a
chore: fix npm test command (#6010)
The `test` command referenced the task `npm run coverage`, which was renamed to `unit-with-coverage` in #5779.
2020-06-15 07:54:58 +02:00
Jack Franklin
91eb74519c
chore: ensure new-docs are up to date (#5994)
* chore: ensure new-docs are up to date

This adds a Travis check that if we re-generate the docs we get the
exact output (by checking if the Git tree is dirty).

We do the dirty check by using `git status --porcelain`, seeing how many
lines that outputs, and using that as the exit code (taking only the
first 255 lines to avoid invalid exit codes). `--porcelain` makes the
output be empty if the repo is not dirty in anyway which translates into
an exit code of 0.

We can't use `git diff-index --quiet HEAD` as it exits with 0 if there are
untracked files in the repo but we want that to cause a failure.
2020-06-11 09:48:37 +01:00
Jack Franklin
83c29d942b
chore: clean lib when running tsc (#5982)
I've had misleading type errors due to left over builds or tests
behaving oddly. We should just strip the entire folder out before
building again so there's no left over artefacts that could cause
issues.

The `|| true` in the command is so if `rm` errors because the folder
doesn't exist, it doesn't exit with an error code.
2020-06-09 12:10:19 +01:00
Jack Franklin
00324204ff
chore: Introduce API Extractor and start generating documentation (#5967) 2020-06-04 11:47:13 +01:00
Jack Franklin
58d1eab794
chore: mark version v3.3.0-post (#5960) 2020-06-02 15:20:20 +02:00
Jack Franklin
e84e579c3c
chore: mark version v3.3.0 (#5959) 2020-06-02 09:53:53 +01:00
Jack Franklin
309d8115c3
chore: Revert Mitt due to breaking changes (#5952)
Replacing the Node EventEmitter with Mitt caused more problems than
anticipated for end users due to the API differences and the amount of
people who relied on the EventEmitter API. In hindsight this clearly
should have been explored more and then released as a breaking v4.

This commit rolls us back to the built in Node EventEmitter library
which we can release to get everyone back on stable builds. We can then
consider our approach to migrating to Mitt and when we do do that we can
release it as a breaking change and properly document the migration
strategy and approach.
2020-06-02 09:32:02 +01:00
Jack Franklin
cfd72acc57
chore: bump version to v3.2.0-post (#5938) 2020-05-29 11:27:54 +02:00
Jack Franklin
88b5265be1
chore: mark version v3.2.0 (#5937) 2020-05-29 10:22:13 +01:00
Jack Franklin
1d4d25a0f3
Use Mitt as the Event Emitter (#5907)
* chore: migrate to Mitt as the EventEmitter

This commit moves us to using Mitt [1] for the event emitter in
Puppeteer. This removes our dependency to Node's EventEmitter which is
part of a larger stream of work to enable a Puppeteer-web version that
doesn't depend on Node.

There are no large breaking changes as we support the main methods that
EventEmitter had, but it also provides some methods that Puppeteer
didn't use. Technically end users could depend on this but it's
unlikely.

[1]: https://github.com/developit/mitt
2020-05-29 09:59:26 +01:00
Jack Franklin
9737059400
chore: remove doclint generate_types code (#5932)
This script generated an `index.d.ts` file but that file was never
commited to git nor included in Puppeteer when we ship. As of right now
people who want TS types can install from the DefinitelyTyped repo and
we are working on shipping types from Puppeteer itself.

Therefore this script is not adding any value and can be removed.
2020-05-28 15:55:14 +01:00
Alex Rudenko
e6c22dae05
chore: bump version to v3.1.0-post (#5884)
Co-authored-by: Alex Rudenko <alexrudenko@chromium.org>
2020-05-18 14:16:25 +02:00
Alex Rudenko
8ba36752e7
chore: mark version v3.1.0 (#5883)
* chore: mark version v3.1.0

Co-authored-by: Alex Rudenko <alexrudenko@chromium.org>
2020-05-18 13:47:03 +02:00
Alex Rudenko
e8232890a4
feat(chromium): roll Chromium to r756035 (#5879)
This corresponds to Chromium 83.0.4103.0.

This roll includes:

- Enable SameSiteByDefaultCookies and CookiesWithoutSameSiteMustBeSecure https://crrev.com/c/2122809
2020-05-18 11:06:42 +02:00
Jack Franklin
9368edbac9
chore: upgrade TypeScript to 3.9 (#5860)
Sticking to a specific version of TS rather than a ^ version so we know
everyone is on the exact same version. Think that's preferable for such
an important dependency.
2020-05-13 10:50:51 +01:00
Jack Franklin
b38bb4334f
Warn when given unsupported product name. (#5845)
* Warn when given unsupported product name.

Fixes #5844.

This change means when a user launches Puppeteer with a product name
that is not supported (which at the time of this commit means it's not
`firefox` or `chrome) we will warn them about it.

Decided on just a warning vs an error because the current behaviour is
that we fallback to launching Chrome and I don't think this warrants a
breaking change.
2020-05-12 10:30:24 +01:00
Jack Franklin
6099272612
chore: add @types/proxy-from-env (#5831) 2020-05-07 17:26:26 +01:00
Jack Franklin
510354054f
chore: add command to run eslint with --fix flag (#5829) 2020-05-07 15:54:33 +02:00
Jack Franklin
4fdb1e3cab
chore: add Prettier (#5825) 2020-05-07 12:54:55 +02:00
Jack Franklin
ae576aff61
chore: mark v3.0.4-post (#5824) 2020-05-07 12:04:22 +02:00
Jack Franklin
c214d20d54
chore: mark version v3.0.4 (#5823) 2020-05-07 11:52:59 +02:00
Mathias Bynens
17bb660dd5
chore: remove unused mime-types dependency (#5819) 2020-05-07 11:28:46 +02:00
Jack Franklin
51154824d8
chore: bump version to 3.0.3-post (#5814) 2020-05-06 17:27:31 +02:00
Jack Franklin
dd5bdf1616
chore: mark version v3.0.3 (#5813) 2020-05-06 15:57:04 +01:00
Jack Franklin
ae7483d5cf
chore: remove src/externs.d.ts (#5811)
* chore: remove src/externs.d.ts

It defined global types that we don't want to use, and instead we move
to using interfaces that we import and reference just like with any
other interface.

This means other than Protocol (which I think is fine to leave as is),
there are no other magic global types and you have to import any types
or interfaces that you want.
2020-05-06 14:23:07 +01:00
Jack Franklin
5518bac291
chore: update how we track coverage during unit tests (#5779)
* chore: update how we track coverage during unit tests

The old method of tracking coverage was causing issues. If a test failed
on CI, that test's failure would be lost because the test failing would
in turn cause the coverage to fail, but the `process.exit(1)` in the
coverage code caused Mocha to not output anything useful.

Instead the coverage checker now:

* tracks the coverage in memory in a Map (this hasn't changed)
* after all tests, writes that to disk in test/coverage.json (which is
gitignored)
* we then run a single Mocha test that asserts every method was called.

This means if the test run fails, the build will fail and give the error
about that test run, and that output won't be lost when the coverage
then fails too.

Co-authored-by: Mathias Bynens <mathias@qiwi.be>
2020-04-30 13:00:41 +01:00
Jack Franklin
1ccfbcb684
chore: enforce naming of errors in catch blocks (#5763) 2020-04-28 15:16:28 +02:00
Jack Franklin
3bf9bd199d
chore: enforce src/protocol.d.ts is in sync (#5762)
* chore: enforce src/protocol.d.ts is in sync

On CI we run `npm run compare-protocol-d-ts` which checks that the file
on disk is up to date with the protocol we fetch from the browser.


Co-authored-by: Mathias Bynens <mathias@qiwi.be>
2020-04-28 13:58:42 +01:00
Jack Franklin
8ddf4f3114
chore: bump version to 3.0.2-post (#5759) 2020-04-28 11:10:39 +01:00
Jack Franklin
646f42e98c
chore: mark version v3.0.2 (#5752) 2020-04-28 10:23:19 +01:00
Jack Franklin
3ed2f6b0ac
chore: remove puppeteer-web (#5750)
We don't support it and v3 shipped without including puppeteer-web in the browser. People are welcome to manually use Browserify to try to get Puppeteer running in a browser but it ultimately isn't our primary focus right now.

Getting puppeteer-core able to run in a browser is something we'll be looking at in the future so we'll revisit this soon.
2020-04-27 11:25:21 +02:00
Mathieu 'p01' Henri
0731049f86
chore: update pngjs to 5.0.0 and jpeg-js to 0.3.7 (#5676) 2020-04-23 11:38:00 +02:00
Jack Franklin
9d297f0827
chore: Bump version to 3.0.1-post (#5717) 2020-04-22 16:07:57 +01:00
Jack Franklin
feec588f95
chore: add test for npm package installing correctly (#5714)
* chore: add test for npm package installing correctly

This command packs up the module and installs it again to check we're
correctly bundling everything we need to allow users to do a fresh
install.

* install realpath
2020-04-22 15:33:36 +01:00
Jack Franklin
1615c9c9d5
chore: add install.js to files for publishing (#5712) 2020-04-22 12:16:51 +01:00
Jack Franklin
6029fdd618
chore: mark version v3.0.1 (#5709) 2020-04-22 11:10:04 +01:00
Jack Franklin
e3922ea1f3
chore: enforce consistent spacing around object curlys (#5700)
The codebase was incredibly inconsistent with the use of spacing around
curly braces, e.g.:

```
// this?
const a = {b: 1}
// or?
const a = { b: 1 }
```

This extended into import statements also. Google's styleguide is no
spacing, so we're going with that.
2020-04-21 10:40:04 +01:00
Jack Franklin
ef3befa2e6
chore: manage published files via files option (#5659)
Rather than a denylist (`.npmignore`) we can instead use an allowlist
via the `files` option in `package.json`. This makes it much harder to
accidentally include files or folders in the build as you have to
explicitly list the files that will be included.

Fixes #5648.
2020-04-17 11:32:25 +02:00
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