Commit Graph

395 Commits

Author SHA1 Message Date
Pavel Feldman
5068185d03 Don't ever enable DOM domain. ()
This patchs makes sure DOM domain is never enabled. The reasoning behind this is that
DOM domain is heavy-weight: it generates a lot of traffic over the protocol.

Drive-by: use Page.addScriptToEvaluateOnNewDocument instead of Page.addScriptToEvaluateOnLoad
2017-07-26 15:19:43 -07:00
Will Chen
7a482c5697 docs: fix broken links in API ()
This patch fixes links in api.md.
2017-07-26 15:06:23 -07:00
JoelEinbinder
2e6751d6f5 Trace only string method names () 2017-07-26 11:48:40 -07:00
JoelEinbinder
9363a15cce Small fixes to jsdoc ()
References .
2017-07-26 09:58:03 -07:00
JoelEinbinder
81d4b8f4f8 Document all options objects wherever they are used ()
This patch adds missing documentation for all the shortcut methods, such as
`page.evaluate` or `page.waitForSelector`.

closes 
2017-07-25 21:01:05 -07:00
Alexei Filippov
83f4e43564 Clean up Browser annotations. () 2017-07-25 20:39:50 -07:00
JoelEinbinder
aa28eb80f0 Wait for double raf after all mouse events. ()
This patch starts waiting for double raf after every mouse event.
It looks like a good enough workaround to make sure mouse events
are delivered.

The single raf might not be enough because browser might 'return' an already-prepared
frame for us without actually dispatching events.

Closes 
2017-07-25 17:03:13 -07:00
JoelEinbinder
1a50403090 fix linter ()
This patch fixes broken travis, caused by impatient merge of f455e3a1e
2017-07-25 16:47:49 -07:00
Pavel Feldman
f455e3a1e4 Remove NetworkManager usage from NavigatorWatcher () 2017-07-25 16:06:53 -07:00
JoelEinbinder
64968862db Implement mouse.click(x,y) ()
Closes 
2017-07-25 16:05:23 -07:00
JoelEinbinder
2081c12317 update package-lock.json () 2017-07-25 15:58:32 -07:00
Pavel Feldman
49e363c121 Mess with lusha's waitFor for fun. () 2017-07-25 15:57:31 -07:00
Pavel Feldman
4adf11427a Unconditionally update frame payload on navigation only. () 2017-07-25 14:58:10 -07:00
Pavel Feldman
eca0d7fe53 Simplify keyboard modifiers handling () 2017-07-25 14:35:03 -07:00
Pavel Feldman
0007809305 Move inner evaluate helpers into frame class. () 2017-07-25 14:30:04 -07:00
JoelEinbinder
4f5f1f6d77 Move missing methods from page onto frame. ()
Closes 
2017-07-25 11:37:46 -07:00
Andrey Lushnikov
b564029589 Improve documentation for the page.waitFor method.
Fixes .
2017-07-25 08:46:11 -07:00
JoelEinbinder
877f06aacb Remove userAgent getter ()
If needed, the user agent could be fetched via querying
`navigator.userAgent` in page.

Closes 
2017-07-25 02:01:10 -07:00
JoelEinbinder
615381c70e Remove browser.closePage. ()
Remove browser.closePage. Closes 
2017-07-25 00:44:13 -07:00
Andrey Lushnikov
d4c5aee5a8 Rename page.evaluateOnInitialized into page.evaluateOnNewDocument
This patch renames page.evaluateOnInitialized into
page.evaluateOnNewDocument to better align with the protocol and with
what the method is actually doing.

Fixes .
2017-07-25 00:17:56 -07:00
Andrey Lushnikov
5acd711b20 Remove InterceptedRequest.isHandled() method
This patch removes the InterceptedRequest.isHandled method. There's
always a single request interceptor who owns all the intercepted
requests and who know if they were handled.

References .
2017-07-24 23:37:28 -07:00
Andrey Lushnikov
efa33c37b3 Remove page.httpHeaders() getter
Remove the page.httpHeaders() method since it always returns the last
value of page.setHTTPHeaders().

References .
2017-07-24 23:35:10 -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 .
2017-07-24 21:43:54 -07:00
Andrey Lushnikov
236acec228 Remove Frame.isMainFrame()
This patch removes redundant frame.isMainFrame() method. The suggested
way to check for main frame is:

```js
frame === page.mainFrame()
```

Fixes .
2017-07-24 21:25:54 -07:00
Andrey Lushnikov
91cbe561ba Roll chromium to r488994
This patch rolls chromium past the r488926 which prevents chromium from
going to sleep on Mac OS X.

Fixes .
2017-07-24 18:28:34 -07:00
JoelEinbinder
a24cec20f9 Fix clicking offscreen horizontally ()
This patch starts clicking in the center of the element area which is
visible in a viewport.

Fixes .
2017-07-24 16:14:32 -07:00
Andrey Lushnikov
0a3125434e Refactor Frame.waitForSelector method
Refactor Frame.waitForSelector to make room for Frame.waitForFunction
implementation.
This patch:
- removes AwaitedElement class which proved to be confusing, and
  introduces a more straight-forward WaitTask.
