Commit Graph

435 Commits

Author SHA1 Message Date
Tomáš Trnka
856c431914 feat(Network): introduce response.securityDetails() method (#1880)
This patch:
- introduces `SecurityDetails` class that exposes a set of fields that describe properties of secure connection
- introduces method `response.securityDetails()` that returns an instance of `SecurityDetails` object.
2018-02-13 11:26:18 -08:00
travch
f3ba436239 Fix: Remove key codes from _pressedKeys Set after keyboard.up() is called (#1928)
keyboard.down() and keyboard.up() both use the _pressedKeys Set, however keyboard.down() adds and searches for the key code, whereas keyboard.up() attempts to delete based on the key rather than the key code.

Fixes #1901
2018-02-12 17:25:38 -08:00
Drew Diamantoukos
b275e66594 chore: Spelling and Markdown Consistency (#1998)
- Adding missing language tags to markdown code blocks.
- Fixed various spelling mistakes my IDE complained to me about.
2018-02-08 22:59:46 -05:00
Andrew Collins
ac1b9a0eb0 feat(Page): add setCacheEnabled(enabled) to Page object (#1609)
This change adds in the `Page.setCacheEnabled(enabled)` method to toggle ignoring cache for each request.

Fixes #1556.
2018-02-08 00:58:48 -05:00
Andrey Lushnikov
a363a733b7
feat: Introduce BrowserFetcher class (#1983)
This patch introduces `BrowserFetcher` class that manages
downloaded versions of products.

This patch:
- shapes Downloader API to be minimal yet usable for our needs. This
  includes removing such methods as `Downloader.supportedPlatforms` and
  `Downloader.defaultRevision`.
- makes most of the fs-related methods in Downloader async. The only
  exception is the `Downloader.revisionInfo`: it has stay sync due to the
  `pptr.executablePath()` method being sync.
- updates `install.js` and `utils/check_availability.js` to use new API
- finally, renames `Downloader` into `BrowserFetcher`

Fixes #1748.
2018-02-07 12:31:53 -05:00
Andrey Lushnikov
ecc3adc279
feat(Response): add Response.fromCache / Response.fromServiceWorker (#1971)
This patch:
- introduces `test/assets/cached` folder and teaches server to cache
  all the assets from the folder
- introduces `test/assets/serviceworkers` folder that stores all the
  service workers and makes them register with unique URL prefix
- introduces `Response.fromCache()` and `Response.fromServiceWorker()`
  methods

Fixes #1551.
2018-02-05 17:59:07 -05:00
Alix Axel
660b65780f feat(Frame): add click(), focus(), hover(), tap() and type() (#1970)
This patch adds frame shortcuts to drive input:
- `Frame.click()`
- `Frame.focus()`
- `Frame.hover()`
- `Frame.tap()`
- `Frame.type()`
2018-02-05 17:58:03 -05:00
Alix Axel
bc6902623a fix: allow timeouts of be 0 (#1964)
This patch fixes timeouts for `puppeteer.launch` and `page.waitForFunction`
to be `0`.

Fixes #1960 .
2018-02-05 17:42:54 -05:00
Andrey Lushnikov
37a1e17461
chore: remove unused parameter in EmulationManager (#1968) 2018-02-05 15:51:43 -05:00
Yaniv Efraim
189deb84c0 feat(Frame): add Frame.evaluateHandle (#1885)
This patch adds Frame.evaluateHandle method. The method is a shortcut
for frame.executionContext().evaluateHandle.

Fixes #1051
2018-01-24 21:16:01 -08:00
Alix Axel
5175d8e692 fix(Page): fix Page.select() behavior to be on par with docs (#1886)
This PR fixes lost functionality that is no longer on-par with the documentation for `Page.select`, namely:

> `...values` <...string> Values of options to select. If the `<select>` has the `multiple` attribute, all values are considered, **otherwise only the first one is taken into account**.

I've also added an accompanying test for this use case.
2018-01-24 21:12:27 -08:00
JoelEinbinder
f2b6016354 chore: switch to npm from yarn (#1878)
This patch:
- migrates CI to use NPM
- drops lockfiles (`yarn.lock`). Lockfiles are ignored by package
  managers when the package is installed as a dependency, so this makes CI closer to the 
  installation our clients run.
2018-01-22 17:11:10 -08:00
Abel Toledano
b61e67d001 feat: add slowMo option to puppeteer.connect (#1864)
This patch introduces a `slowMo` option to the `puppeteer.connect` method. The option
is similar to the one in `puppeteer.launch` and is used to slow down the connection.
2018-01-22 16:45:46 -08:00
Ram Dobson
cb684ebbc4 feat(Page): introduce Page.waitForXPath (#1767)
This patch:
- introduces `page.waitForXPath` method
- introduces `frame.waitForXPath` method
- amends `page.waitFor` to treat strings that start with `//` as xpath queries.

Fixes #1757.
2018-01-22 15:16:20 -08:00
Ian Hunter
59f6d42610 feat: add Page.Events.DOMContentLoaded (#1730)
Fixes #1580
2018-01-16 23:22:44 -08:00
yujiosaka
c866c175f8 fix: page.goto should support pages with self requests (#1391) (#1781)
This patch fixes `page.goto` for websites that re-request document URL with javascript.

Fixes #1391.
2018-01-12 00:16:36 -08:00
Andrey Lushnikov
5368051610
feat: expose raw devtools protocol connection (#1770)
feat: expose raw devtools protocol connection

This patch introduces `target.createCDPSession` method that
allows directly communicating with the target over the
Chrome DevTools Protocol.

Fixes #31.
2018-01-10 19:33:22 -08:00
Radu Aron
ec8e40f1cb feat(Page): Add global navigation timeout setting (#1728)
This patch introduces `page.setDefaultNavigationTimeout` method to override the 
default 30 seconds navigation timeout.

Fixes #1514
2018-01-10 13:04:01 -08:00
Andrey Lushnikov
9634d13be2
fix: requestInterception should play nicely with canceled redirects (#1758)
Since interception events and `loadingFailed` events come from
different processes and are not serialized, we might get `loadingFailed` event and a subsequent outdated `requestIntercepted`.

Short-term, this patch stops assuming that interception events are
aligned with `loadingFailed`.

Long-term, this will be resolved as @caseq completes network
servicification effort in chromium.

Fixes #880.
2018-01-09 22:59:21 -08:00
yujiosaka
f6b7c13316 chore(install): mention yarn along npm in the error message (#1759) 2018-01-09 21:56:04 -08:00
yujiosaka
c29822d663 feat: Attribute network requests to frames (#1646)
This patch introduces `request.frame()` method that returns the frame that
initiated request.

Fixes #1579
2018-01-09 18:47:21 -08:00
yujiosaka
5843f6f775 fix: setRequestInterception and setExtraHTTPHeaders not working together (#1734)
This patch starts lowering header keys while generating request hashes.

Fixes #1729.
2018-01-09 16:52:28 -08:00
Darío Kondratiuk
dcc1b24395 chore(Page): Add missing return comments in addScriptTag and addStyleTag (#1753) 2018-01-09 16:31:41 -08:00
刘祺
71089b0802 feat: teach Downloader to respect redirects (#1741)
This patch adds support for redirects to downloader.

Fixes #1740
2018-01-08 18:10:13 -08:00
刘祺
d7d9623740 fix: downloader host fault tolerance (#1739)
Strip trailing slashes from Downloader download host.
2018-01-08 18:08:27 -08:00
JoelEinbinder
972f44d328 fix: avoid calling jsonValue from waitFor (#1746)
If the success value of `waitForFunction` was not serializable, checking whether it was truthy with `.jsonValue()` might fail. Now I check whether it was truthy inside the page.

Fixes #1737.
2018-01-08 14:14:41 -08:00
yujiosaka
8e9c54a789 feat: introduce browser.userAgent() (#1716)
The patch introduces browser.userAgent() method to retrieve
default browser user agent.

Fixes #1706.
2018-01-05 10:14:30 -08:00
JoelEinbinder
05b1aca21e feat: support JSHandles for page.waitFor* calls (#1712)
This patch:
- teaches page.waitFor* methods to accept JSHandles
- starts returning JSHandles from page.waitFor* calls. 

BREAKING CHANGE: this patch starts allocating `JSHandle`/`ElementHandle` instances for every call to `page.waitFor*` functions. These handles should be disposed manually to avoid memory consumption.

Fixes #1703, fixes #1654, fixes #1724.
2018-01-04 14:49:13 -08:00
Andrey Lushnikov
24354a4879
feat: implement CSS Coverage (#1714)
This patch adds two new methods to the `page.coverage` namespace:
- `page.coverage.startCSSCoverage()` - to initiate css coverage
- `page.coverage.stopCSSCoverage()` - to stop css coverage

The coverage format is consistent with the JavaScript coverage.
2018-01-03 18:21:40 -08:00
JoelEinbinder
f183664d0f feat: rename page.xpath into page.$x, return an array of elements (#1713)
Fixes #1705.
2018-01-03 15:37:08 -08:00
Andrey Lushnikov
d062381978
feat: Implement JavaScript Coverage (#1673)
This patch introduces a new `page.coverage` namespace with two methods:
- `page.coverage.startJSCoverage` to initiate JavaScript coverage
  recording
- `page.coverage.stopJSCoverage` to stop JavaScript coverage and get
  results
2018-01-02 19:53:53 -08:00
yujiosaka
35a5d8bba9 chore(NavigationWatcher): correct closure annotation (#1658) 2017-12-27 20:00:37 -07:00
JoelEinbinder
8a40cd5eef feat(Launcher): allow the default arguments to be overridden (#1623)
This patch:
- adds `puppeteer.defaultArgs()` method to get default arguments that are used to launch chrome
- adds `ignoreDefaultArgs` option to `puppeteer.launch` to avoid using default puppeteer arguments

Fixes #872
2017-12-19 17:51:21 -08:00
Audrius Jakumavicius
f8040cb2a2 feat(pdf): add headerTemplate and footerTemplate to available PDF options (#1625)
This patch allows specifying header and footer templates for PDF printing.

Fixes #373.
2017-12-19 16:54:34 -08:00
JoelEinbinder
60ba8c3af9 feat: add page.xpath (#1620)
This patch adds xpath support with the following methods:
- page.xpath
- frame.xpath
- elementHandle.xpath

Fixes #537
2017-12-19 16:23:45 -08:00
Andrey Lushnikov
b73737302a
fix: convert all getters to methods (#1621)
The patch converts all the getters in the codebase into the methods.
For example, the `request.url` getter becomes the `request.url()`
method.

This is done in order to unify the API and make it more predictable.
The general rule for all further changes would be:
- there are no getters/fields exposed in the api
- the only exceptions are "namespaces", e.g. `page.keyboard`

Fixes #280.

BREAKING CHANGE:
This patch ditches getters and replaces them with methods throughout
the API. The following methods were added instead of the fields:
- dialog.type()
- consoleMessage.args()
- consoleMessage.text()
- consoleMessage.type()
- request.headers()
- request.method()
- request.postData()
- request.resourceType()
- request.url()
- response.headers()
- response.ok()
- response.status()
- response.url()
2017-12-18 17:05:57 -08:00
Jih-Chi Lee
18d5cfa269 fix(Cookies): disallow setting cookies in 'about:blank' page (#1567)
This patch asserts that no cookies are set on `about:blank` and `data:` urls.

References #1411
2017-12-16 01:17:20 -08:00
Andrey Lushnikov
4eaf52fa1d
feat(Browser): introduce browser.process() variable (#1581)
This patch adds a `browser.process()` getter to expose the child process
with running browser.

Fixes #1539.
2017-12-11 12:11:12 -08:00
JoelEinbinder
a164524c72 feat(Connection): nicer stack traces on protocol errors (#1383)
This rewrites protocol errors to have the stack trace of the call site.
2017-12-08 19:05:46 -08:00
Andrey Lushnikov
391d1abaa7
chore: generalize node6 transpilation (#1560)
This patch unifies node6 transpilation:
- instead of generating multiple top-level directories, prefixed with
  `node6-`, all transpiled code gets placed under single `node6/` folder
- transpilation doesn't change require paths of transpiled modules any
  more
2017-12-08 15:14:28 -08:00
Andrey Lushnikov
9a5086847c
refactor: move ChromiumDownloader under lib/ (#1554)
This patch:
- renames ChromiumDownloader into just Downloader (this is in
  preparation for different products download)
- moves Downloader from utils/ to lib/. This unifies all of the
  production-critical code in the lib/.

Drive-by: make Downloader a regular class.
2017-12-08 13:39:13 -08:00
Mickael GOETZ
16320b7ac2 fix(Page.screenshot): prioritize screenshot type over filename extension (#1526)
For the `page.screenshot` command, this patch starts prioritizing `options.type` option over the type inferred from `options.path`

Fixes #1492.
2017-12-04 14:04:36 -08:00
Mehdi Raash
90f799cc95 chore: remove excessive whitespace (#1375) 2017-12-03 23:03:28 -08:00
Slohmes
5a6488883a feat(Tracing): allow custom tracing categories (#1439)
This patch adds `categories` option to the `page.tracing.start` method
that allows to override default tracing categories. 

References #1300, #854
2017-12-03 18:36:34 -08:00
Andrey Lushnikov
2becd156d0
feat(Chromium): roll Chromium to r518818 (#1455)
This roll includes:
- crrev.com/518362 DevTools: override referrer policy for the request if
  referer header is overriden

Fixes #1373.
2017-11-23 07:42:48 +03:00
Trent Willis
770c17b2ea feat(Frame): implement frame.content and frame.setContent methods (#1447)
This refactors the page.content and page.setContent methods to be defined on the Frame class. This allows access from the Page still but also on all frames.

Fixes #754
2017-11-23 05:44:33 +03:00
Andrey Lushnikov
88eaede5ad
fix(page): fix "timeout: 0" to actually disable any navigation timeout (#1435)
Since non-promise values always win the `Promise.race`, we shouldn't
return `null` for timeout promise in NavigationWatcher.

Instead, we can return a promise that never resolved. It should be
GC'd later with the navigation watcher itself.

Fixes #1417.
2017-11-21 08:21:25 +03:00
Andrey Lushnikov
cafd040bf2
fix(Network): be prepared to miss requestWillBeSent events (#1420)
With the addition of `browser.targets()` api, we now can connect to
in-flight targets.

For Puppeteer, it means that it can "miss" certain events happenning
while it wasn't attached to the target.

This patch:
- fixes this problem with NetworkManager, preparing it for the
  missed `requestWillBeSent` event.
- adds a new test to ensure that not a single unhandled promise
  rejection has happened during test execution.

Fixes #1363.
2017-11-20 15:59:07 -08:00
Andrey Lushnikov
ea70ac9003
fix(Page.goto): check navigation completeness on frame detachment (#1419)
Currently, the NavigatorWatcher ensures that all the frames in the
frame subtree reach the desired lifecycle events state.

For this to be fully correct, NavigatorWatcher should also check
navigation status whenever frames are detached.
2017-11-20 14:47:11 -08:00
Andrey Lushnikov
6512ce768d
fix(Frame): postpone evaluations until execution context gets created (#1415)
In Blink, frames don't necesserily have execution context all the time.
DevTools Protocol precisely reports this situation, which results in
Puppeteer's frame.executionContext() being null occasionally.

However, from puppeteer point of view every frame will have at least a
default executions context, sooner or later:

- frame's execution context might be created naturally to run frame's
  javascript
- if frame has no javascript, devtools protocol will issue execution
  context creation

This patch builds up on this assumption and makes frame.executionContext()
to be a promise.
As a result, all the evaluations await for the execution context to be created first.

Fixes #827, #1325

BREAKING CHANGE: this patch changes frame.executionContext() method to return a promise.
To migrate onto a new behavior, await the context first before using it.
2017-11-18 16:27:52 -08:00
Andrey Lushnikov
90ca007367
fix(Launcher): handle SIGHUP signal (#1405)
The SIGHUP signal is sent whenever the controlling terminal is closed.

On Windows, SIGHUP is emulated by libuv, and will be the only signal we
receive before the application will be terminated.

This patch starts handling SIGHUP in the same way we handle SIGTERM.

Fixes #1367.
2017-11-16 19:28:32 -08:00
Octavian Cioaca
a350e89381 chore(Browser): fix jsdoc in Browser.create method (#1403) 2017-11-16 16:28:52 -08:00
Andrey Lushnikov
cc0c461ea8
fix(Launcher): handle SIGTERM by default (#1402)
SIGTERM signal is widely used to notify application that it will be shut down.

This patch starts listening to SIGTERM event to gracefully retire
chromium instance.

References #1047.
2017-11-16 14:26:32 -08:00
Christopher Dieringer
b0b22199f9 fix(ElementHandle.screenshot): account for scroll (#1323)
Currently, `elementHandle.screenshot` passes bounding box into the `page.captureScreenshot` 
method.
This is wrong since `captureScreenshot` accepts viewport, not bounding box.

This patch uses layout metrics to convert bounding box into viewport.

Fixes #1315.
2017-11-10 16:02:52 -08:00
Andrey Lushnikov
2c8f658815
fix(Navigation): wait for lifecycle events for the frame subtree (#1356)
Currently, we wait only for the main frame to reach the desired
lifecycle state.

This patch starts waiting until all the frames reach the desired
lifecycle state.

Fixes #1173.
2017-11-10 15:44:14 -08:00
JoelEinbinder
f8d19e79e7 fix(Page.waitForSelector): "visible" option should check parent visibility (#1354)
This patch starts checking for boundingClientRect to make sure that the
element is visible.
2017-11-10 15:44:01 -08:00
Andrey Lushnikov
44d1e834a4
fix(Navigation): correctly wait for navigation in Page.goto (#1355)
This patch:
- starts persisting lifecycle state for every frame
- migrates NavigationWatcher to rely on these lifecycle events
- refactors Page.goto to properly return navigation errors

Fixes #1218.
2017-11-10 15:33:14 -08:00
Alix Axel
7d18275fb9 Test: add tests to cover clicking checkbox (#1125)
This patch adds tests to make sure clicking both checkbox and its label
works.

These are regression tests to cover the upstream fix, rolled in #1299.
2017-11-07 20:38:22 -08:00
Andrey Lushnikov
cbe3dc58a2
Revert "feat(Page): teach Page.setContent to wait for resources to load (#1152)" (#1312)
This reverts commit 80ee469429.

Lifecycle events are not ready yet to support the setContent scenario.
The prerequisite for this is
https://chromium-review.googlesource.com/c/chromium/src/+/747805 that
might not land soon due to technical concerns.
2017-11-07 14:18:05 -08:00
JoelEinbinder
b58d319926 fix(Page.click): throw a meaningful message for invisible elements (#1309)
This patch starts throwing a meaningful error message when trying to click the hidden
node.

References #1294
2017-11-07 13:54:40 -08:00
JoelEinbinder
3cb0f1af34 fix: make exposeFunction work for frames (#1295)
This patch fixes page.exposeFunction method so that it
adds exposed binding to all existing frames.

Fixes #690
2017-11-07 13:26:23 -08:00
Schelkun
77f585298f feat(Page): introduce Page bringToFront method (#1252)
This patch introduces Page.bringToFront method to activate tabs.

Fixes #1244
2017-11-07 13:17:36 -08:00
Robert Sköld
cc5e8a9bd4 fix(Page.type): Add assertion to page.type() (#1301)
This patch starts throwing a nice error when `page.type` is called
with non-existent selector.
2017-11-07 03:07:51 -08:00
Xingan Wang
8e445734c6 feat(Frame): reject error for addScriptTag/addStyleTag (#1287)
fix #1221
2017-11-06 22:04:40 -08:00
Andrey Lushnikov
5e154dc835
fix(Page.select): assert all values are of type "string". (#1280)
This patch starts asserting that all values are of type "string".

The alternative approach to cast values to strings
might yield a hard-to-debug errors.

Fixes #1276.
2017-11-03 19:20:12 -07:00
Adi Prasetyo
03fefb53f8 feat(browser): add browser.disconnected event (#960)
This patch adds a 'disconnected' event for the browser. The event is issued
when the "browser" loses connection to the chrome process.

References #952
2017-11-03 18:46:17 -07:00
Andrey Lushnikov
88ba52a363
refactor: use Page.getFrameTree instead of Page.getResourceTree (#1275)
This patch starts using Page.getFrameTree instead of
Page.getResourceTree.

The resource tree is experimental, whereas the frame tree is not.
2017-11-03 18:37:21 -07:00
Xingan Wang
e0f5b93923 feat(Frame): addStyleTag and addScriptTag now return ElementHandles.
This patch teaches `page.addStyleTag` and `page.addScriptTag` to return ElementHandles
to the added tags.

Fixes #1179.
2017-11-03 00:05:38 -07:00
Andrey Lushnikov
ac55e69676
feat(Chromium): roll chromium to r513435. (#1259)
This roll brings in a bunch of important patches:
- crrev.com/512647 Changed headless browser profile dir to use Default profile path
- crrev.com/512760 DevTools: stop idleness detector when pending navigation commits
- crrev.com/512905 DevTools: introduce Page.getFrameTree
- crrev.com/513373 DevTools: report loaderId in the lifecycle events
- crrev.com/513419 DevTools: introduce Page.setLifecycleEventsEnabled
- crrev.com/513422 DevTools: return loaderId from Page.navigate

Fixes #921 

BREAKING CHANGE:

Headless user profile structure is changing. Custom profiles set with --user-data-dir flag will no longer be read in Chrome 63 and will have to be recreated.

Alternatively, you can migrate old headless profile to a new structure. if you stored your profile in `<profile>` folder, you would run the following bash commands:

```bash
cd <profile>
mkdir Default
mv * Default
```

Full headless-dev PSA announcement: https://groups.google.com/a/chromium.org/forum/#!msg/headless-dev/asX8WgktXIE/zTUfmHDcAQAJ
2017-11-02 13:26:21 -07:00
Suvrat Jain
fede2643ac feat(Frame): introduce Frame.select
This patch adds `Frame.select` method that does the same functionality as
former `Page.select`, but on a per-frame level.

The `Page.select` method becomes a shortcut for the ÷main frame's select.

Fixes #1139
2017-11-01 22:06:04 -07:00
Andrey Lushnikov
f5bb333cd0
fix: support PlzNavigate in puppeteer. (#1239)
This patch migrates puppeteer to support PlzNavigate chromium
project.

As a consequence of this patch, we no longer wait for both
requestWillBeSent and requestIntercepted events to happen. This should
resolve a ton of request interception bugs that "hanged" the loading.

Fixes #877.
2017-11-01 14:04:10 -07:00
Andrey Lushnikov
b9266c74f8
feat(Page): rename Page.getMetrics into Page.metrics (#1240)
BREAKING CHANGE: method page.getMetrics() got renamed into
page.metrics().
2017-11-01 13:39:31 -07:00
Andrey Lushnikov
9f071bf411
fix(Navigation): do not race with security error for navigation (#1237)
Currently, NavigationWatcher listens to lifecycle events from Page
domain and security events from Security domain.

However, the events are dispatched from different processes in browser:
- Page's lifecycle events are dispatched from renderer process
- Security events are dispatched from browser process

This makes for the undefined order between events and results in
NavigationWatcher reporting different failuer messages, based on
the event order.

This patch stops relying on security errors in navigation watcher and
instead switches to request failure codes for the main resource.

Fixes #1195
2017-11-01 13:28:00 -07:00
AlexChung1995
e70f98ddb9 feat(Page.select): return selected options from Page.select (#1099)
This patch teaches Page.select to return an array of actually selected options.
If no option is selected, an empty array will be returned.
2017-10-31 21:47:52 -07:00
Manoj Patel
9f19641a3d chore: Fix typo in comment for Events (#1234) 2017-10-31 16:10:18 -07:00
Andrey Lushnikov
c9a26e11f1
fix(ElementHandle): teach ElementHandle to work with shadowdom (#1227)
Elements in shadow dom erroneously considered that they were detached
from document.

This patch starts using `Element.isConnected` instead of
`document.contains()` call.

Fixes #1061.
2017-10-31 12:02:16 -07:00
Adam Stankiewicz
5ffbd0d221 feat(ElementHandle): add ElementHandle.$ and ElementHandle.$$ (#1151)
This patch adds `ElementHandle.$` and `ElementHandle.$$` methods to query nested
elements.

Fixes #508
2017-10-27 02:08:58 -07:00
JoelEinbinder
655b94db47 fix(touch): requestAnimationFrame before sending tap (#1142)
This patch adds a work-around for the upstream bug, issuing double-raf before emulating touch event.

References #673
2017-10-26 14:53:50 -07:00
Andrey Lushnikov
ab9b34cd5d fix(Launcher): force-kill chrome on process exit and interruption (#1155)
This patch starts force-killing chromium regardless of custom userdata
directory when the node process exits.

References #1047
2017-10-24 16:05:12 -07:00
Andrey Lushnikov
b9ab6fe4bb fix(interception): Disable newtork caching when intercepting (#1154)
Request interception might not work properly if caching is enabled.
2017-10-24 15:14:25 -07:00
Andrey Lushnikov
ce005d480c feat(Chromium): Roll chromium to r511134 (#1153)
This roll includes:
- crrev.com/510651 that changes request interception methods in protocol
- s/Page.setRequestInterceptionEnabled/Page.setRequestInterception

BREAKING CHANGE

Page.setRequestInterceptionEnabled is renamed into
Page.setRequestInterception.
2017-10-24 14:45:03 -07:00
Andrey Lushnikov
80ee469429 feat(Page): teach Page.setContent to wait for resources to load (#1152)
This patch adds "options" parameter to the `page.setContent` method. The
parameter is the same as a navigation parameter and allows to specify
maximum timeout to wait for resources to be loaded, as well as to
describe events that should be emitted before the setContent operation
would be considered successful.

Fixes #728.
2017-10-24 13:57:39 -07:00
Andrey Lushnikov
f38c8bb17b feat(Page.goto): support multiple events in waitUntil option (#1147)
This patch adds support to multiple events that could be passed inside
navigation methods:
- Page.goto
- Page.waitForNavigation
- Page.goForward
- Page.goBack
- Page.reload

Fixes #805
2017-10-24 10:05:15 -07:00
Andrey Lushnikov
ef369e5d5d feat(Page.goto): add a 'domcontentloaded' option to the Page.goto (#1145)
This patch adds a new `domcontentloaded` option to a bunch of navigation
methods:
- Page.goto
- Page.waitForNavigation
- Page.goBack
- Page.goForward
- Page.reload

Fixes #946.
2017-10-24 00:35:18 -07:00
Andrey Lushnikov
ce8a952044 refactor: migrate NavigatorWatcher to lifecycle events (#1141)
This patch:
- migrates navigation watcher to use protocol-issued lifecycle events.
- removes `networkIdleTimeout` and `networkIdleInflight` options for
  `page.goto` method
- adds a new `networkidle0` value to the waitUntil option of navigation
  methods

References #728.

BREAKING CHANGE:

As an implication of this new approach, the `networkIdleTimeout` and
`networkIdleInflight` options are no longer supported. Interested
clients should implement the behavior themselves using the `request` and
`response` events.
2017-10-23 18:10:59 -07:00
JoelEinbinder
126ab7b90e feat(keyboard): Accept codes (#1116)
BREAKING CHANGE:

This patch lets key names be code in addition to key. When specifying a code, the proper text is generated assuming a standard US keyboard layout. e.g Digit5 -> "5" or "%" depending on Shift.

* location is now specified. #777

* Using unknown key names now throws an error. #723

* Typing newlines now correctly presses enter. #681
2017-10-23 12:43:45 -07:00
Andrey Lushnikov
bcc969ccc4 feat(interception): Implement request.mockResponse method (#1064)
feat(interception): Implement request.respond method

This patch implements a new Request.respond method. This
allows users to fulfill the intercepted request with a hand-crafted
response if they wish so.

References #1020.
2017-10-20 16:55:15 -07:00
Andrey Lushnikov
5c92ba222a fix(page.evaluate): jsonValue should ignore toJSON property (#1098)
Currently, JSHandle.jsonValue() is implemented as in-page JSON.stringify
call and consequent JSON.parse in node. This approach proved to be
unfortunate for automation purposes: if page author overrode the
Object.prototype.toJSON method, then it's harder for puppeteer to
interact with the page.

This patch switches JSHandle.jsonValue to use protocol serialization
that ignores toJSON property. THis also changes the `page.evaluate`
behavior since it is based on JSHandle.jsonValue().

Fixes #1003.

BREAKING CHANGE:
`page.evaluate` no longer calls toJSON when generating return value.
For the old behavior, do JSON.parse/JSON.stringify manually:

```js
const json = JSON.parse(await page.evaluate(() => JSON.stringify(obj)));
```
2017-10-20 10:45:49 -07:00
Andrey Lushnikov
4f64dfd993 feat(Request): allow aborting intercepted requests with custom reasons (#1080)
This patch adds optional parameter to the `request.abort()` method
that specifies abort reason.

References #1020.
2017-10-18 00:26:48 -07:00
Christian Davis
b3857bd690 fix(page): page.close() assert that connection is not closed (#1038) 2017-10-17 19:24:34 -07:00
JoelEinbinder
32398d11bd feat(Browser): introduce Browser.pages() (#554)
This patch:
- introduces Target class that represents any inspectable target, such as service worker or page
- emits events when targets come and go
- introduces target.page() to instantiate a page from a target

Fixes #386, fixes #443.
2017-10-17 19:14:57 -07:00
Andrey Lushnikov
273c733237 feat(Request): introduce Request.failure() method (#1065)
Similarly to the `request.response()` method, this patch adds
`request.failure()` method that returns error details for the failed
requests.

Fixes #901.
2017-10-17 17:48:04 -07:00
JoelEinbinder
2b7951473d feat(Browser): make browser.close() to always terminate remote browser
This patch:
- changes `browser.close` to terminate browser.
- introduces new `browser.disconnect` to disconnect from a browser without closing it

This patch: fixes #918, fixes #989 

BREAKING CHANGE:
`browser.close()` will always close a browser, even if it was initialized with
`puppeteer.connect`. To disconnect from a remote browser, use `browser.disconnect()` instead.
2017-10-17 15:35:00 -07:00
JoelEinbinder
6a8865cd85 feat(keyboard): make keyboard.down generate input event by default (#1016)
This patch starts generating input events for `keyboard.down`, addressing bullet 2 of
#723. With this patch, there's no longer any difference between `keboard.press('a')` and
`keyboard.press('a', {text: 'a'})`.

BREAKING CHANGE:
`keyboard.down('a')` starts generating input event (wasn't the case before).

References #723
2017-10-13 15:22:55 -07:00
Andrey Lushnikov
a02347e3ef feat(Page): implement page.setOfflineMode (#1032)
This patch implements page.setOfflineMode method.

Fixes #63.
2017-10-13 14:41:39 -07:00
Christian Davis
8511db957f feat(page): waitForSelector hidden option (#967)
This patch adds a 'hidden' option for the `page.waitForSelector` method.
2017-10-13 09:11:11 -07:00
JoelEinbinder
8f430fb23d fix(ElementHandle.boundingBox): account for margin, padding, and border in element.boxModel (#1017)
This patch starts relying on border quad to compute element's bounding box.

Fixes #1010
2017-10-12 17:53:59 -07:00
Sam Verschueren
c310f139a0 feat(Frame): Support options in addScriptTag and addStyleTag (#996)
This patch:
- deprecates injectFile as it was confused with the addScriptTag
- accepts an options object in addScriptTag which supports properties url, path and content.
- accepts an options object in addStyleTag which supports properties url, path and content.

Fixes #949.

BREAKING CHANGE:
- the addStyleTag/addScriptTag have changed;
- the injectFile was removed in favor of (addStyleTag({path:}).
2017-10-12 01:26:44 -07:00
JoelEinbinder
0426e3c068 Roll chromium to 508268 (#1019)
This gets us:

- Plural metrics names https://crrev.com/507885
- TargetInfoChanged on URL changes https://crrev.com/508049
- Sending proper resource types for requests https://crrev.com/667504

Fixes #734
2017-10-12 01:17:06 -07:00
JoelEinbinder
c893bf3684 fix(input) Send .code with keyboard events (#1015)
This patch starts sending proper `.code` field with emulated keyboard events.

References #777.
2017-10-11 18:09:43 -07:00