Commit Graph

2159 Commits

Author SHA1 Message Date
David Barton
30c7b3c462
docs(contributing): specify Chromium version format for releases (#6956)
Co-authored-by: Mathias Bynens <mathias@qiwi.be>
2021-03-31 12:43:04 +02:00
Jack Franklin
b349c91e7d
fix: make $ and $$ selectors generic (#6883)
* fix: make `$` and `$$` selectors generic

This means, much like TS's in built `querySelector` type, you can now do:

```ts
const listItems = page.$$<HTMLLIElement>('ul li');
```

And/or:

```ts
const h2 = page.$<HTMLHeadingElement>('h2');
```

And the return value will be of type `ElementHandle<T>|null`, where `T`
is the type you provided. By default `T` is an `Element`, so you don't
have to provide this if you don't care as a consumer about the exact
type you get back.

* chore: fix test assertions
2021-03-25 11:40:34 +00:00
Jack Franklin
866d34ee11
fix: type page event listeners correctly (#6891)
This PR fixes the fact that currently if you have:

```ts
page.on('request', request => {

})
```

Then `request` will be typed as `any`. We can fix this by defining an
interface of event name => callback argument type, and looking that up
when you call `page.on`.

Also includes a drive-by fix to ensure we convert response headers to
strings, and updates the types accordingly.
2021-03-25 11:26:35 +00:00
Christian Bromann
e31e68dfa1
fix(typescript): allow defaultViewport to be 'null' (#6942)
Fixes: #6885

Co-authored-by: Maksim Sadym <69349599+sadym-chromium@users.noreply.github.com>
2021-03-24 12:14:06 +01: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
David Barton
ff860819a7
docs(api): fix lint in code snippets (#7012) 2021-03-22 07:12:55 +01:00
Daniel Rowe
dc8ab6d8ca
feat(page): add omitBackground option for page.pdf method (#6981) 2021-03-18 19:57:32 +00:00
Julian Descottes
b8d72cb039
chore: skip non-standard cookie asserts on Firefox (#6994) 2021-03-17 16:09:10 +00:00
Robin Richtsfeld
8695759a22
feat(network): request interception and caching compatibility (#6996)
This patch enables developers to also keep the cache on when doing request interception.
2021-03-17 15:42:35 +01:00
Henrik Skupin
bf60a300e7
chore: improve "Page.close should run beforeunload if asked for" unit test for Firefox (#6995) 2021-03-16 15:35:32 +01:00
Joel Griffith
5f24f60819
fix: make screenshots work in puppeteer-web (#6936) 2021-03-15 09:05:15 +00:00
Robin Richtsfeld
1c2479a6cd
fix(network): don't disable cache for auth challenge (#6962)
* fix(network): don't disable cache for auth challenge

* test: page.authenticate does not disable caching

* fix(network): _protocolRequestInterceptionEnabled -> _userRequestInterceptionEnabled

* style(test): fix line breaks

Co-authored-by: Mathias Bynens <mathias@qiwi.be>
2021-03-15 07:02:07 +00:00
Nitin Kumar
56f17fe481
docs(readme): remove inactive slack link (#6986) 2021-03-15 07:48:06 +01:00
Maciej Brencz
35e66c4304
docs(troubleshooting): update Alpine section (#6960)
The latest Chromium provided by Alpine is at version 89.

Co-authored-by: Mathias Bynens <mathias@qiwi.be>
2021-03-09 09:02:24 +01:00
Sri Harsha
9e3fcb9f94
chore(src): fix minor typo (#6961) 2021-03-09 09:01:09 +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
David Barton
abb32801d5
chore: add latest chromium version (#6952) 2021-03-04 07:50:08 +01:00
Darío Kondratiuk
2ba61e04e9
fix(filechooser): cancel is sync (#6937)
BREAKING CHANGE: FileChooser.cancel() is now synchronous.
2021-03-02 15:27:11 +01: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
Aurélien Ooms
05c08e7083
docs(api): fix typo in environment variable name (#6918)
`PUPPETEER_SKIP_DOWNLOAD ~ PUPPETEER_SKIP_CHROMIUM_DOWNLOAD`.
2021-02-23 13:36:30 +01:00
su
ebc3e88fce
docs(api): fix typo (#6911)
Issue: #6903
Co-authored-by: susan51531 <804885378@qq.com>
2021-02-20 11:31:37 +01:00
Henrik Skupin
b046fd79bd
chore: run unit tests for Firefox on MacOS (#6896) 2021-02-18 13:44:36 +01:00
Jack Franklin
00d88ef0d8
chore: enable ff unit tests again (#6861) 2021-02-18 11:51:55 +01:00
信鑫-King
d66389ba7e
docs(readme): fix page.pdf code example (#6890)
Ref: `PaperFormat` type.
2021-02-18 09:05:43 +01:00
Mathias Bynens
f7de60be22
fix: move CI npm config out of .npmrc (#6901)
This avoids issues with local `npm commands` trying to use the Wombat registry.
2021-02-17 18:52:22 +01:00
Jack Franklin
ff26c62647
fix: explicit HTTPRequest.resourceType type defs (#6882)
We can use the new `Lowercase` util in TS4 to avoid duplicating the type
and instead lowercase it.

Note we still need to do the work so callbacks are typed correctly:

```ts
page.on('request', request => {

})
```

Right now `request` is `any`, whereas it should be a
`puppeteer.HTTPRequest`. You can manually set the type for now, and I
will work on adding types for events so that this is done automatically
by the compiler in a future release.

Fixes #6854.
2021-02-17 10:14:38 +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
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
be7c22933c
fix: expose Viewport type (#6881)
Also includes drive-by when I subbed `@default` (not valid) to
`@defaultValue` (valid!) in a few places and exposed types from
`Coverage.ts` so they get exposed too.

Fixes 6876.
2021-02-12 12:32:27 +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
a5e174f696
fix: expose puppeteer.Permission type (#6856)
* fix: expose puppeteer.Permission type

A regression in our own types when compared to @types/puppeteer - we
needed to expose the permissons.
2021-02-11 15:44:56 +00:00
Alex Rudenko
ad5935738d
feat(page): add color-gamut support to Page.emulateMediaFeatures (#6857)
The change updates the validation function to allow color-gamut media
features and updates the documentation.

Issues: #6761
2021-02-11 13:59:50 +00:00
Mathias Bynens
a63f53c938
fix: add favicon test asset (#6868)
The favicon was taken from https://github.com/mathiasbynens/small.

Issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1682076
2021-02-11 11:54:45 +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
641ffc2a20
chore: improve TS automated type tests (#6860)
This PR:

1. Makes sure we remove and freshly install Puppeteer before testing our
   type defs, to avoid running on stale files.
2. Makes the tests run off `puppeteer.tgz` to avoid having version
   numbers in the file name and therefore having to update it when we
   bump versions.
2021-02-11 10:34:44 +00:00
Jack Franklin
bdaba7829d
fix: jsonValue() type is generic (#6865)
During the migration to TS we changed `jsonValue` so it returned
`<Record<string, unknown>>`. This is only true if all the JSON values it
returns are objects; but it could return an array, a string, a number,
etc. Therefore we make the type generic, setting the default to
`unknown`, so the user has control over the type.
2021-02-11 09:50:15 +00:00
Jack Franklin
63d48b2ecb
fix: expose ScreenshotOptions type in type defs (#6869)
Fixes #6866.
2021-02-11 09:35:26 +00:00
Jack Franklin
df41b87b82
chore: temporarily disable FF tests on CI (#6864)
* chore: temporarily disable FF tests on CI

The tests are regularly flaking (see #6861 for some investigation). In
the mean time it's blocking us landing and releasing, so we'll
temporarily skip FF tests for now.

Co-authored-by: Mathias Bynens <mathias@qiwi.be>
2021-02-11 09:14:28 +00: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
Jan Scheffler
25abae6e79
chore(domworld): clear set (#6847) 2021-02-09 10:39:15 +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
David Barton
58d5f9c3ae
docs(troubleshooting): update broken Dockerfile link to historical one (#6828)
Co-authored-by: Mathias Bynens <mathias@qiwi.be>
2021-02-09 09:45:36 +01:00