Commit Graph

561 Commits

Author SHA1 Message Date
Andrey Lushnikov
678b8e85ad
fix(page): use secondary DOMWorld to drive page.select() (#3809)
This patch starts creating secondary DOMWorld for every connected
page and switches `page.select()` to run inside the secondary world.

Fix #3327.
2019-01-22 17:55:33 -05:00
Andrey Lushnikov
9fd4b67d0c
fix(requestinterception): filter out "intervention" header (#3814)
Fixes #3798
2019-01-20 00:02:13 -05:00
Andrey Lushnikov
4ac00caf9d
refactor: split out DOMWorld from Frame (#3780)
This patch splits out `IsolatedWorld` class from Frame.
The `IsolatedWorld` abstraction is an execution context
with a designated set of DOM wrappers.

References #2671
2019-01-15 17:21:23 -08:00
Joel Einbinder
4e1e2fb701 fix(screenshot): round the clip dimensions (#3778) 2019-01-15 14:34:31 -08:00
Andrey Lushnikov
04fbbd7cf0
fix(network): relax request matching heuristic (#3775)
Drop requirement for matching "origin" and "content-type" headers
in requests and request interceptions. This way javascript redirects
that use form submission start working.

Fix #3684.
2019-01-15 11:37:53 -08:00
Andrey Lushnikov
e8bb26eb95
refactor: split out classes into files (#3773)
New files:
- LifecycleWatcher
- JSHandle
2019-01-14 20:34:50 -08:00
Andrey Lushnikov
4e9e3bc614
refactor: consolidate all events in Events.js (#3772)
This will allow us to break all dependency cycles that were forcing
us to put many things in a single file (e.g. ExecutionContext and
ElementHandle).
2019-01-14 19:57:05 -08:00
Andrey Lushnikov
9083c111ca
fix(frames): make sure evaluation does not hang in detached iframes (#3770)
Fix #3261
2019-01-14 17:23:53 -08:00
Brian Schiller
7fabf32172 feat(executioncontext): warn on nested js handle (#3591)
ExecutionContext.evaluateHandle accepts arguments that are either
serializable, or JSHandles. A potential confusion is that it *does not*
accept arguments that *contain* JSHandles.

This patch adds a log message warning when it encounters that situation.

Fixes #3562
2019-01-14 14:30:50 -08:00
Andrey Lushnikov
d346cb57b4
chore: cleanup puppeteer.connect({browserURL}) (#3766)
This patch:
- renames `browserUrl` into `browserURL`
- cleans up some code
- adds tests for error handling

References #3537
2019-01-14 14:30:03 -08:00
Łukasz Fiszer
15af75f9a2 feat(launcher): add browserUrl option to puppeteer.connect (#3558)
The `browserURL` option allows to connect to a browser that exposed it's remote debugging protocol on a known port.

Fixes #3537
2019-01-14 13:23:34 -08:00
Joel Einbinder
96adedf54f fix(screenshots): throw on 0x0 screenshots (#3756)
Fix #2672
2019-01-11 15:24:43 -08:00
Joel Einbinder
29a2438534 chore(types): Upgrade TypeScript to 3.2.2 (#3754) 2019-01-10 22:56:39 -08:00
Ram Dobson
f73197385a fix(page): page.waitForFunction should work with multiline strings (#3727)
Fixes #3723
2019-01-10 18:18:28 -08:00
Andrey Lushnikov
89fc2adff5
fix(page): consoleMessage.location() should work with workers (#3752)
This patch:
- refactors consoleMessage.location() implementation to
make it work for workers
- re-writes tests to avoid 5 second delay
2019-01-10 18:05:28 -08:00
Tom P
0c867631b0 feat(page): introduce consoleMessage.location() (#3365)
This patch adds a new consoleMessage.location() method that returns console message origins.

Fixes #3029
2019-01-10 16:51:13 -08:00
Andrey Lushnikov
1899e7931c
feat: enable Network Service by default (#3738)
References #3471.
2019-01-09 15:47:08 -08:00
Andrey Lushnikov
c86bc0fa9f
feat(chromium): roll Chromium to r620317 (#3732)
This roll includes:
- https://crrev.com/619087 - DevTools: support interception for file: schema
- https://crrev.com/616936 - Complete the screen capture color space plumbing

This should allow us to switch to network service by default.

Note: We now have to force a specific color space since https://crrev.com/616936
tries to pick the system one.
2019-01-08 12:55:40 -08:00
Andrey Lushnikov
3d82465f66
fix(page): fix repetitative setContent calls (#3666)
Fix #3665.
2018-12-13 13:33:42 -08:00
Andrey Lushnikov
8aaca4eb1e
feat(page): introduce "Popup" event (#3661)
This patch adds a new "popup" event for page.
"Popup" event is fired whenever page opens another page with
given opener.
2018-12-12 17:09:42 -08:00
Andrey Lushnikov
c90392bdf5
feat: introduce page.browserContext() (#3655) 2018-12-12 15:08:31 -08:00
Andrey Lushnikov
927d0f443b
feat(page): support waitUntil option for page.setContent (#3557)
This patch teaches `page.setContent` to await resources in
the new document.

**NOTE**: This patch changes behavior: currently, `page.setContent`
awaits the `"domcontentloaded"` event; with this patch, we can now await
other lifecycle events, and switched default to the `"load"` event.

The change is justified since current behavior made `page.setContent`
unusable for its main designated usecases, pushing our client
to use [dataURL workaround](https://github.com/GoogleChrome/puppeteer/issues/728#issuecomment-334301491).

Fixes #728
2018-11-20 15:32:46 -08:00
Andrey Lushnikov
e2e43bc23d
fix(page): navigating 11 pages simultaneously should not throw warning (#3560)
NavigatorWatcher subscribes to Connection to get a `Disconnected` event,
causing us to hit the default max of 10 listeners constraint.

Technically we don't leak anything here and can safely bump
the maxListenersCount to Infinity.

However, we conveniently have `CDPSession`, and
can re-dispatch the event on it and keep the safety check in place.
2018-11-20 14:21:13 -08:00
Andrey Lushnikov
95a19c74bc
fix(page): dispatch errors into page (#3550)
Errors thrown on the node side of the `page.exposeFunction` callback
should be dispatched into the page.

Fixes #3549
2018-11-15 14:51:34 -08:00
Joel Einbinder
568734386d fix(types): fix parameters where they disagree with the api (#3525) 2018-11-12 12:59:21 -08:00
Joel Einbinder
79ec7a3fe5 fix(types): fix return types where JSDoc and api.md disagree (#3512) 2018-11-07 22:48:43 -08:00
Joel Einbinder
9ba3261571 feat(accessibility): snapshot the accessibility tree (#3470)
This adds `page.accessibility.snapshot()`. It serializes and returns the accessibility tree for the page. By default, uninteresting nodes are filtered out of the snapshot.

fixes #2033
2018-11-01 18:54:51 -07:00
Andrey Lushnikov
3596c5f7e2
fix(page.evaluate): better function serialization (#3480)
References #1665
2018-11-01 16:43:21 -07:00
Andrey Lushnikov
2a88690582
fix(launcher): add flags to improve reliability (#3474)
- The "IPC flooding protection" was added in https://crrev.com/604305
and should be disabled for our automation usescases.
- The other two flags are coming from https://github.com/smooth-code/jest-puppeteer/issues/137
2018-11-01 15:41:08 -07:00
Andrey Lushnikov
3dd5c28f90
fix(pipe): dispatch "disconnected" event when browser is terminated (#3472) 2018-10-31 16:31:29 -07:00
Zeev Rosental
81edbbb58e fix(clicking): handle negative area results in computeQuadArea (#3413)
This patch fixes a case in which computeQuadArea calculates the area size correctly, but returns the area as a negative number.
This occurs when DOM.getContentQuads returns quads in a specific order.

E.g. the array: [ { x: 463, y: 68.5 },{ x: 437, y: 68.5 },{ x: 437, y: 94.5 },{ x: 463, y: 94.5 } ] will receive area size of -676.
2018-10-25 11:41:37 -07:00
Joel Einbinder
d025d1f959 fix(csscoverage): don't prematurely disable the CSS domain (#3418)
CSS stylesheets can still be parsed and added events emitted during the CSS.stopRuleUsageTracking call. It needs to be awaited before calling CSS.disable, otherwise the text content of those style sheets will be unavailable.
2018-10-16 16:55:17 -07:00
Joel Einbinder
6ac66c3547 feat: browser.waitForTarget (#3356)
This adds `browser.waitForTarget` and `browserContext.waitForTarget`. It also fixes a flaky test that was incorrectly expecting targets to appear instantly.
2018-10-09 14:16:53 -07:00
Joel Einbinder
07febb637c fix: add missing location property to some key descriptors (#3354) 2018-10-05 12:35:10 -07:00
Joel Einbinder
cd54ce388e fix(types): upgrade node types to 8.10.34 (#3341) 2018-10-03 16:59:49 -07:00
Joel Einbinder
c237947b32 chore(types): upgrade to TypeScript 3.1.1 (#3331)
This upgrades  us to TypeScript 3.1.1, which fixes some build failures. Annoyingly TypeScript does a better job of checking `process.stdio`, which exposes that the DefinitelyTyped definition for it is wrong. See https://github.com/DefinitelyTyped/DefinitelyTyped/issues/11587. I'll look into submitting a patch for that later.
2018-10-02 13:38:06 -07:00
Łukasz Usarz
842fee860b fix(page): full page screenshot when defaultViewport is null (#3306)
Fixes #3104
2018-09-27 10:50:21 -07:00
Andrey Lushnikov
4e48dfc7a1
feat(launcher): add experimental "transport" option to pptr.connect (#3265)
This patch:
- adds experimental "transport" option to pptr.connect
- uses "transport" option to make sure Puppeteer-Web works with
  Target.exposeDevToolsProtocol

Drive-by: add `browser.target()` to access browser target.
2018-09-20 11:55:23 -07:00
Andrey Lushnikov
5acf953104
feat(frame): introduce Frame.goto and Frame.waitForNavigation (#3276)
This patch introduces API to manage frame navigations.
As a drive-by, the `response.frame()` method is added as a shortcut
for `response.request().frame()`.

Fixes #2918.
2018-09-20 11:31:19 -07:00
Andrey Lushnikov
0b9d8a6271
feat: async stacks for all "async" public methods (#3262)
This patch traces all public async methods and wraps them
in a helper method that tags the sync stack trace.

Later on, if the method call throws an exception, we add
a captured stack trace to the original stack trace with the "--ASYNC--"
heading.

An example of a stack trace:

```
Error: net::ERR_ABORTED at http://localhost:8907/empty.html
    at navigate (/Users/lushnikov/prog/puppeteer/lib/Page.js:622:37)
    at process._tickCallback (internal/process/next_tick.js:68:7)
  -- ASYNC --
    at Page.<anonymous> (/Users/lushnikov/prog/puppeteer/lib/helper.js:147:27)
    at fit (/Users/lushnikov/prog/puppeteer/test/page.spec.js:546:18)
    at process._tickCallback (internal/process/next_tick.js:68:7)
```
2018-09-19 13:54:58 -07:00
Andrey Lushnikov
9223bca964
refactor: move navigation management to FrameManager (#3266)
This patch:
- moves implementation of page.goto and page.waitForNavigation
  into FrameManager. The defaultNavigationTimeout gets moved to
  FrameManager as well.
- moves NavigatorWatcher into FrameManager to avoid circular dependency

References #2918
2018-09-19 13:12:28 -07:00
Andrey Lushnikov
b97bddf8e5
refactor: unify response tracking in page.goto and waitForNavigation (#3258)
This patch unifies logic in response trackign in page.goto and
page.waitForNavigation.

As a drive-by, we now make sure that we return the right response
for the right frame. This will come handy for future frame navigation
API.

References #2918
2018-09-18 00:15:50 +01:00
Andrey Lushnikov
7f00860abd
fix(browserfetcher): Fix windows fetching (#3256)
Since r591479 windows archives are uploaded with a different
name.
2018-09-17 18:15:08 +01:00
Andrey Lushnikov
d547b9d24a
fix(browser): browser closing/disconnecting should abort navigations (#3245)
Fixes #2721.
2018-09-14 19:44:54 +01:00
Andrey Lushnikov
f0beabd22a
chore: drop DEBUG for public API calls (#3246)
This proved to be useless: we've never used it since we
released the initial version of puppeteer more than a year ago.
2018-09-14 18:23:30 +01:00
Łukasz Usarz
d929f7e213 fix: set JPG background to white when omitBackground option is used (#3240)
Fixes #3234
2018-09-14 11:03:33 +01:00
Andrey Lushnikov
7ec0801729
fix: expect Network.responseReceived event is never dispatched (#3233)
Fixes #2888.
2018-09-12 22:08:32 +01:00
Andrey Lushnikov
9c4b6d06e2
refactor: use browser-compliant interface of 'ws' (#3218)
Bundled version of Puppeteer should rely on native WebSocket.

Luckily, 'ws' module supports the same interface as the native
browser websockets. This patch switches WebSocketTransport to
use the browser-compliant interface of 'ws'.

After this patch, I was able to bundle Puppeteer for browser
using the following config in `package.json`:

```json
"browser": {
  "./lib/BrowserFetcher.js": false,
  "ws": "./lib/BrowserWebSocket",
  "fs": false,
  "child_process": false,
  "rimraf": false,
  "readline": false
}
```

where `./lib/BrowserWebSocket` is:

```js
module.exports = WebSocket;
```

and the bundling command is:

```sh
$ browserify -r ./index.js:puppeteer > ppweb.js
```

References #2119
2018-09-11 18:41:28 +01:00
Andrey Lushnikov
1b2c8113ba
refactor: move Connection to use ConnectionTransport (#3217)
Currently connection assumes that transport is a websocket
and tries to handle websocket-related errors.

This patch:
- moves ConnectionTransport interface to use callbacks instead
  of events. This way it could be used in browser context as well.
- introduces WebSocketTransport that implements ConnectionTransport
  interface for ws.

This is a preparation step for 2 things:
- exposing `transport` option in the `puppeteer.connect` method
- better support for `browserify`

References #2119
2018-09-07 21:36:16 +01:00
Andrey Lushnikov
f230722ff0
refactor: avoid dynamic requires in lib/ folder (#3208)
This patch removes all dynamic requires in Puppeteer. This should
make it much simpler to bundle puppeteer/puppeteer-core packages.

We used dynamic requires in a few places in lib/:
- BrowserFetcher was choosing between `http` and `https` based on some
  runtime value. This was easy to fix with explicit `require`.
- BrowserFetcher and Launcher needed to know project root to store
  chromium revisions and to read package name and chromium revision from
  package.json. (projectRoot value would be different in node6).
  Instead of doing a backwards logic to infer these
  variables, we now pass them directly from `//index.js`.

With this patch, I was able to bundle Puppeteer using browserify and
the following config in `package.json`:

```json
  "browser": {
    "./lib/BrowserFetcher.js": false,
    "ws": "./lib/BrowserWebSocket",
    "fs": false,
    "child_process": false,
    "rimraf": false,
    "readline": false
  }
```

(where `lib/BrowserWebSocket.js` is a courtesy of @Janpot from
https://github.com/GoogleChrome/puppeteer/pull/2374/)

And command:

```sh
$ browserify -r puppeteer:./index.js > ppweb.js
```

References #2119
2018-09-06 20:33:41 +01:00