Commit Graph

109 Commits

Author SHA1 Message Date
Mathias Bynens
b2552e4f7d
chore: restore page.setUserAgent test (#5868)
Ref. #5781.
2020-05-14 10:24:30 +01:00
Jack Franklin
4fdb1e3cab
chore: add Prettier (#5825) 2020-05-07 12:54:55 +02:00
Mathias Bynens
862eea850e
chore: disable flaky setUserAgent test in Firefox (#5780) 2020-04-30 12:10:28 +02:00
Jack Franklin
1ccfbcb684
chore: enforce naming of errors in catch blocks (#5763) 2020-04-28 15:16:28 +02:00
Jack Franklin
e3922ea1f3
chore: enforce consistent spacing around object curlys (#5700)
The codebase was incredibly inconsistent with the use of spacing around
curly braces, e.g.:

```
// this?
const a = {b: 1}
// or?
const a = { b: 1 }
```

This extended into import statements also. Google's styleguide is no
spacing, so we're going with that.
2020-04-21 10:40:04 +01:00
Jack Franklin
17cd8703f9
chore: migrate unit tests to Mocha (#5600)
Rather than maintain our own test runner we should instead lean on the community and use Mocha which is very popular and also our test runner of choice in DevTools too.

Note that this commit doesn't remove the TestRunner source as it's still used for other unit tests, but they will be updated in a future PR and then we can remove the TestRunner.

The main bulk of this PR is updating the tests as the old TestRunner passed in contextual data via the `it` function callback whereas Mocha does not, so we introduce some helpers for the tests to make it easier.
2020-04-09 07:56:25 +02:00
Maja Frydrychowicz
0b1a9ceee2
chore: Replace Juggler with Firefox Nightly in CI (#5395)
Fixes #5150.
2020-02-20 13:57:15 +01:00
den
5e63254e62 chore: fix typo in test name (#5217) 2019-12-11 15:41:41 +01:00
Mathias Bynens
eddb23b521
chore: update URLs (#5185) 2019-11-26 13:12:25 +01:00
Mathias Bynens
81d2600236 feat(chromium): roll Chromium to r705776 (#5058)
This corresponds to Chromium 79.0.3942.0.

This roll includes:

- Support CSS media feature emulation in CDP
  https://chromium-review.googlesource.com/c/chromium/src/+/1821608
- Implement timezone ID verification
  https://chromium-review.googlesource.com/c/chromium/src/+/1822557
- Allow aria-hidden objects into the browser-side ax tree
  https://chromium-review.googlesource.com/c/chromium/src/+/1760862
- Remove pre-BlinkGenPropertyTrees codepaths (affects screenshot clipping)
  https://chromium-review.googlesource.com/c/chromium/src/+/1752244
- Terminate some asynchronous waiting commands on cross-process navigation
  https://chromium-review.googlesource.com/c/chromium/src/+/1766001/21#message-a6a61261b97ffca6ecb180c0a2303b538f7a6476

Per upstream Chromium changes, `page.screenshot` now clips elements to the viewport. This matches the clipping behavior of elements in inner scrollers (i.e., document and overflow scroll clipping now work the same).
2019-10-23 11:41:44 +02:00
Mathias Bynens
f504c042c0 test: mark Page.close test as failing in Firefox (#4929) 2019-09-12 14:29:40 -07:00
Yury Semikhatsky
e0c8d46af1 fix: abort page.waitForRequest/Response when page closes (#4865)
We'd like to pass an abortion signal inside Helper.waitForEvent in order to interrupt it when browser/page closes. Several approaches have been considered:

1. Pass CDPSession instance as a another parameter to the helper method and listen to Disconnected event on it. It would introduce undesired dependency on the session object.
2. Listen to the CDPSession closure at the call sites (e.g. waitForRequest) and pass an abortion promise which would be fulfilled when such event is fired. The listeners would have to be removed from the session on successful completion of waitForEvent so we'd have to pass some kind of DisposablePromise which would be disposed during cleanup. Such parameter looked somewhat hairy.
3. Create DisconnectPromise on CDPSession. One potential risk with that is all chained promises would hang around until the event is fired which might inadvertently cause memory leaks. On the other hand, adding such promise to Promise.race will remove dependency as soon as the race is finished. So this is the approach we're taking with one tweak: the promise is created locally inside Page. 

Ideally the disconnectPromise would throw when the session is closed but it may lead to uncaught promise errors if all chained promises are resolved, to avoid that the promise is resolved with an Error and Helper.waitForEvent throws it later.

Fix #4733
2019-08-21 10:26:48 -07:00
Andrey Lushnikov
b6b29502eb
feat(chromium): roll Chromium to r686378 (#4841)
This roll includes:
- https://crrev.com/685152 - [DevTools] Do not debug worker shadow pages
- https://crrev.com/683391 - [CSP] Check inline script CSP in prepare-a-script
- https://chromium-review.googlesource.com/c/v8/v8/+/1707331 - Ignore returnByValue when serializing caught value in promise rejections.
2019-08-14 21:43:18 -07:00
Andrey Lushnikov
90df69cf77
fix(page): do evaluations with one roundtrip (#4539)
This patch teaches page.evaluate to do 1 hop instead of 2 hops.
As a result, things such as `page.select` will not throw an
unfortunate exception when they schedule a navigation.

Fix #4537
2019-06-07 13:46:43 -07:00
Sergio M
60249e0bc2 fix: Page.setContent working with unicode strings (#4433)
Fix `page.setContent` with unicode strings that exceeds the range of a 8-bit byte.

This patch implements decoding part of the [MDN's solution #4 for the "unicode problem"](https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#Solution_4_%E2%80%93_escaping_the_string_before_encoding_it).

Since we rely on node.js buffer to encode into base64, we don't have troubles with base64 encoding, so it is left as-is.

Fixes #4424
2019-05-18 17:15:16 +03:00
Andrey Lushnikov
b3027a6e16
test(page): make sure exposeFunction works with complex args (#4411) 2019-05-09 18:02:46 -07:00
Andrey Lushnikov
13f73b5b3a
feat(chromium): roll Chromium to r656675 (#4389)
This roll includes:
- https://chromium-review.googlesource.com/c/v8/v8/+/1569425 - [debug] Introduce GetCreationContext to debug API

Fix #4263
2019-05-06 00:22:18 -07:00
Andrey Lushnikov
27c9f754b1
fix(page): teach page.setContent to work with tricky content (#4366)
Fix #4364
2019-04-30 00:35:05 -07:00
Andrey Lushnikov
e3abb0aa32
feat(puppeteer): introduce puppeteer.errors and puppeteer.devices (#4312)
These getters are introduced as a more convenient substitute for
a `require('puppeteer/Errors')` and
`require('puppeteer/DeviceDescriptors')`.

This way we can make cross-browser story nicer - a single require
of `puppeteer` or `puppeteer-firefox` fully defines Puppeteer
environment.
2019-04-19 15:33:06 -07:00
Andrey Lushnikov
0c4d53b293
test: add a test for queryObjects with navigation (#4303)
References #4263
2019-04-18 10:03:06 -07:00
Andrey Lushnikov
19606a3b79
fix: cache disabling should stick when toggling request interception (#4260)
This patch:
- refactors `NetworkManager`/`FrameManager` so that they enable all the
relevant domains themselves. This is a preparation for OOPIF support and
migration onto fetch domain.
- moves `networkManager` ownership into `FrameManager`. This way it's clear who owns what.
- stops enabling Security domain: it saves quite some traffic over
websocket since it no longer sends annoying "SecurityStateChanged" events.
Instead, use `Security.setIgnoreCertificateErrors` method.
- consolidates network cache state in network manager. This even fixes a
bug with caching and request interception interop.
2019-04-10 00:42:42 -04:00
Andrey Lushnikov
9d31068225
feat(chromium): roll Chromium to r648643 (#4256)
This roll includes:
- https://crrev.com/648335 -
[DevTools] Send DevTools request ID through URLLoader
- https://crrev.com/648360 -
[DevTools] Add renderer request ID to requestIntercepted

References #3471
2019-04-08 12:11:35 -07:00
Andrey Lushnikov
6474b3ffe0
test: ensure Page.setBypassCSP works with iFrames (#4155) 2019-03-11 17:56:32 -07:00
Andrey Lushnikov
e8a49633d9
test: cleanup tests (#4078)
- move Connection test into CDPSession.spec.js
- remove a nasty test that was reaching into implementation details
2019-02-26 20:36:55 -08:00
Andrey Lushnikov
3bea5d6017
feat(firefox): implement browserContext.overridePermissions (#4060) 2019-02-22 23:59:32 -08:00
Andrey Lushnikov
5c818368a5
feat(firefox): implement page.exposeFunction (#4052) 2019-02-22 00:04:25 -08:00
Andrey Lushnikov
3b180923a6
refactor(firefox): migrate onto Juggler flatten protocol (#4033)
Juggler now implements the same "flatten" protocol as CDP.
This patch:

* copies `Connection.js` from original Puppeteer (with a few renames, e.g. `CDPSesssion` -> `JugglerSession`).
* migrates code to support protocol-level sessions
2019-02-19 13:20:39 -08:00
Andrey Lushnikov
6350cf0892
fix(firefox): report more console messages (including warnings) (#4005) 2019-02-13 23:22:45 -08:00
Andrey Lushnikov
0b40d04b99
feat(firefox): support running beforeunload hooks when closing (#4003) 2019-02-13 22:16:12 -08:00
Andrey Lushnikov
e3b76b2beb
feat(firefox): support consoleMessage.location() (#4002) 2019-02-13 19:56:56 -08:00
Andrey Lushnikov
1890dc04ba
feat(firefox): Page.waitForRequest/Page.waitForResponse (#3989)
Drive-by: refactor `Request.frame()` tests into a separate test suite.
2019-02-12 19:10:14 -08:00
Andrey Lushnikov
b82cc150d1
feat(firefox): support Page.setJavascriptEnabled (#3970)
This patch implements:
- Page.setJavascriptEnabled
- Page.setCacheEnabled
2019-02-08 20:57:16 -08:00
Andrey Lushnikov
fc18a79e99
feat(firefox): support Page.setUserAgent method (#3968) 2019-02-08 19:53:27 -08:00
Andrey Lushnikov
cfefd611b8
feat(firefox): support target.opener() and page.on('popup') (#3966) 2019-02-08 19:21:54 -08:00
Andrey Lushnikov
0cf6ab68e7
feat(firefox): support page.browserContext() (#3965) 2019-02-08 18:58:40 -08:00
Andrey Lushnikov
6b18e8cef5
feat(firefox): introduce async stacks for Puppeteer-Firefox (#3948)
This patch refactors Puppeteer-Firefox code to declare public
API in `/lib/api.js` and use it to setup async stack hooks
over the public API method calls.
2019-02-07 15:18:43 -08:00
Andrey Lushnikov
6887ad881a
chore: further unify Puppeteer-Firefox tests with Puppeteer (#3931)
This patch:
* unifies assets between tests
* enables a few puppeteer tests on Puppeteer-Firefox

Drive-by: beautify failing output of `expect.toEqual` matcher.

References #3889
2019-02-06 13:49:14 -08:00
Andrey Lushnikov
14fb3e38db
chore(firefox): mark all Puppeteer tests that are failing on FF (#3924)
This patch:
- introduces new testRunner methods `addTestDSL` and `addSuiteDSL`
  to add annotated test / suite.
- introduces new test/suite declaration methods: `it_fails_ffox` and
  `describe_fails_ffox`. These are equal to `it`/`describe` for chromium
  tests and to `xit`/`xdescribe` for firefox.
- marks all unsupported tests with `it_fails_ffox`
- adds a new command-line flag `'--firefox-status'` to `//test/test.js`.
  This flag dumps current amount of tests that are intentionally skipped
  for Firefox.

End goal: get rid of all `it_fails_ffox` and `describe_fails_ffox`
tests.

Drive-By: remove cookie tests  "afterEach" hook that was removing
cookies - it's not needed any more since every test is run in a
designated browser context.

References #3889
2019-02-05 22:32:41 -08:00
Andrey Lushnikov
86783c2495
chore(firefox): run all tests without "UnhandledPromiseRejection" error (#3922)
This aligns all Puppeteer tests so that they never throw the
"UnhandledPromiseRejection" when run with Puppeteer-Firefox.

With this patch, the `npm run funit` passes 275 of 460 Puppeteer tests.

References #3889.
2019-02-05 19:49:47 -08:00
Andrey Lushnikov
69c434af75
test(firefox): further unify Puppeteer-Firefox and Puppeteer tests (#3894)
This patch:
- changes Puppeteer-Firefox plumbing of defaultBrowserOptions to align
  with the way we do it for Puppeteer.
- plumbs puppeeteer-dependent Errors and DeviceDescriptors down to every
  test.
- unifies a few tests between Puppeteer-Firefox and Puppeteer.

**Note:** in future, we should expose errors as `puppeteer.errors` and
device descriptors as `puppeteer.devices` to make it easy to pass around
Puppeteer/Puppeteer-Firefox instance.

References #3889.
2019-02-02 18:49:12 -07:00
Andrey Lushnikov
47fbb117f5
test(firefox): add more Puppeteer-Firefox tests to Puppeteer (#3892)
References #3889
2019-02-02 12:55:15 -07:00
Andrey Lushnikov
a2f1e2774a
fix: ignore console messages from destroyed execution contexts (#3866)
Fix #3865
2019-01-30 16:19:02 -08:00
Andrey Lushnikov
a064a6341b
feat(page): introduce page.setDefaultTimeout (#3854)
Method `page.setDefaultTimeout` overrides default 30 seconds timeout
for all `page.waitFor*` methods, including navigation and waiting
for selectors.

Fix #3319.
2019-01-28 17:16:12 -08:00
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
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
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
6656519560
test: split out dialog tests (#3586) 2018-11-20 20:18:57 -08:00