- refactors the mutation observer to return true in case of successful
  waiting or false in case of timeout.

References 
2017-07-24 10:07:43 -07:00
Andrey Lushnikov
63e928f4cd Roll chromium to r488823 2017-07-24 01:13:49 -07:00
JoelEinbinder
fdaaa2c0e6 Inject file with sourceURL ()
This patch starts adding a sourceURL trailing comment to make stack traces
readable.
2017-07-23 09:56:35 -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
5757bc18f2 Rename 'maxTime' option of Page.navigate into 'timeout'
The motivation behind this rename is to name all the 'timeout' options
across methods similarly.

References .
2017-07-22 16:32:57 -07:00
JoelEinbinder
98ee35655f Mouse ()
This patch:
- adds Mouse class which holds mouse state and implements mouse primitives,
such as moving, button down and button up.
- implements high-level mouse api, such as `page.click` and `page.hover`.

References , References 
2017-07-21 20:29:31 -07:00
JoelEinbinder
eb2cb67b0e Remove keyboard.type and keyboard.press ()
This patch removes keyboard.type and keyboard.press methods. The motivation
behind this is to keep only low-level API in the `keyboard` namespace.
2017-07-21 20:00:09 -07:00
Andrey Lushnikov
794f9bb82a [doclint] move all the lint checks in the lint.js
This patch cleans up Documentation.js file by moving all the checks
into the lint.js

Drive-by: fix the Page.waitFor test.
2017-07-21 14:21:17 -07:00
Andrey Lushnikov
dc032b42b9 Introduce polymorphic page.waitFor method
This patch:
- introduces page.waitForSelector to wait for the selector to appear
- introduces polymorphic page.waitFor method, which accepts
either string (and in this case is a shortcut for page.waitForSelector)
or number (and in this case it's a promisified timeout).

References .
2017-07-21 12:54:04 -07:00
Andrey Lushnikov
1891a49962 fix documentation for Page.waitFor 2017-07-21 12:14:12 -07:00
Andrey Lushnikov
1f954fa7ed Implement timeout option for page.waitFor
This patch implements timeout option for page.waitFor. The function
will throw if the selector doesn't appear during timeout milliseconds
of waittime.

References , .
2017-07-21 12:07:48 -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
0960dc38d1 Automatically generate table-of-contents for markdown
This patch teaches doclint to regenerate table of contents
automatically whenever it's needed.

This patch:
- splits lint.js into lint.js and cli.js
- teaches cli.js to generate table-of-contents
- removes the test for table-of-contents errors from doclint
- adds a test for doclint failing to parse object destructuring in
  method parameters.
2017-07-21 11:12:05 -07:00
Andrey Lushnikov
52de75742b Implement visible option for Page.waitFor method
This patch adds a 'visible' option to the Page.waitFor method, making
it possible to wait for the element to become actually visible.

References , .
2017-07-21 10:01:19 -07:00
Andrey Lushnikov
139b9e9b6d Get rid of page.emulate() / page.emulatedDevices() methods
This patch:
- gets rid of `page.emulate` and `page.emulatedDevices`
  methods. Instead, it is suggested to use `page.setViewport()`
  and `page.setUserAgent()` methods.
- moves DeviceDescriptors to the top level of the puppeteer so that
  it is convenient to require them.
- improves on documentation to describe the suggested emulation
  approach.

References .
2017-07-20 23:53:06 -07:00
Andrey Lushnikov
76ac3bded5 Convert DevicesDescriptors into puppeteer format
This patch converts lib/DevicesDescriptors from a devtools front-end
format into a puppeteer format.

This patch does this via introducing a scripts utils/fetch_devices.js
which grabs devices from upstream of DevTools Front-end and
converts them into puppeteer devices.

References .
2017-07-20 17:49:15 -07:00
Andrey Lushnikov
ffc5a8ae4f Add missing test asset 2017-07-20 16:05:17 -07:00
Andrey Lushnikov
f5215b2ed0 Restart browser once in a while during unit testing
The unit testing on mac is unreliable, making the last tests to hang.
This seems to be related to the upstream bug: crbug.com/741689

For now, this patch restarts the browser in the middle of unit testing.
This should be reverted once the upstream is fixed.

References .
2017-07-20 15:29:09 -07:00
Andrey Lushnikov
42edc3108a [emulation] fix touch emulation
This patch:
- fixes touch emulation
- adds tests to cover basic Page.emulate

References .
2017-07-20 12:22:34 -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
a981594b1d Revert node's scrolling into view in page.click()
This change was not intentional in e33a8f818c
2017-07-20 00:53:14 -07:00
Andrey Lushnikov
e33a8f818c Support HEADLESS env variable for unit tests
This patch makes it possible to run unit tests in non-headless
mode with the following command:

```
HEADLESS=false npm run unit
```
2017-07-19 19:36:22 -07:00
Andrey Lushnikov
a63a0198de Implement waitFor which survives navigation ()
This patch implements page.waitFor method which survives navigation.

References .
2017-07-19 19:04:51 -07:00
JoelEinbinder
2fb1d9afca Fix comments on WebPage.js ()
This patch fixes bad indentation in WebPage comments
2017-07-19 14:44:47 -07:00