Commit Graph

36 Commits

Author SHA1 Message Date
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
Andrey Lushnikov
0a190ebec9 Rename 'remoteDebuggingURL' into 'browserWSEndpoint' (#272) 2017-08-16 01:10:55 -07:00
Andrey Lushnikov
a424f5613a Introduce Puppeteer.connect method (#264)
This patch:
- refactors Connection to use a single remote debugging URL instead of a
  pair of port and browserTargetId
- introduces Puppeteer.connect() method to attach to already running
  browser instance.

Fixes #238.
2017-08-15 14:29:42 -07:00
Andrey Lushnikov
13e8580a34 Use puppeteer.launch instead of browser constructor (#255)
This patch:
- split browser launching logic from Browser into `lib/Launcher.js`
- introduce `puppeteer` namespace which currently has a single `launch`
  method to start a browser

With this patch, the browser is no longer created with the `new
Browser(..)` command. Instead, it should be "launched" via the
`puppeteer.launch` method:

```js
const puppeteer = require('puppeteer');
puppeteer.launch().then(async browser => {
  ...
});
```

With this approach browser instance lifetime matches the lifetime of
actual browser process. This helps us:
- remove proxy streams, e.g. browser.stderr and browser.stdout
- cleanup browser class and make it possible to connect to remote
  browser
- introduce events on the browser instance, e.g. 'page' event. In case
  of lazy-launching browser, we should've launch browser when an event
  listener is added, which is unneded comlpexity.
2017-08-14 18:08:06 -07:00
Andrey Lushnikov
4269f6a1bb Roll chromium to r493985 (#251)
This patch:
- rolls chromium to r493985
- migrates Browser.version() puppeteer method to use newly added
  Browser.getVersion() protocol method

References #227
2017-08-12 22:04:39 -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
JoelEinbinder
5d647bf1fa Use const a lot fo places (#188) 2017-08-02 12:06:47 -07:00
Andrey Lushnikov
a43c315214 Implement browser 'ignoreHTTPSErrors' option. (#177)
This patch implements Browser 'ignoreHTTPSErrors' option.

Fixes #84.
2017-08-01 15:17:57 -07:00
JoelEinbinder
2acfec0989 Slow mode (#173)
This patch introduces a `slowMo` browser option which
slows down puppeteer operations. Comes handy for debugging
scripts.
2017-07-31 18:47:56 -07:00
JoelEinbinder
b474a2d0d9 Mark options objects as optional (#170) 2017-07-30 13:46:56 -07:00
Alexei Filippov
83f4e43564 Clean up Browser annotations. (#138) 2017-07-25 20:39:50 -07:00
JoelEinbinder
615381c70e Remove browser.closePage. (#124)
Remove browser.closePage. Closes #116
2017-07-25 00:44:13 -07:00
Andrey Lushnikov
4af0911b90 Use more good flags to run chrome instance.
The switches are mostly borrowed from chromedriver launching code.
2017-07-20 12:20:10 -07:00
Andrey Lushnikov
21af495b65 Move screenshot task chain in Browser
Currently, it's impossible to do screenshots in parallel.
This patch:
- makes all screenshot tasks sequential inside one browser
- starts activating target before taking screenshot
- adds a test to make sure it's possible to take screenshots across
  tabs
- starts waiting for a proper page closing after each test. This might
  finally solve the ECONNRESET issues in tests.

References #89
2017-07-19 14:15:16 -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
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
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
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
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
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
Andrey Lushnikov
aaefec7868 Fix Travis-Ci tests
It turned out that the tip-of-tree chromium fails to start on Travis
because of two reasons:
- inability to run LinuxSUIDSandbox
- libnss3 library version being too small

Both problems happen because of the outdated "trusty" distribution
which is used on travis.

This patch:
- reverts the previous patch 9e6f779. Instead of introducing such
  a weird "api", both phantom_shim/runner.js and test/test.js no
  explicitly pass '--no-sandbox' flag to the browser
- updates the libnss3 lib on travis

Fixes #33
2017-06-21 14:11:52 -07:00
Andrey Lushnikov
7874108fda Fix running on Travis-Ci 2017-06-21 14:11:52 -07:00
Andrey Lushnikov
eb02af93b6 Improve error reporting when chrome fails to start
This patch starts throwing exception and dumping chromium stderr when
the browser fails to start.

References #33
2017-06-21 14:11:52 -07:00
Pavel Feldman
8e0a3ac6d9 Make InPageCallback async (#24)
Fixes #20
2017-06-21 14:11:52 -07:00
Andrey Lushnikov
ff2c3bbca9 Cleanup Page class
This patch removes unneeded dependency from Page
to Browser.
2017-06-15 21:35:31 -07:00
Andrey Lushnikov
67932b87c1 Drop the chrome-remote-interface dependency
This patch drops the chrome-remote-interface dependency and
introduces Connection class which handles all the communication
with remote target.

Closes #3
2017-06-14 15:45:59 -07:00
Andrey Lushnikov
ac3e76fb22 Cleanup typechecker errors
This patch cleans up different issues which were spotted by the
typechecker.
2017-06-11 23:10:33 -07:00
Andrey Lushnikov
1f51384918 Introduce Eslint to validate style
This patch introduces eslint and fixes multiple minor code
style issues.
2017-06-11 01:32:59 -07:00
Andrey Lushnikov
2b50d8cc32 Introduce utils/check_availability.js utility
This patch introduces check_availability.js utility which looks for
available chromium binaries for different revisions and platforms.

This patch also re-factors the chromium downloader scripts so that
it can operate different platforms.
2017-06-08 11:22:21 -07:00
Andrey Lushnikov
2cda8c18d1 Puppeteer: staging commit. 2017-05-11 00:06:41 -07:00