Commit Graph

1907 Commits

Author SHA1 Message Date
Martin Splitt
a46c78fc91 docs(new): Adds TSDoc to Tracing class (#6088)
* Adds tsdoc to Tracing class

* Updates tsdocs

Co-authored-by: martinsplitt <martin@geekonaut.de>
2020-06-25 13:01:46 +02:00
Martin Splitt
60904da4cd docs(new): migrate FileChooser docs to TSDoc (#6092)
Co-authored-by: martinsplitt <martin@geekonaut.de>
2020-06-25 13:01:36 +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
Martin Splitt
f481922175 docs(new): Adds TSDoc to Mouse class (#6086)
* Adds tsdoc to Mouse class

* Updates puppeteer class tsdoc

* docs(new): add TSDoc comments to BrowserFetcher (#6078)

* Adds tsdoc for Touchscreen (#6087)

Co-authored-by: martinsplitt <martin@geekonaut.de>

* Adds tsdoc to Mouse class

* Fixes tsdoc comment for Mouse class

Co-authored-by: martinsplitt <martin@geekonaut.de>
2020-06-25 13:01:36 +02:00
Martin Splitt
2ad42dc398 docs(new): migrate Touchscreen docs to TSDoc (#6087)
Co-authored-by: martinsplitt <martin@geekonaut.de>
2020-06-25 13:01:12 +02:00
Martin Splitt
73b97956cc
docs(new): add TSDoc comments to BrowserFetcher (#6078) 2020-06-24 09:33:19 +01: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
1ee379ce4d
chore: avoid disabling prettier (#6079) 2020-06-23 15:02:22 +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
k.zaitsev
fdc6fda46e
docs: fix effect -> affect typos (#5985) 2020-06-23 07:24:15 +02:00
Tim van der Lippe
4659ee8daa docs(new): add TSDoc comments to BrowserContext (#6066) 2020-06-23 07:22:10 +02:00
Peter Marshall
ccae54644c
docs(new): migrate Browser docs to TSDoc (#6070) 2020-06-23 07:19:15 +02: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
Stefan
2090676a55
docs: fix broken link to DeviceDescriptors.ts (#6076) 2020-06-23 06:56:31 +02:00
Alex Rudenko
6657364364
docs(new): migrate ElementHandle to TSDoc (#6073)
* docs(new): migrate ElementHandle to TSDoc

Co-authored-by: Alex Rudenko <alexrudenko@chromium.org>
2020-06-22 17:21:57 +02:00
Alex Rudenko
7025f1c5ea
docs(new): migrate Target to TSDoc (#6067)
* docs(new): migrate Target to TSDoc

Co-authored-by: Alex Rudenko <alexrudenko@chromium.org>
2020-06-22 14:57:04 +02:00
Paul Lewis
819afbebf7
docs(new): migrate ConsoleMessage docs to TSDoc (#6065) 2020-06-22 13:52:39 +01:00
Alex Rudenko
983a7b67df
docs(new): migrate CDPSession to TSDoc (#6064) 2020-06-22 12:05:10 +02:00
Alex Rudenko
1cf3f06055
docs(new): migrate TimeoutError to TSDoc (#6062)
* docs(new): migrate TimeoutError to TSDoc

Co-authored-by: Alex Rudenko <alexrudenko@chromium.org>
2020-06-22 10:34:57 +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
Tayo Agagu
750f5eecae
docs: fix broken link to USKeyboardLayout file (#6059)
Link in api doc to USKeyboardLayout returns a 404 (missing common folder in link)
2020-06-22 07:26:04 +02:00
Jack Franklin
e7b91a7f41
chore: enforce a max line length on comments (#6055) 2020-06-19 15:39:03 +01:00
Mathias Bynens
7978315de7
docs(new): migrate SecurityDetails docs to TSDoc (#6053) 2020-06-19 15:30:28 +02: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
9522f80116
chore: create common directory (#6042)
These files will be used by both the web and node versions of Puppeteer.
Another name for this might be "core" but I don't want to cause
confusion with the puppeteer-core package that we publish at the moment.
2020-06-18 15:53:23 +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
90b0934f85
chore: create node directory for Node-only files (#6041)
This is another step towards making Puppeteer agnostic of environment
and being able to run in Node or a browser.

The files in the `node` directory are ones that would only be needed in
the Node build - e.g. the code that downloads and launches a local
browser instance.

The long term vision here is to have three folders:

* node - Node only code
* web - Web only code
* common - code that is shared

But rather than do that in one PR I'm going to split it up to make it
easier to review and deal with.
2020-06-18 13:49:59 +01:00
Jack Franklin
ce34c0a4ff
fix: page.goto options type should be optional (#6038)
The TypeScript definition erroneously made `options` required. We can
fix it by providing a default value, which means users calling the
function will be able to leave it blank without TS complaining.

Issues like this are a +1 to porting our tests to TypeScript in order to
catch these on our own test suite, so that's something we should look into.
2020-06-18 12:44:46 +01:00
Martin Splitt
44402b75a0
feat(new-docs): add tsdoc comments to WebWorker (#6029)
* feat(new-docs): add TSDoc comments to `WebWorker`

Co-authored-by: martinsplitt <martin@geekonaut.de>
2020-06-17 16:26:10 +01:00
Jack Franklin
64c9c709c3
chore: add dependency chart generation as script (#6034) 2020-06-17 15:29:39 +02:00
Jack Franklin
547f4ea60a
chore: create new debug module (#6028)
* chore: create new Debug module

This debug module can be used in either Node or the browser. We'll use
the `debug` module in Node land, but fallback to a simple `console.log`
solution when in the browser in an attempt to keep our browser bundle
size down.

* Use our debug wrapper rather than Node's `debug`.
2020-06-16 16:24:54 +01:00
Mathias Bynens
56742ebe8c
chore: bump version to v4.0.0-post (#6024) 2020-06-16 08:52:56 +02:00
Jack Franklin
e4de5f10d0
chore: move assert into its own module (#6021)
A lot of the helpers in `helpers.ts` are heavily bound to NodeJS and at
the moment we're trying to make the `Connection` class be able to run in
multiple environments. Its only remaining Node dependency was its
reliance on `helpers.ts`, which it only needed for `assert`.

This is a useful change also because `helpers.ts` is quite large and
full of functions that do different things; I think we can name them
better and move them into modules with a specific purpose rather than a
generic `"helpers"` dumping ground.

Once this change lands `Connection` should be usable in the browser.
2020-06-15 17:34:50 +02:00
Mathias Bynens
f1ec6a3df0
chore: update references to branch names (#6022) 2020-06-15 17:34:16 +02:00
Jack Franklin
2ffe710177
chore: mark version 4.0.0 (#6018) 2020-06-15 14:48:37 +01:00
Tim van der Lippe
03ab1c1b9c
fix: improve Ctrl + C support (#6011)
Fix child process killing when the parent process SIGINTs.

If you `ctrl + c` the Puppeteer parent process, we would sometimes not properly handle killing of the child processes. This would then leave child processes behind, with running Chromium instances. This in turn could block Puppeteer from launching again and results in
cryptic errors.

Instead of using the generic `process.kill` with the process id (which for some reason is negative the pid, which I don't get), we can kill the child process directly by calling `proc.kill`.

Fixes #5729.
Fixes #4796.
Fixes #4963.
Fixes #4333.
Fixes #1825.
2020-06-15 15:02:00 +02:00
Jack Franklin
b659969a38
chore: migrate away from Node's EventEmitter (#5979) 2020-06-15 11:52:19 +01:00
Jarrod Overson
6e060ce0fd
fix(connection): separate send/receive debug logging (#6017)
This PR splits the logging for send and receive messages in to separate debug channels.
This way it is easier to filter and takes advantage of debug's automated coloring to make
it easier to visually parse on the command line
2020-06-15 09:36:45 +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
Tim van der Lippe
398c16d61d
chore: fix docs linter (#6009)
4205ff79d9 removed the header in the Mouse class documentation, but the linter requires the reference to that header to be removed as well.
2020-06-12 18:24:53 +02:00
Mathias Bynens
4205ff79d9 docs(api): remove subheader for non-namespace
This way, pptr.dev doesn’t incorrectly think the header is a namespace.

Ref. #6000.
2020-06-12 17:13:20 +02:00
Maja Frydrychowicz
3d56a9e76f chore: add test configuration options for running tests against multiple products (#5964)
* chore: remove "Extracting..." log message

Fixes #5741.

* test: support extra Launcher options and skips

The extra Launcher options and skipping conditions enable
unit tests to be run more easily by third-parties, e.g.
browser vendors that are interested in Puppeteer support.

Extra Launcher options were previously removed as part of
switching away from the custom test harness.

* test: enable more tests for Firefox
2020-06-12 15:56:11 +02:00
Jack Franklin
5c91dfbf3f
chore: move index.js into src (#6007)
* chore: move `index.js` into `src`

This is the first part of a series of pull requests that will slowly
make it possible to initialise Puppeteer for either a Node environment
or a web one. By creating the `initialisePuppeteer` function we can
inject dependencies in for the given version of Puppeteer (e.g. inject a
different debug library for Node vs the web).

This PR moves the initialisation into `src` and calls into it from the
root `index.js`.
2020-06-12 13:53:02 +01:00
Jack Franklin
8a099a0c2c
docs: replace @return with @returns (#6006)
The former is not understood by TSDoc.
2020-06-12 12:38:24 +02:00
Jack Franklin
23f18d8cc0
docs(new): start documenting the Page class (#6001)
This PR starts exploring the Page class and how to best document it. It explores how best to document events in the system, and I think pulling them out into an `enum` is the best solution here. It lets us end up with a page of docs that explicitly lists all the events the page class can ever emit.
2020-06-12 11:10:12 +01:00
Tim van der Lippe
c1d7be379b
docs(api): add copy-pasting text example to Mouse class (#6000)
There are numerous issues on the Puppeteer issue tracker about selecting and copy-pasting of text (#3252, #4954,  #423, #1366, #343) as well as several StackOverflow questions:

- https://stackoverflow.com/questions/57101467/how-do-you-paste-text-using-puppeteer
- https://stackoverflow.com/questions/49131516/how-to-copy-text-from-browser-clipboard-using-puppeteer-in-nodejs
- https://stackoverflow.com/questions/60158746/how-do-i-access-the-contents-of-the-clipboard-from-within-a-headless-puppeteer-t
- https://stackoverflow.com/questions/56306153/domexception-on-calling-navigator-clipboard-readtext

I propose we include this commonly-asked question in the main documentation.

Fixes #3252.
Fixes #4954.
2020-06-12 07:32:59 +02:00