Commit Graph

24 Commits

Author SHA1 Message Date
Andrey Lushnikov
e6af6e19d6 feat(console): dispatch JSHandles as console arguments (#975)
This patch starts dispatching JSHandle instances as console arguments.

BREAKING CHANGE: this changes the API of the ConsoleMessage.

Fixes #324.
2017-10-09 17:01:01 -07:00
Andrey Lushnikov
0d0f9b7984 feat(JSHandles): introduce JSHandles (#943)
This patch:
- introduces ExecutionContext class that incapsulates javascript
  execution context. An examples of execution contexts are workers and
  frames
- introduces JSHandle that holds a references to the javascript
  object in ExecutionContext
- inherits ElementHandle from JSHandle

Fixes #382.
2017-10-06 15:35:02 -07:00
Andrey Lushnikov
a71f287c6b Fix evaluation in case of first "undefind" argument (#732)
It turns out that [undefined, 1].join(',') results in ",1" instead
of "undefined,1". This causes a syntax error when trying to pass undefined
as a first argument to `page.evaluate` method.

Fixes #572.
2017-09-11 16:59:38 -07:00
Andrey Lushnikov
0bea42bd8c Do not leave dangling promises when sending messages over protocol (#742)
It's very bad to have 'unhandled promise rejection' that can't be
handled in user code. These errors will exit node process in a near
future.

This patch avoids 'unhandled promise rejection' while sending protocol
messages.

This patch:
- introduces `puppeteer:error` debug scope and starts using it for all
  swalloed errors.
- makes sure that every `client.send` method is either awaited or its
  errors are handled.
- starts return promises from Request.continue() and Request.abort().
- starts swallow errors from Request.contine() and Request.abort().

The last is the most important part of the patch. Since
`Request.continue()` might try to continue canceled request, we should
disregard the error.

Fixes #627.
2017-09-11 16:21:51 -07:00
JoelEinbinder
42fa3af659 Remove promise jsdoc (#641)
This patch removes unnecessary "promise" return types in jsdoc for async functions.
2017-08-31 17:58:07 -07:00
Andrey Lushnikov
66912a7277 [api] use object instead of map for headers (#567)
This patch:

- switches to objects instead of maps for headers (in Request, Response and
page.setExtraHTTPHeaders)
- converts all header names to lower case

Fixes #547, fixes #509
2017-08-28 12:09:24 -07:00
JoelEinbinder
2c4dfbfd88 Fix node6 support for Object.entries and URL object (#548)
This patch introduces a polyfill for Object.entries which is missing in Node 6
2017-08-25 15:13:59 -07:00
Eric Bidelman
1f9b4fb4c8 Change let into const (#457)
This patch:
- changes `let` into `const` throughout codebase
- adds eslint check to prefer const over let
2017-08-21 16:39:04 -07:00
Aleksey
56eab00fa7 Roll chromium to r494365 (#271)
This patch:
- rolls chromium to r494365
- starts using Runtime.evaluate(awaitPromise: true), with new semantic
  we can avoid additional Runtime.awaitPromise call
- stops resolving promises for Console event
2017-08-15 17:35:59 -07:00
Andrey Lushnikov
fe06c896eb Roll chromium to 492629 (#230)
This patch
- rolls chromium to 492629
- migrates connection establishing to use browser target. This migration means
  that now we have a single websocket connection to browser (implemented
  in Connection class). A connection to a particular target is
  incapsulated in a new Session class.
2017-08-09 16:14:00 -07:00
Andrey Lushnikov
20ba447689 [DEBUG] Trace only those events which have listeners. (#201)
The `DEBUG=*page npm run unit` is too verbose due to events spamming
the console.

This patch starts tracing emitted events only if there are any
listeners.
2017-08-03 15:20:31 -07:00
Andrey Lushnikov
adf35952fc [DEBUG] More descriptive event reporting
This patch improves DEBUG reporting so that circular event
arguments are shown with some information.
2017-07-29 13:02:56 -07:00
JoelEinbinder
8780fcb662 Event coverage and debugging (#160)
This patch introduces event coverage for DEBUG module and 
API coverage.

Closes #50.
2017-07-28 11:45:05 -07:00
Andrey Lushnikov
ff5ed1c738 Implement page.waitForFunction method
The page.waitForFunction method allows to wait for a general predicate.
The predicate will be continiously polled for in page, until
it either returns true or the timeout happens.

The polling parameter could be one of the following:
- 'raf' - to poll on every animation frame
- 'mutation' - to poll on every dom mutation
- <number> - to poll every X milliseconds

References #91
2017-07-27 16:45:14 -07:00
JoelEinbinder
a2e0d27fb6 Implement public API coverage
This patch:
- implements a basic public API coverage based on 'helper.tracePublicAPI' methods
- adds `npm run coverage` command which reports coverage after running all of the unit tests

References #50.
2017-07-27 16:16:37 -07:00
JoelEinbinder
bbde8fd1c2 page.evaluate takes a string in addition to function (#135)
This patch improves on page.evaluate to accept a string.
The string can have a trailing '//# sourceURL=' comment which would
name the evaluation to make stacks beautiful.

In order to make sourceURL comments possible, this patch:
- removes wrapping of the client function into `Promise.resolve()`
- stops passing `awaitPromise` parameter to `Runtime.evaluate`
- starts to await promise via the `Runtime.awaitPromise` if the return type of the evaluation
  is promise

closes #118
2017-07-27 12:23:41 -07:00
JoelEinbinder
2e6751d6f5 Trace only string method names (#141) 2017-07-26 11:48:40 -07:00
Andrey Lushnikov
5549ad0282 Do not serialize remote objects unless needed
This patch stops serializing console API arguments unless there are
listeners of the 'console' event in puppeteer.

This saves quite a lot CPU cycles.

Fixes #117.
2017-07-24 21:43:54 -07:00
Andrey Lushnikov
c4904b4e10 Do not leak event listeners on navigation
This patch:
- introduces helper.addEventListener/helper.removeEventListeners
  to simplify event management
- moves NavigatorWatchdog over to the helper.addEventListener to
  stop leaking event listeners
2017-07-22 17:46:39 -07:00
Andrey Lushnikov
aba61de905 Make helper.getExceptionMessage synchronous
We now have description of an exception, no need for a roundtrip
to the backend.
2017-07-21 11:57:25 -07:00
Andrey Lushnikov
55acae40fd Introduce DEBUG module which traces public API calls
This patch improves on DEBUG module to trace all puppeteer's
public API calls.

References #89.
2017-07-18 21:06:03 -07:00
Andrey Lushnikov
6c1c3a0c45 Return remote object description for unserializable objects
This patch starts handling unserializable objects by returning their
description.

Fixes #86.
2017-07-18 01:34:43 -07:00
Andrey Lushnikov
1a97d8b3c2 Teach 'consolemessage' event to send all the arguments
This patch fixes 'consolemessage' event so that it passes
over all the arguments of console API call.
2017-07-17 20:22:45 -07:00
Andrey Lushnikov
3d90ea38a9 Implement Frame.evaluate
This patch implements Frame.evaluate method.

References #4.
2017-06-27 14:57:14 -07:00