Commit Graph

94 Commits

Author SHA1 Message Date
Andrey Lushnikov
34a96a8462 Rename navigation option 'waitFor' into 'waitUntil'.
This patch renames navigation option 'waitFor' into 'waitUntil' to
avoid confusion with 'page.waitFor' call.

References #39.
2017-07-14 13:59:36 -07:00
Andrey Lushnikov
76415e1be5 [doc] distinct naming for functions which are evaluated in page context
This patch renames all the function parameters which are executed in
page context into 'pageFunction'.
2017-07-14 13:51:22 -07:00
Andrey Lushnikov
235001bab3 [doclint] validate return statements
This patch teaches doclint to validate presence of return statements.
It also adds a bunch of documentation to the api.md.

References #14.
2017-07-14 13:04:15 -07:00
JoelEinbinder
4bd855c66b Use getBoundingClientRect instead of DOM.BoxModel (#76)
This patch re-implements `page.click()` and `page.focus()` using
`page.evaluate`
2017-07-13 18:32:34 -07:00
Andrey Lushnikov
64ebcdba9f Do not close readline after reading remote debugging port
Closing readline interface results in closing underlying
stream. We don't want this.
2017-07-12 19:15:21 -07:00
Andrey Lushnikov
38e6f53cc7 [doclint] add linting for class properties
This patch:
- adds linting for class properties
- adds documentation for the missing class properties

References #14.
2017-07-12 09:45:08 -07:00
Andrey Lushnikov
60621b8815 Fix Click unit tests on Mac OS X
This patch brings screenDPI back in clicking equation, which was
regressed in afb096cfd7.
2017-07-11 22:35:22 -07:00
Aleksey
b77ae4b77c Properly cleanup FrameManager._frameIdToExecutionContextId. (#73) 2017-07-11 21:52:09 -07:00
Andrey Lushnikov
b0a2cf662e Roll chromium to r485143 2017-07-11 19:38:20 -07:00
Andrey Lushnikov
7765760186 [doclint] Start linting method arguments
This patch introduces a general Documentation.diff method, which
produces a diff of two documentations.

With this, the patch teaches documentation linter to lint method arguments.

References #14.
2017-07-11 16:43:41 -07:00
Pavel Feldman
afb096cfd7 Disable DOM domain after each operation. (#71)
It's very heavy to have DOM domain enabled. This patch keeps DOM domain disabled after each use.
2017-07-11 16:25:25 -07:00
Andrey Lushnikov
279cd4c9fb Remote Browser's remoteDebuggingPort option
This patch remove remoteDebuggingPort option. Instead, browser
is launched with '--remote-debugging-port=0' flag, letting browser
to pick any port. The puppeteer reads the port number from the
browser's stderr stream.

This change cuts average browser start time from 300ms to 250ms
on my machine. This happens since puppeteer doesn't have to probe
network once every 100ms, waiting for the remote debugging server to
instantiate.

Fixes #21.
2017-07-11 08:30:41 -07:00
Andrey Lushnikov
d120e7e426 properly cleanup exit process listener as browser closes 2017-07-11 08:11:16 -07:00
Andrey Lushnikov
b6d0ebfbf2 Run headless chromium with --hide-scrollbars
This patch runs chromium in headless mode with the --hide-scrollbars
flag so that it doesn't spoil screenshots.

Fixes #68.
2017-07-10 18:58:29 -07:00
Andrey Lushnikov
50d9c186b5 Change Page.navigate to return main resource response
This patch changes Page.navigate API:
- Page.navigate now resolves to the main page response
- Page.navigate throws errors if there's no main page response,
  e.g. in case of SSL errors, max navigation timeout,
  or invalid url.

This patch also adds httpsServer with a self-signed certificates
for the testing purposes.

Fixes #10.
2017-07-10 18:50:06 -07:00
JoelEinbinder
da0cde1b45 Implement Page.uploadFile (#61)
This patch implements `Page.uploadFile` method to support file upload inputs.
2017-07-10 11:21:46 -07:00
JoelEinbinder
739c1566a9 Add tests for all public methods on Page (#62) 2017-07-10 10:09:59 -07:00
Andrea Cardaci
ff4a389274 Fix watchdog timer cleanup (#64)
Fix a bug in f7cd004 which prevents the cleanup of the watchdog timer, thus keeping the Node.js process alive for this._maxTime msec no matter what.
2017-07-08 08:54:28 -07:00
Andrey Lushnikov
f7cd0048af Cleanup navigator logic
This patch cleans up navigator logic. (This is a result of a pair
programming with @pavelfeldman).
2017-07-07 15:46:05 -07:00
Aleksey
090ecfa6b9 Added frame.waitFor(selector) (#59)
This patch adds `frame.waitFor(selector)` method.

Fixes #42.
2017-07-08 01:39:02 +03:00
Andrey Lushnikov
34f043d821 Implement browser.stdout and browser.stderr streams
This patch adds browser.stdout and browser.stderr streams.

These streams allow to get the browser instance output, e.g.

```js
browser.stderr.pipe(process.stdout);
```
2017-07-07 20:49:17 +03:00
Andrey Lushnikov
c8664319ed Make browser._ensureChromeIsRunning idempotent
The _ensureChromeIsRunning should launch chrome only once
and return the same promise for all its clients.
2017-07-06 18:20:01 -07:00
Paul Irish
6c7ae41ae6 fix page.injectFile and add test. (#52)
This line within `injectFile` wasn't doing much of anything: 

```js
let expression = fs.readFile(filePath, 'utf8', (err, data) => callback({err, data}));
```

* That's fixed.
* A path error in examples/features.js is fixed.
* Test added for injectFile.
2017-07-07 02:09:23 +03:00
Andrey Lushnikov
19a8d74d3c Implement Body interface for both Request and Response
This patch partially implements Fetch API's [Body](https://developer.mozilla.org/en-US/docs/Web/API/Body)
interface for both Request and Response.

Fixes #26.
2017-07-06 12:17:01 -07:00
Andrey Lushnikov
64fed38c60 Rename Page.Events.Error into Page.Events.PageError
The 'error' event has a special treatment in Node:
https://nodejs.org/api/events.html#events_error_events

To avoid this, this patch renames the 'error' event into
the 'pageerror'.
2017-07-06 11:22:32 -07:00
Andrey Lushnikov
19e882f505 fix switch statement indentation in FrameManager 2017-07-06 10:46:19 -07:00
Andrey Lushnikov
773a09a8cf Add support for unserializable values in Page.evaluate
This patch adds support for unserializable return values in
Page.evaluate.

Currently, these values are:
- NaN
- Infinity
- -Infinity
- -0

Fixes #51.
2017-07-06 10:41:01 -07:00
Andrey Lushnikov
62111fbc08 Fix style after 9faecc2e 2017-07-05 19:07:33 -07:00
Andrey Lushnikov
9faecc2e67 Fix Page.setContent method
The patch fixes an unfortunate bug in Page.setContent method and
adds a test to cover it.

References #50.
2017-07-05 18:09:17 -07:00
Andrey Lushnikov
4fb7f7754c add a more clear message for protocol errors 2017-07-05 17:21:42 -07:00
Andrey Lushnikov
0d2c32e8cd Roll chromium to r484159 2017-07-05 17:02:58 -07:00
Paul Irish
2cd60c9e1e network manager: remove duplicated method (#48) 2017-06-30 08:26:36 -07:00
Andrey Lushnikov
9c138e9dba Support redirects in NewtorkManager
This patch adds support to redirects so that they will be reported
as a separate requests.

References #26.
2017-06-29 18:57:07 -07:00
Andrey Lushnikov
7f74daf62c Simplify NetworkManager's request/response management
This patch:
- drops Request dependency on NetworkManager
- drops Response dependency on NetworkManager
- drops requestIds from Request and Response objects
2017-06-29 18:18:06 -07:00
Andrey Lushnikov
3dfa688920 Simplify lib/Navigator.js 2017-06-29 12:28:05 -07:00
Andrey Lushnikov
4aa74cc7f8 cleanup Page.js from network leftovers after a35a21d 2017-06-29 12:00:19 -07:00
Andrey Lushnikov
a35a21dfaf Implement NetworkManager
This patch implements NetworkManager, which encapsulates all the
interaction with Network domain.

The NetworkManager also uses partial implementation of Request and
Response classes, defined in the Fetch API specification.

References #26
2017-06-29 11:49:56 -07:00
Patrick Hulce
4b0b81fd9b Add better network idle definition (#38)
This patch:
- Changes network idle promise to wait for 2 or fewer network requests for at least idleTime (defaults to 5s) before resolving.
- Adds timer cleanup to failure navigation case.
- Adds handling of webSocketClosed.
- Ignores unrecognized requestIds to avoid negative inflight requests.

References #10
2017-06-28 14:39:37 -07:00
Andrey Lushnikov
d5be1a6436 Introduce Page.Events.Request
This patch introduces the 'request' event which is fired when
page has initiated a request.

The event dispatches an instance of Request class.

References #26.
2017-06-28 01:42:42 -07:00
Andrey Lushnikov
7b59a89695 Implement Request object
This patch does a step towards Fetch API:
- implements Request object to some extend. The Request object will be
  sent in RequestWillBeSent event.
- implements InterceptedRequest which extends from Request and allows
  for request modification. The InterceptedRequest does not
  conform to Fetch API spec - there seems to be nothing related to
  amending in-flight request.
- adds test to make sure that request can change headers.

References #26
2017-06-28 01:41:42 -07:00
Andrey Lushnikov
5ed71fcb8f Test the 'networkidle' navigation logic
This patch adds a test to verify that navigation properly waits for the
network to become idle.

References #10
2017-06-27 22:02:46 -07:00
JoelEinbinder
d5a91650ae Implement Basic input API
This patch implements Basic Input api:
- Page.focus(selector) - focuses element with selector
- Page.click(selector) - clicks element with selector
- Page.type(text) - types text into a focused element

Fixed #43.
2017-06-27 18:27:22 -07:00
Andrey Lushnikov
3d90ea38a9 Implement Frame.evaluate
This patch implements Frame.evaluate method.

References #4.
2017-06-27 14:57:14 -07:00
Andrey Lushnikov
819fa355f4 Convert var's to let's
This patch:
- converts all var's to let's throughout the codebase
- enforces the let's over var's via the eslint rule
2017-06-22 14:58:39 -07:00
Pavel Feldman
cf35524285 Foramt JSDocs for 2 spaces 2017-06-21 14:11:52 -07:00
Pavel Feldman
437a93b26e Reformat code using 2 spaces 2017-06-21 14:11:52 -07:00
Pavel Feldman
bc0655b587 Extract basic in-flight counting navigator 2017-06-21 14:11:52 -07:00
Pavel Feldman
4761f13740 Inline helper eval functions 2017-06-21 14:11:52 -07:00
Pavel Feldman
84bc09bce1 Revert "Reformat codebase into 2-spaces"
This reverts commit d0d1ee303e41fe4ba762a031b78c3894edac52df.
2017-06-21 14:11:52 -07:00
Andrey Lushnikov
448ac4ce64 Reformat codebase into 2-spaces
This patch:
- reformats codebase to use 2-spaces instead of 4. This will
  align the project with other codebases (e.g. DevTools and Lighthouse)
- enables eslint indentation checking

References #19
2017-06-21 14:11:52 -07:00