Commit Graph

889 Commits

Author SHA1 Message Date
Mathias Bynens
dd470c7a22
feat(api): make page.isDragInterceptionEnabled a method (#7419)
Having it be a getter is surprising and inconsistent, since the other `page.is*` APIs are just methods.

Issue: #7150
2021-07-13 11:37:39 +02: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
Ben Allfree
b5e6474374
feat: add cooperative request intercepts (#6735)
With this change,`request.respond`, `request.abort`, and `request.continue` can accept an optional `priority` to activate Cooperative Intercept Mode. In Cooperative Mode, all intercept handlers are guaranteed to run and all async handlers are awaited. The interception is resolved to the highest-priority resolution. See _Cooperative Intercept Mode and Legacy Intercept Mode_ in `docs/api.md` for details.
2021-07-02 17:58:32 +00:00
Rowan Merewood
7200b1a6fb
feat: add support for useragentdata (#7378)
Adds userAgentData to setUserAgent that supports specifying user agent
data for the new navigator.userAgentData and Client Hints headers.
2021-06-29 18:29:55 +02:00
Brian Misiak
e3699e248b
feat: add a streaming version for page.pdf
Co-authored-by: Jan Scheffler <janscheffler@chromium.org>
2021-06-23 14:51:38 +02:00
Jan Scheffler
4ce4110628
feat: add page.emulateCPUThrottling (#7343) 2021-06-22 11:43:11 +00:00
Dan Park
a91b8aca37 feat: add drag-and-drop support (#7150)
This commit adds drag-and-drop support, leveraging new additions to the CDP Input domain (Input.setInterceptDrags, Input.dispatchDragEvent, and Input.dragIntercepted).
2021-06-07 13:50:34 +02:00
Darío Kondratiuk
b4509d31cc
test: fix page.browserContext test title (#7292) 2021-05-27 13:51:41 +00:00
Darío Kondratiuk
ad523c87fa
test: move network emulation tests to the emulation spec file (#7293) 2021-05-27 13:17:12 +00:00
Jan Scheffler
f863f4bfe0
feat(chromium): roll to Chromium 92.0.4512.0 (r884014) (#7288) 2021-05-26 16:44:29 +00:00
Darío Kondratiuk
2c9ff4feaf
test: fix typo in page test (#7277) 2021-05-26 14:52:54 +00:00
Maksim Sadym
cb038cd401
test: close browser in case of test failed (#7271) 2021-05-26 11:17:56 +02:00
Darío Kondratiuk
89a85b428d
test: reorder describes in JS coverage spec (#7075)
Just some code reorder. We had a describe between it calls. I'm moving that describe to the end

Co-authored-by: Jack Franklin <jacktfranklin@chromium.org>
2021-05-25 08:14:44 +01:00
Robin Richtsfeld
d01aa6c84a
feat(requestinterception): remove cacheSafe flag (#7217) 2021-05-20 14:09:56 +02:00
Robin Richtsfeld
e0b35d7d1d
test: remove console.log in unit test (#7216)
Co-authored-by: Mathias Bynens <mathias@qiwi.be>
2021-05-17 07:32:53 +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
Patrick Hulce
cb285a2379
feat: expose other sessions from connection (#6863) 2021-05-07 08:31:39 +00: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
Robin Richtsfeld
c9978d20d5
fix(requestinterception): fix font loading issue (#7060)
See https://github.com/puppeteer/puppeteer/pull/6996#issuecomment-811546501 and https://github.com/puppeteer/puppeteer/pull/6996#issuecomment-813797393 for context.

Issue: #7038
2021-05-06 08:36:34 +02:00
Jan Scheffler
8126101980
chore: disable flaky test on Firefox (#7207) 2021-05-05 12:21:14 +00:00
Jan Scheffler
ec3fc2e035
feat: add option to filter targets (#7192)
* feat: add option to filter targets

Co-authored-by: Mathias Bynens <mathias@qiwi.be>
2021-05-03 13:48:31 +02:00
Jan Scheffler
a293b96952 chore: disable flaky test on Firefox
Issue: #7182
2021-05-03 10:48:29 +02:00
Henrik Skupin
49a54cfc93
chore: enable firefox reconnection spec (#7114) 2021-04-22 09:55:49 +02:00
Henrik Skupin
4607d5a2d3
chore: run "should be able to launch Firefox" only with regular install (#7106) 2021-04-20 08:56:20 +02:00
Darío Kondratiuk
c39c81d016 test: fix Browser.pages should return all of the pages (#7064) 2021-04-07 09:11:43 +02:00
Darío Kondratiuk
138ddc3641
chore(test): reorder describes in coverage spec (#7032) 2021-04-06 09:30:55 +00:00
Alex Rudenko
4426135692
fix(aria): fix parsing of ARIA selectors (#7037) 2021-04-06 10:41:49 +02:00
Jack Franklin
9633e6e392
chore: disable firefox reconnection spec (#7062)
It's constantly failing on CQ - think there's an issue in Firefox
nightly.
2021-04-06 08:19:32 +00: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
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
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
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
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
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
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
Henrik Skupin
b046fd79bd
chore: run unit tests for Firefox on MacOS (#6896) 2021-02-18 13:44:36 +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
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
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
Jan Scheffler
4e8d074c2f
fix(domworld): reset bindings when context changes (#6766) (#6836) 2021-02-08 18:56:04 +00:00
Maksim Sadym
401d84e4a3
feat: use captureBeyondViewport in Page.captureScreenshot (#6805)
BREAKING CHANGE:
- `page.screenshot` makes a screenshot with the clip dimensions, not cutting it by the ViewPort size.
2021-02-03 14:30:46 +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
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
Jan Scheffler
cac540be3a
fix(domworld): fix waitfor bindings (#6766) (#6775)
* fix(domworld): fix waitfor bindings (#6766)

Co-authored-by: Johan Bay <jobay@google.com>
2021-01-25 13:01:59 +01:00
Jan Scheffler
5ea76e9333
feat: add page.emulateNetworkConditions (#6759) 2021-01-21 10:00:57 +01:00
Maja Frydrychowicz
09fca442f7
chore: update test expectations per Mozilla’s sync-up with v5.5.0 (#6650)
This patch enables more tests for Firefox. These tests are enabled in Mozilla's CI for Firefox. The extra error handling here prevents hangs in the test harness in that environment.
2020-12-07 08:18:32 +01:00
dmitrysteblyuk
fb859115c0
fix: do not use old utility world (#6528)
Don’t use the old utility world, as it is being destroyed later when browser reconnects to the page.

Issue: #6527
2020-11-26 12:43:42 +01:00
Michael Kebede
b57f3fcd53
feat: support promise as return value for page.waitForResponse predicate (#6624)
Co-authored-by: Joni <josalmi@google.com>
2020-11-25 11:35:47 +01:00
Jack Franklin
659193a4f5
chore: mark launcher spec as failing on Windows (#6574)
We've pushed this date back a lot, let's make it permanent until we have
more time to investigate.
2020-11-03 10:11:29 +00:00
Peter Thaleikis
3bb417b14b
chore: fix typo in test (#6566) 2020-11-01 09:43:07 +01:00
Johan Bay
729cdfe98a
chore: mark version v5.4.0 (#6542) 2020-10-23 16:28:38 +02: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
Johan Bay
8fabe32800
feat(queryhandler): add built-in pierce handler (#6509)
Adds a handler 'pierce' that pierces shadow roots while querying.
2020-10-13 11:05:47 +02: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
Johan Bay
3afe1935da
feat(a11y-query): extend aria handler with waitFor (#6472)
This commit adds waitFor to the built-in aria handler (#6307).
2020-10-07 10:49:11 +02:00
Johan Bay
950ae334ca
feat(a11y-query): aria query handler sans waitfor (#6459)
This commit adds a new built-in handler for querying by accessible name and role (#6307).
Support for waitForSelector will be added in a follow-up commit.
2020-10-05 08:25:55 +02:00
Maja Frydrychowicz
41ef3eec90
fix: update preferences in default Firefox profile (#6465) 2020-10-05 07:17:21 +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
Maja Frydrychowicz
4cdbebe1ac
chore: disable firefox windows launcher test until Nov (#6451) 2020-09-29 16:04:07 +01: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
Yang Guo
96f3d439f5
feat(console): expose stack trace for console messages (#6445) 2020-09-25 15:27:13 +02:00
Johan Bay
72fe86fe6a
feat(a11y-query): introduce internal handlers (#6437)
This commit changes the internal representation of query handlers to contain Puppeteer-level code instead of page functions.
The interface `CustomQueryHandler` is introduced for user-defined query handlers. When a `CustomQueryHandler` is registered using  `registerCustomQueryHandler` a corresponding Puppeteer-level handler is created through `makeQueryHandler` by wrapping the page functions as appropriate.
The internal query handlers (defined by the interface `QueryHandler`) contain two new functions: `waitFor` and `queryAllArray`.
- `waitFor` allows page-based handlers to make use of the `WaitTask`-backed implementation in `DOMWorld`, whereas purely Puppeteer-based handlers can define an alternative approach instead.
- `queryAllArray` is similar to `queryAll` but with a slightly different interface; it returns a `JSHandle` to an array with the results as opposed to an array of `ElementHandle`. It is used by `$$eval`. 

After this change, we can introduce built-in query handlers that are not executed in the page context (#6307).
2020-09-23 16:02:22 +02:00
Johan Bay
b1c3efaa34
feat(a11y-query): split waitFor logic for selectors and xpath (#6426)
The logic for waitForXPath and waitForSelector is currently very tightly coupled. This commit tries to untangle that relationship. This is the first step towards introducing built-in query handlers that are not executed in the page context (#6307).
2020-09-21 15:47:33 +02:00
campersau
083ea41e94
test(frame): correct terminology in URL fragment test (#6416)
Bug: #6398
2020-09-14 13:42:32 +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
Mathias Bynens
e22ca4c7c4
chore: extend Firefox launch test deadline by a month (#6403)
Ref. #5673.
2020-09-08 15:08:23 +02:00
Bryan Maloyer
b6bbfd0ede
fix: ensure frame.url() includes the query string (#6398)
Co-authored-by: Mathias Bynens <mathias@qiwi.be>
2020-09-08 10:49:44 +02:00
Maja Frydrychowicz
054d782c82
fix(Launcher): use wait-for-process Firefox option (#6315) 2020-08-10 10:23:17 +02:00
Christian Bromann
9bc063b5ef
chore: assert location value of ConsoleMessage in tests (#6282) 2020-07-29 12:13:50 +01:00
Jack Franklin
21552f8fe7
feat: page.waitForTimeout (#6268) 2020-07-28 10:37:49 +02:00
Christian Bromann
8c1a5866c5
fix: handle promise for reading protocol stream of trace (#6270) 2020-07-23 16:21:15 +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
Johan Bay
313774c553
feat: change QueryHandler to contain QueryOne and QueryAll methods (#6218)
Co-authored-by: Mathias Bynens <mathias@qiwi.be>
2020-07-17 07:29:42 +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
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
9b3005c105
feat(types): improve page.evaluate types (#6193) 2020-07-10 11:52:13 +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
12434663e2
chore: remove installAsyncStackHooks helper (#6186)
* chore: remove `installAsyncStackHooks` helper

This code was written when browsers/Node didn't support errors in async
functions very well. They now do a much better job of this, so we can
lose the additonal complexity from our codebase and leave it to the host
environment :)

* lazy launcher is private

* remove async stack test
2020-07-09 11:38:25 +01:00
Christian Bromann
e67a860eb0
feat: add Mouse#wheel (#6141) 2020-07-06 09:27:17 +02:00
Jack Franklin
5049b83186
feat(types): add types for page.$$eval (#6139)
* feat(types): add types for `page.$$eval`

* Add new-docs for $$eval

* fix example

* linting
2020-07-03 15:23:51 +01:00
Jack Franklin
6474edb9ba
feat(types): add types for $eval (#6135)
This pulls in the types (based on the DefinitelyTyped repo) for
`page.$eval` (and the `$eval` method on other classes). The `$eval`
method is quite hard to type due to the way we wrap and unwrap
ElementHandles that are passed to / returned from the `pageFunction`
that users provide.

Longer term we can improve the types by providing type overloads as
DefinitelyTyped does but I've deferred that for now (see the `TODO` in
the code for more details).
2020-07-02 10:09:34 +01:00
Jack Franklin
8370ec88ae
feat(types): add (and fix) evaluateHandle types (#6130)
This change started as a small change to pull types from DefinitelyTyped over to
Puppeteer for the `evaluateHandle` function but instead ended up also fixing
what looks to be a long standing issue with our existing documentation.

`evaluateHandle` can in fact return an `ElementHandle` rather than a `JSHandle`.
Note that `ElementHandle` extends `JSHandle` so whilst the docs are technically
correct (all ElementHandles are JSHandles) it's confusing because JSHandles
don't have methods like `click` on them, but ElementHandles do.

if you return something that is an HTML element:

```
const button = page.evaluateHandle(() => document.querySelector('button'));
// this is an ElementHandle, not a JSHandle
```

Therefore I've updated the original docs and added a large explanation to the
TSDoc for `page.evaluateHandle`.

In TypeScript land we'll assume the function will return a `JSHandle` but you
can tell TS otherwise via the generic argument, which can only be `JSHandle`
(the default) or `ElementHandle`:

```
const button = page.evaluateHandle<ElementHandle>(() => document.querySelector('button'));
```
2020-07-01 12:44:08 +01:00
Jack Franklin
3c0dc45e47
chore: update Windows skipped tests. (#6133)
The headful one I'm permanently skipping as I don't know what the issue is and I can't debug without getting my hands on a Windows machine. If anyone has one or is able to help, that'd be great!

The other I'm deferring another month and will ping the FF folks :)
2020-07-01 11:28:13 +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
Jack Franklin
785551997f chore: tidy up TODO from TS tests migration (#6090)
Deleting `Node` errors in strict mode; we don't need to have this test
any more.
2020-06-25 13:01:36 +02:00
Jack Franklin
37f6032003
feat(api): remove emulateMedia method (#6084)
It has been deprecated for a while. In the next breaking release let's remove it.

BREAKING CHANGE: swap to `emulateMediaType` instead.
2020-06-23 16:27:37 +01:00
Jack Franklin
381b0f833c
chore: declare toBeGolden to TypeScript (#6080)
Which means we can avoid all the ts-expect-errors on any `toBeGolden`
calls.
2020-06-23 15:02:09 +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
e7b91a7f41
chore: enforce a max line length on comments (#6055) 2020-06-19 15:39:03 +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