Commit Graph

983 Commits

Author SHA1 Message Date
Mathias Bynens
11ff374ca3
chore: drop Node.js v6 support (#5045)
Node.js v6 was end-of-life'd in April, 2019, with AWS Lambda prohibiting updaets to the Node.js v6 runtime since June 30, 2019.

This makes it quite safe for us to remove the Node 6 support from the repository.
2019-10-16 17:00:20 +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
Yury Semikhatsky
498492d4a3 test: add a test for errors inside promise (#4838)
The bug was fixed upstream in V8 and rolled into chromium at r686227.
This adds a test.

Fix #4651
2019-08-15 12:03:48 -07:00
Andrey Lushnikov
417981aafa
fix(firefox): fix cookies in default browser context (#4850)
This patch adds tests and fixes the nodejs part of the problem.
The issue will be fixed once we roll a new version of Firefox.

References #4470
2019-08-15 11:52:02 -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
01b888049e
test(firefox): disable BigInt tests for Firefox (#4849)
Juggler doesn't yet support BigInt transferring.
2019-08-14 17:49:42 -07:00
Andrey Lushnikov
f595bc0b67
test: fix tests to work on node6 (#4851)
Our magical node6 transpiler can't handle object spreads :(

Drive-by: use "includes" instead of "startsWith" for devtools URL
since I remember that it used to be "chrome-devtools://", and somehow
I saw it as "devtools://" somewhere.
2019-08-14 17:49:12 -07:00
Andrey Lushnikov
0e0a67916d
feat(chromium): roll Chromium to r682225 (#4844)
This roll includes:
- https://crrev.com/681997 - Turn on default SiteInstance by default.

The SiteInstance by default was breaking "devtools: true" option, so
there's a new feature we disable now by default.

This keeps pressuring us towards OOPIF support since that's an
inevitable future.
2019-08-14 15:25:55 -07:00
Andrey Lushnikov
d687c81cd5
chore(flakiness-dashboard): skip API Coverage for realz (#4843) 2019-08-13 16:23:41 -07:00
Andrey Lushnikov
763e3901d9
chore(flaky): save build result (#4819) 2019-08-08 20:53:12 -07:00
Andrey Lushnikov
f753ec6b04
chore(testrunner): distinguish between TERMINATED and CRASHED (#4821)
`testRunner.run()` might have 4 different outcomes:
- `ok` - all non-skipped tests passed
- `failed` - some tests failed or timed out
- `terminated` - process received SIGHUP/SIGINT while testrunner was running tests. This happens on CI's under certain circumstances, e.g. when
  VM is getting re-scheduled.
- `crashed` - testrunner terminated test execution due to either `UnhandledPromiseRejection` or
  some of the hooks (`beforeEach/afterEach/beforeAll/afterAll`) failures.

As an implication, there are 2 new test results: `terminated` and `crashed`.
All possible test results are:
- `ok` - test worked just fine
- `skipped` - test was skipped with `xit`
- `timedout` - test timed out
- `failed` - test threw an exception while running
- `terminated` - testrunner got terminated while running this test
- `crashed` - some `beforeEach` / `afterEach` hook corresponding to this
test timed out of threw an exception.

This patch changes a few parts of the testrunner API:
- `testRunner.run()` now returns an object `{result: string,
terminationError?: Error, terminationMessage?: string}`
- the same object is dispatched via `testRunner.on('finished')` event
- `testRunner.on('terminated')` got removed
- tests now might have `crashed` and `terminated` results
- `testRunner.on('teststarted')` dispatched before running all related
`beforeEach` hooks, and `testRunner.on('testfinished')` dispatched after
running all related `afterEach` hooks.
2019-08-08 15:15:09 -07:00
Andrey Lushnikov
c047624b68
chore: generate testIds on CIs only (#4817) 2019-08-07 10:26:53 -07:00
Andrey Lushnikov
dcff850b6f
chore(flakiness): update flakiness format (#4808)
This patch:
- updates Flakiness Dashboard format to define version per-build
  and to pass COMMIT information
- drops the README.md generation - we'll move on to a designated flakiness
  dashboard viewer
2019-08-06 15:32:55 -07:00
Darío Kondratiuk
b9b6ca1825 fix(network): be able to remove headers using request.continue (#4797)
I think this was a regression caused here https://github.com/GoogleChrome/puppeteer/pull/4265/files#diff-d2ac7cb061b0c51644d0a5d6140e3a32R446

Fix #4743
2019-08-05 15:26:17 -07:00
Joel Einbinder
4acce550c4 fix(test): enable cross process viewport test (#4806) 2019-08-05 15:22:16 -07:00
Joel Einbinder
a95ec70635 chore(test): label coverage+debuger test with upstream bug (#4807)
Filed as https://crbug.com/990945
2019-08-05 15:22:01 -07:00
Joel Einbinder
f2056a8e25 fix(test): enable redirect inside sync XHR test (#4805)
The underlying bug appears to have been fixed. Test works.
2019-08-05 15:19:34 -07:00
Darío Kondratiuk
eb44e260a9 test: add page.bringToFront test (#4778)
Test `page.bringToFront` in headful.
2019-08-01 17:08:29 -07:00
Andrey Lushnikov
5c7c45f0aa
chore(coverage): fix coverage for events (#4787)
We used to track API Coverage for public events, but this was regressed in the refactoring that
introduced `//lib/Events.js`.

This patch:
- Brings back API Coverage for events
- Combines all coverage-generated tests into a single one. This way
we can generate less data for flakiness dashboard.
2019-08-01 16:09:50 -07:00
Andrey Lushnikov
e252dcf200
chore(flakiness): Flakiness Dashboard fixes (#4788)
- fix `FLAKINESS_DASHBOARD_BUILD_URL` to point to a task instead of a build
- do not pretty-print `dashboard.json` when serializing flakiness results
- filter out 'COVERAGE' test(s) so that they don't add up to `dashboard.json` payload. These are useless
- validate certain important options of flakiness dashboard
- more logging to STDOUT to actually say which repo and what branch is getting used
- enhance commit message with a build URL
- use a more compact format for JSON. For 100 runs of 700 tests it yields 21MB json instead of 23MB.
- bump default builds number to 100
2019-08-01 16:09:02 -07:00
Yury Semikhatsky
e2db16f898 fix(tests): make eval test resilient to error format (#4793)
Make eval test resilient to variations in error message format between browsers.This will make the test pass without alternations in WebKit as well as Crhrome and Firefox.
2019-08-01 14:18:35 -07:00
Andrey Lushnikov
932c8cbe9a
chore: introduce initial version of flakiness dashboard (#4781)
This patch introduces a dashboard that records test results and
uploads them to https://github.com/aslushnikov/puppeteer-flakiness-dashboard

Since many bots might push results in parallel, each bot pushes
results to its own git branch.

FlakinessDashboard also generates a simple README.md with a flakiness
summary. If this proves to be not enough, we can build a website that
fetches flakiness data and renders it nicely.
2019-07-31 22:23:50 -07:00
Yury Semikhatsky
1b4a0302fc fix(test): make sure selection is not empty before running copy command (#4772)
If current selection is empty document.execCommand('copy') may return false in some browsers (e.g. WebKit based ones).
2019-07-30 13:19:56 -07:00
Joel Einbinder
7a607469df fix(tests): background page tests should wait for the page (#4769) 2019-07-29 14:09:34 -07:00
Andrey Lushnikov
ea28cccfe0 feat(page): introduce file chooser interception (#4653)
This patch introduces a page.waitForFileChooser() method
that adds a watchdog to wait for file chooser dialogs.

This lets Puppeteer users to capture file chooser requests
and fulfill/cancel them if necessary.

Fixes #2946
2019-07-22 21:30:49 -07:00
Yury Semikhatsky
2abaac10aa fix(launcher): make dumpio and pipe options work together (#4727)
Don't ignore stdout and stderr when using pipe for remote debugging and dumpio is true. In that case puppeteer process connects to the stdout/stderr streams of the child process and it will not hang.
2019-07-18 16:42:11 -07:00
Andrey Lushnikov
835e8849fd
feat(testrunner): add new testrunner options (#4718)
This patch adds new TestRunner options:
- `disableTimeoutWhenInspectorIsEnabled` - disable test timeout if
  testrunner detects enabled inspector.
- `breakOnFailure` - if testrunner should terminate test running on
  first test failure
2019-07-17 10:32:37 -07:00
Andrey Lushnikov
ad1802188d
fix(launcher): disable component extensions (#4704)
Chrome has a set of component extensions - e.g. CryptoTokenExtension
that helps with 2FA.

These extensions are loaded regardless of the `--disable-extensions`
flag we already pass. To disable these extensions, we need to pass additional
`--disable-component-extensions-with-background-pages` flag.

Fix #4300
2019-07-15 17:54:42 -07:00
Yury Semikhatsky
a39d553511 fix(tests): Get TLS version from Node instead of hardcoding it (#4700) 2019-07-14 18:33:31 -07:00
Andrey Lushnikov
62733a20d7
fix(connection): bump websocket max received message size to 256Mb (#4571)
This is the max message size that DevTools can emit over the DevTools
protocol: https://cs.chromium.org/chromium/src/content/browser/devtools/devtools_http_handler.cc?type=cs&q=kSendBufferSizeForDevTools&sq=package:chromium&g=0&l=83

Test is failing on firefox since Firefox crashes when allocating 100Mb string.

Fix #4543
2019-06-14 01:05:09 -07:00
Andrey Lushnikov
8df0b3ec3b
fix(network): allow fulfilling requests with status code 422 (#4566)
Migration onto fetch domain (2265974ce5)
changed the way we generate status texts: instead of relying on build-in
list of statuses, we tried to rely upon the [Chromium implementation](https://cs.chromium.org/chromium/src/net/http/http_status_code_list.h?sq=package:chromium&g=0).

Puppeteer's list is much more exhaustive - let's keep it.

Fix #4454
2019-06-10 17:39:58 -07:00
Joel Einbinder
b2f94909a1 fix(eval): be able to throw protocol like errors (#4551) 2019-06-10 17:35:40 -07:00
Andrey Lushnikov
6a50888d34
fix(firefox): fix missing awaits in mouse.click (#4561)
This applies the same fix we used on the Chrome-side and adds a test.

Fix #4536
2019-06-10 16:53:38 -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
Andrey Lushnikov
15804d111a
test: remove debug console.log (#4522) 2019-06-04 16:27:36 -07:00
Andrey Lushnikov
78d5106dd9
feat(chromium): roll Chromium to r665405 (#4516)
* feat(chromium): roll Chromium to r665405

This roll includes:
- https://crrev.com/665226 - DevTools: make interception respect cross-process frame boundaries

This fixes page loading with dynamic OOPIFs - test is added.

Fix #4442

* fix lint
2019-06-04 11:03:15 -07:00
Andrey Lushnikov
d221c02c13
test: add test to verify fetching of dataURL requests (#4233) 2019-05-31 17:11:55 -07:00
Andrey Lushnikov
015e330815
test: add oopif tests (#4495)
Reference #2548
2019-05-29 16:49:44 -07:00
Andrey Lushnikov
76b24e64e8
feat(chromium): roll Chromium to r662092 (#4462)
This roll includes:
- [inspector_protocol:8ec18cf](8ec18cf088) Support STRING16 in the template when converting CBOR map keys
to protocol::Value.
- [inspector_protocol:37518ac](37518ac421) fix parsing of the last ASCII character

This fixes protocol handling of UTF8 in both V8 and Chromium.

Fixes #4443.
2019-05-22 21:21:45 +03:00
Andreas Tolfsen
cbecfba0af test: convert license text file to LF line endings (#4438)
See #4320 (comment).

Should fix the checkout problems on Unix file systems.
2019-05-21 23:11:25 +03:00
Darío Kondratiuk
bad98baf70 fix(test): browser.disconnect should not be awaited (#4446)
browser.disconnect does not return a promise
2019-05-21 17:26:04 +03:00
Jake Causon
90a1032300 fix(network): stringify response headers for intercepted requests (#4436)
Stringifying the headers was the behaviour before v1.15

References #4379
2019-05-20 11:05:32 +03: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
3f23bb022e
test: add failing evaluation test with utf8 (#4444)
References #4443
2019-05-18 14:05:28 +03:00
Andrey Lushnikov
8a1c2495c0
test: add SVG clicking test (#4432)
Someone had concerns that pptr's clicking doesn't work with SVG.

Make sure Puppeteer's clicking does.
2019-05-18 12:49:55 +03:00
Joel Einbinder
a3cb16308c feat: root option in page.accessibility.snapshot() (#4318)
Going from `AXNode` -> `ElementHandle` is turning out to be controversial.

This patch instead adds a way to go from `ElementHandle` -> `AXNode`. If the API looks good, I'll add it into Firefox as well.

References #3641
2019-05-09 23:39:42 -07:00
Andrey Lushnikov
b3027a6e16
test(page): make sure exposeFunction works with complex args (#4411) 2019-05-09 18:02:46 -07:00
Joel Einbinder
1516e0df21 feat(workers): create workers from service workers and shared workers (#4397)
This allows users to easily evaluate javascript inside service workers and shared workers by creating a Worker object for them.
2019-05-09 17:29:18 -07:00
Andrey Lushnikov
ef24c69c62
fix(tracing): start without options (#4388) 2019-05-09 17:15:33 -07:00
Tony Brix
511dcf9d32 feat(browser): Add browser.isConnected() (#4403)
Add `browser.isConnected()` to the public api to be able to tell when the browser is connected

fixes https://github.com/smooth-code/jest-puppeteer/pull/237#issuecomment-490260041
2019-05-09 16:24:52 -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
1de9906260
test: add cookie tests (#4365) 2019-04-30 00:35:41 -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
e2e6b88934
feat(chromium): roll Chromium to r654752 (#4358)
This roll includes:
- https://crrev.com/653809 - FrameLoader: ignore failing provisional loads entirely
- https://crrev.com/654750 - DevTools: make sure Network.requestWillBeSent is emitted on time for sync xhrs

The FrameLoader patch is the reason behind the test change. It's
actually desirable to fail frame navigation if the frame detaches - and
that's consistent with Firefox.

Fixes #4337
2019-04-28 20:19:01 -07:00
Andrey Lushnikov
f3db28c94b
test: add failing test for request interception with sync XHRs (#4350)
`Network.requestWillBeSent` is not issued for the redirect inside
sync XHRs.

References #4337.
2019-04-26 16:28:15 -07:00
Andrey Lushnikov
770411be9d
test: verify overriding postdata and method on navigation (#4317)
References #4309
2019-04-19 18:22:30 -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
Darío Kondratiuk
dde55b0257 test: Make intervention test Edge friendly (#4314)
All tests are green when running against [Microsoft Edge Insider](https://www.microsoftedgeinsider.com/en-us/), except this test.

Edge returns `https://to-be-replaced.invalid/feature/5718547946799104` instead of `https://www.chromestatus.com/feature/5718547946799104`

I think that checking for `feature/5718547946799104` is a small test and will do the job for both browsers.

```
$env:CHROME = "C:\Program Files (x86)\Microsoft\Edge Dev\Application\msedge.exe"; node
.\test.js
```
2019-04-19 11:29:29 -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
a8ffdad76e
feat(chromium): roll Chromium to r650583 (#4284)
This roll includes:
- https://crrev.com/650583 - DevTools: fix DOM.getContentQuads for a
  corner case

Fixes #4281.
2019-04-13 00:28:58 -07:00
Andrey Lushnikov
145e8680b1
test: add failing test for clicking certain elements (#4282)
References #4281
2019-04-13 00:10:48 -04:00
Andrey Lushnikov
8f8e77492d
test: split out request interception tests (#4278) 2019-04-11 21:33:01 -04:00
Andrey Lushnikov
5ee21d97e7
fix(page): intersect content quads with viewport (#4277)
In certain cases inline element children might be positioned
outside of viewport.

In this case, we should intersect all content quads with viewport
before we pick one to click into.

Fixes #4274.
2019-04-11 21:11:20 -04:00
Andrey Lushnikov
20988775bf
fix: gracefully handle multiple contexts for secondary DOM World (#4276)
In case of multiple sessions to the same target, there's a race between
sessions to create a secondary isolated world. As a result, we might
end up having 2 execution contexts created for the needs of the
secondary isolated world.

This patch starts handling this race gracefully: instead of crashing,
we can use either of the execution contexts and ignore the rest.

Notably, the same race condition might happen if page reloads itself
in-between the calls to `page.addEvaluateOnNewDocument` and
`page.createIsolatedWorld`.

Fixes #4197.
2019-04-11 16:26:18 -04: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
Joseph Arhar
fd0f58e9c2 fix: Use new requestId for interception request matching (#4248)
Fix #3471
2019-04-08 14:17:57 -07: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
Darío Kondratiuk
72866e9467 test: Change cookies unsecure test title (#4187)
I think we wanted to say "HTTP Website" there.
2019-03-20 11:36:27 -07:00
Andrey Lushnikov
60567575d2
test: make sure frames are reported from-inside shadow DOM (#4167)
References #4163.
2019-03-15 21:01:36 -07:00
Vse Mozhet Byt
854b1c0912 feat(executioncontext): support bigints transferring (#4016)
Refs: https://chromedevtools.github.io/devtools-protocol/tot/Runtime#type-UnserializableValue
2019-03-15 10:20:48 -07:00
Andrey Lushnikov
3511a35fa4
test: fix fixtures test when run with env DUMPIO=1 (#4123)
The DUMPIO env variable is propagated to a spawned process
and results in unfortunate stdout.
2019-03-13 16:26:28 -07:00
Andrey Lushnikov
6474b3ffe0
test: ensure Page.setBypassCSP works with iFrames (#4155) 2019-03-11 17:56:32 -07:00
Andrey Lushnikov
42351c7fe5
feat(firefox): Implement header overrides in request interception (#4142)
This patch makes sure header overrides in request interception are
functioning as expected.

Drive-by: teach test server to use utf-8 charset header for text files.
2019-03-08 14:26:13 -08:00
Darío Kondratiuk
5d6535ca0c test: Fix should fire for fetches test (#4139)
The code in "should fire for fetches" was copy of "should fire for iframes"
I bet the test was supposed to use a fetch there.
2019-03-08 08:59:07 -08:00
Andrey Lushnikov
87a8d744e6
test: add a failing test that tries to click a fixed button in an iframe (#4130)
References #4110
2019-03-06 18:46:40 -08:00
Andrey Lushnikov
1623bef264
test: improve test coverage for Request.continue (#4096)
Drive-by: add clarification to docs/api.md regarding
chaning "URL".

References #4030
2019-03-05 14:57:15 -08:00
Joel Einbinder
f32d77e074 test: check if the executable path is an exact match (#4117)
References #4102
2019-03-04 23:46:14 -08:00
Joel Einbinder
ba5f94d2b0 test: disable flaky cookies test (#4112)
References #4111
2019-03-04 18:18:54 -08:00
Andrey Lushnikov
9db09fe7e9
test: add test to validate redirecting in request.respond (#4106) 2019-03-04 17:16:04 -08:00
Andrey Lushnikov
c68df320f8
test: add failing test for bad request interception (#4108)
References #3973
2019-03-04 17:09:23 -08:00
Joel Einbinder
a6d8ecce6f fix(firefox): keyboard tests (#4082) 2019-02-27 15:13:17 -08: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
9ef23b1754
feat(firefox): implement cookies api (#4076)
This patch implements `page.setCookie()`, `page.deleteCookie()` and
`page.cookies()` and doubles the test coverage for cookies so that
we can feel safer on cross-browser compatibility.
2019-02-26 16:24:30 -08:00
Joel Einbinder
03d06f54d6 feat(firefox): page.accessibility.snapshot() (#4071) 2019-02-25 21:57:33 -08:00
Andrey Lushnikov
f21486fa1b
feat(firefox): implement Page.touchscreen (#4070) 2019-02-25 15:36:38 -08:00
Andrey Lushnikov
3541b894f5
test: split out all chromium-specific tests into chromiumonly.spec.js (#4068) 2019-02-25 12:51:06 -08:00
Andrey Lushnikov
77a4ea505e
test: split out fixture tests and make them work with FF (#4067)
Drive-By: give Puppeteer-Firefox its own copy of DeviceDescriptors.
2019-02-25 12:40:17 -08:00
Andrey Lushnikov
4ecbd91e4b
refactor(firefox): migrate onto ExecutionContext events (#4064)
Juggler now has Runtime domain that emits Execution Context events
"ExecutionContextCreated" and "ExecutionContextDestroyed".
2019-02-24 23:07:24 -08:00
Andrey Lushnikov
56dafd7424
feat: support Response.buffer(), Response.json() and Response.text() (#4063)
This patch:
- implements Response.buffer() and other methods
- splits out relevant tests into a separate test suites
- implements `testServer.enableGzip()` method to optionally gzip
  certain routes in tests
- adds tests to make sure `Response.text()` returns expected results
  for binary and compressed responses.
2019-02-24 19:31:35 -08:00
Andrey Lushnikov
3bea5d6017
feat(firefox): implement browserContext.overridePermissions (#4060) 2019-02-22 23:59:32 -08:00
Andrey Lushnikov
f1a14fec5b
feat(firefox): support elementHandle.uploadFile (#4058)
Fixes #3762
2019-02-22 17:22:46 -08:00
Andrey Lushnikov
1315dc8234
feat(firefox): support Page.emualteMedia (#4056) 2019-02-22 14:04:40 -08:00
Andrey Lushnikov
5c818368a5
feat(firefox): implement page.exposeFunction (#4052) 2019-02-22 00:04:25 -08:00
Andrey Lushnikov
7d39aca93c
test: split out test for "text" option of ElementHandle.press (#4051) 2019-02-21 15:56:53 -08:00
Andrey Lushnikov
ed984ac479
chore(firefox): kill original puppeteer-firefox tests (#4047)
When we started working on Puppeteer-Firefox, we forked original
Puppeteer testsuite.

This patch concludes the effort to merge testsuites back together.

Fixes #3889
2019-02-21 13:10:15 -08:00
Andrey Lushnikov
fbf91cca98
test(firefox): move AX tests to Chrome-only (#4042)
Let's not focus on AX for now for Firefox.
2019-02-21 10:07:13 -08:00
Andrey Lushnikov
a0fd2ce3fd
fix(firefox): enable more tests (#4037)
Further align Puppeteer-Firefox implementation with Puppeteer to
pass more tests.
2019-02-19 22:36:02 -08:00
Andrey Lushnikov
03c542a6c1
feat(firefox): implement missing launcher options (#4036)
This patch implements `puppeteer.defaultArgs()` and also missing
options, such as `ignoreDefaultArgs`.
2019-02-19 22:08:09 -08:00
Andrey Lushnikov
719ee5af3d
feat(firefox): support page.setExtraHTTPHeaders (#4035) 2019-02-19 15:22:12 -08:00
Andrey Lushnikov
c118b208fa
feat(firefox): basic request interception support (#4034)
This patch implements `page.setRequestInterception`, `page.continue`
and `page.abort` methods.
2019-02-19 14:51:56 -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
4a4793a5e1
feat(firefox): support Browser.target() (#4028)
Support browser target.

Drive-by: switch over to a more devtools'ish protocol:

- use `targetId` instead of `pageId` everywhere
- use target events instead of tab events
2019-02-17 10:23:48 -08:00
Andrey Lushnikov
ea482c4751
fix(firefox): properly cleanup networkmanager (#4024) 2019-02-15 23:34:01 -08:00
Andrey Lushnikov
9782f9c827
fix(firefox): add test to make sure remote browser can be closed (#4023) 2019-02-15 18:26:14 -08:00
Andrey Lushnikov
c35821a1a1
feat(firefox): switch over to WebSocket and support multiclient (#4022)
- switch transport from TCP to WS (yay!)
- implemenet `puppeter.connect()`, `browser.disconnect()`, `'disconnected'`
event and `browser.wsEndpoint()`
2019-02-15 17:57:48 -08:00
Andrey Lushnikov
e0d4a5d2ec
fix(firefox): track frame detachment in navigation watchdog (#4008) 2019-02-14 00:06:30 -08:00
Andrey Lushnikov
247733b879
fix(firefox): enable more firefox tests (#4007) 2019-02-13 23:59:38 -08:00
Andrey Lushnikov
e8f044c3be
fix(firefox): enable a bunch of evaluation tests (#4006) 2019-02-13 23:41:53 -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
2275c3c0c8
fix(firefox): properly round clip when doing element screenshots (#4001)
Do clipping the same way we do it in Chromium.
2019-02-13 19:47:14 -08:00
Andrey Lushnikov
670d758dfe
feat(firefox): support "referer" option in Page.goto (#4000) 2019-02-13 13:49:05 -08:00
Andrey Lushnikov
fbf36438e8
feat(firefox): support Request.postData (#3999) 2019-02-13 13:11:50 -08:00
Andrey Lushnikov
13224a761e
feat(firefox): support Response.securityDetails() (#3997) 2019-02-13 11:56:51 -08:00
Andrey Lushnikov
57e7f12fbc
test: split out tests for security details (#3996)
This adds missing test coverage for security details and
re-generates our self-signed ceritificate to have meaningful
issuer and subject name.
2019-02-13 11:35:49 -08:00
Andrey Lushnikov
31ae1d6d15
feat(firefox) support Request.headers() & Response.headers() (#3993) 2019-02-13 00:55:56 -08:00
Andrey Lushnikov
89d0f1e1e7
feat(firefox): implement frame.goto / frame.waitForNavigation (#3992)
Some corner cases regarding iframes being detached during navigation
are not yet supported.
2019-02-12 20:10:53 -08:00
Andrey Lushnikov
f0fba56ea3
test: split out Response.fromCache/fromServiceWorker (#3990) 2019-02-12 19:59:54 -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
afb9355b15
feat(firefox): basic support for Network (#3988)
This patch introduces basic Request and Response events for
page. It also teaches navigation methods, e.g. `page.goto` to return
navigation response.
2019-02-12 17:38:48 -08:00
Joel Einbinder
fb9d4049d8 test(mouse): add failing for test for mobile + cross process navigation (#3951) 2019-02-11 14:00:06 -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
edb6f62824
feat(firefox): support page.setDefaultNavigationTimeout (#3969)
This patch supports:
- page.setDefaultNavigationTimeout
- page.setDefaultTimeout
2019-02-08 20:37:14 -08:00
Andrey Lushnikov
fc18a79e99
feat(firefox): support Page.setUserAgent method (#3968) 2019-02-08 19:53:27 -08:00
Andrey Lushnikov
1ce578b787
chore(test): remove the server.EMPTY_PAGE2 asset (#3967)
Firefox used to have a bug that prevented adding iframes with the
same URL as main frame. In this case, we used the EMPTY_PAGE2
so that it doesn't clash with top-level EMPTY_PAGE.

The bug seems to be fixed after we rolled onto a fresh Firefox;
there's no more need for this test asset.
2019-02-08 19:24:40 -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
a9875359aa
feat(firefox): implement execution contexts (#3962) 2019-02-08 17:15:52 -08:00
Andrey Lushnikov
0bb657cb26
chore(test): remove --firefox-status flag from tests (#3956)
The [IsPuppeteerFirefoxReady?](https://aslushnikov.github.io/ispuppeteerfirefoxready/)
website now has its own script to compute test and api coverage.
2019-02-08 13:29:13 -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
addd7f4c6a
chore(testrunner): introduce verbose mode (#3946) 2019-02-07 13:17:29 -08:00
Andrey Lushnikov
76eecde823
chore(test): remove stray console.log (#3943) 2019-02-07 08:14:05 -08:00
Andrey Lushnikov
609e763381
test(firefox): enable screenshot tests for Firefox (#3942)
References #3889
2019-02-07 07:59:14 -08:00
Andrey Lushnikov
49e8704ba8
test(firefox): enable more tests on Puppeteer-Firefox (#3937)
References #3889
2019-02-07 07:15:19 -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
a210dd7ee2
chore(testrunner): show 5 slowest tests on CI (#3919)
Show top slowest tests on CI.

Drive-by: some facelifting for the test reporter.
2019-02-05 15:28:35 -08:00
Andrey Lushnikov
00bcecbf72
chore: increase test timeout to 20 seconds on Appveyour (#3918)
Looks like Appveyour is indeed slow; try giving it more time
to run tests.

Drive-by: support TIMEOUT env variable for Puppeteer tests.
2019-02-05 13:38:56 -08:00
Andrey Lushnikov
28087c291f
feat(firefox): support ElementHandle.contentFrame() (#3917) 2019-02-05 13:29:49 -08:00
Andrey Lushnikov
dd8bd6dcb1
test(firefox): support Puppeteer-Firefox specific env variables (#3907)
This patch:
- adds support to `FFOX` env variable for Puppeteer testsuite
- install Firefox preferences when running tests with custom firefox
  executable

References #3889
2019-02-05 13:17:02 -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
b5e53fdbf4
test(firefox): add puppeteer-firefox unique evaluation tests (#3891)
References #3889
2019-02-01 18:40:40 -08:00
Andrey Lushnikov
6bb0350b4d
test(firefox): introduce vendor-specific specs (#3890)
Certain Puppeteer methods do expose the inner browser - e.g.
`browser.version()` depends on the browser we run.

Split out these tests into a vendor-specific test suites.

References #3889
2019-02-01 17:55:12 -08:00
Andrey Lushnikov
84fe6014e9
chore(firefox): run Puppeteer-Firefox against Puppeteer tests (#3888)
Introduce a `npm run funit` script that runs puppeteer tests
against Puppeteer-Firefox.

Next steps:
- bring Puppeteer-Firefox unique tests to Puppeteer
- skip failing tests and run Puppeteer-Firefox on CI
- work through tests to pass them all with Puppeteer-Firefox
2019-02-01 17:04:19 -08: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
55432f88e9
fix(page): execute frame.waitFor{Selector,XPath} in secondary world (#3856)
This patch starts executing frame.waitForSelector and frame.waitForXPath
in secondary world. As a result, websites that mutate page global
context (e.g. removing global MutationObserver) don't break Puppeteer's
behavior.

Fixes #609
2019-01-28 12:24:27 -08:00
Andrey Lushnikov
2061dd4718
fix(page): teach waitForSelector to return null (#3846)
`page.waitForSelector` should return `null` if waiting for `hidden:
true` and there's no matching node in DOM.

Before this patch, `page.waitForSelector` would return some JSHandle
pointing to boolean value.
2019-01-28 14:24:53 -05:00
Andrey Lushnikov
62da2366c6
chore: introduce //lib/api.js (#3835)
Introduce `//lib/api.js` that declares a list of publicly exposed
classes.

The `//lib/api.js` list superceedes dynamic `helper.tracePublicAPI()` calls
and is used in the following places:
- [ASYNC STACKS]: generate "async stacks" for publicy exposed API in `//index.js`
- [COVERAGE]: move coverage support from `//lib/helper` to `//test/utils`
- [DOCLINT]: get rid of 'exluded classes' hardcoded list

This will help us to re-use our coverage and doclint infrastructure
for Puppeteer-Firefox.

Drive-By: it turns out we didn't run coverage for `SecurityDetails`
class, so we lack coverage for a few methods there. These are excluded
for now, sanity tests will be added in a follow-up.
2019-01-25 23:21:14 -05:00
Andrey Lushnikov
1a7995558f
chore(test): prepare tests to be run with Puppeteer-Firefox (#3833)
This patch aligns Puppeteer testing infrastructure with the approach
we use in Puppeteer-Firefox.

This patch:
- makes all tests accept Puppeteer object as a function argument
  rather than require it statically. This way we can pass either
  Puppeteer or Puppeteer-Firefox to drive tests.
- renames the `puppeteer.spec.js` into `launcher.spec.js`. The
  `puppeteer.spec.js` is now the entry point for all cross-browsers
  tests.
2019-01-24 01:04:42 -05:00
Andrey Lushnikov
fb710120e9
feat(page): use secondary world to drive clicks (#3828)
References #2671
2019-01-22 23:24:14 -05: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
Linus Unnebäck
9fb89e1bbc test: Add test for waitForFunction with cross-process navigation (#3826) 2019-01-22 13:21:18 -05:00
Andrey Lushnikov
9fd4b67d0c
fix(requestinterception): filter out "intervention" header (#3814)
Fixes #3798
2019-01-20 00:02:13 -05:00
Andrey Lushnikov
489be90c75
test: move tracing tests to one-per-browser (#3781)
Tracing is working on a per-browser level, not per-page. In order
to paralellize these tests effectively and properly, each should run
a designated browser.
2019-01-15 16:39:30 -08:00
Joel Einbinder
91c4501cc6 test(coverage): add failing test for skipping all debugger statements (#3779) 2019-01-15 14:49:57 -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
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
Andrey Lushnikov
0505c81b52
test: add test for multiline waittask (#3753)
References #3723
2019-01-10 21:41:09 -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
16fc28bf06
test: make sure headful browser closes with beforeuload page (#3751)
This was fixed upstream at https://crrev.com/618425

Fixes #3673
2019-01-10 14:05:43 -08:00
Andrey Lushnikov
1899e7931c
feat: enable Network Service by default (#3738)
References #3471.
2019-01-09 15:47:08 -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
Andrey Lushnikov
309cbe625f
test: split out navigation tests (#3585) 2018-11-20 20:09:25 -08:00
Andrey Lushnikov
d61916b53e
test: split out evaluation tests (#3584) 2018-11-20 19:59:59 -08:00
Andrey Lushnikov
e83918987a
test: split input tests into keyboard, mouse and touchscreen (#3583) 2018-11-20 19:43:07 -08:00
Andrey Lushnikov
25f4f26851
test: extract clicking tests (#3582) 2018-11-20 19:34:57 -08:00
Andrey Lushnikov
a181bdde31
test: split out emulation tests (#3581) 2018-11-20 19:17:56 -08:00
Andrey Lushnikov
a5b1978190
test: split out waittask tests (#3580) 2018-11-20 18:57:28 -08:00
Andrey Lushnikov
e5830d1199
test: split queryselector tests into separate file (#3579) 2018-11-20 18:45:37 -08:00
Andrey Lushnikov
aa9fb82f14
test: split screenshot tests into separate file (#3578) 2018-11-20 18:32:42 -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
Darío Kondratiuk
03d8746260 test(accessibility): Fix duplicated test (#3539) 2018-11-15 14:57:07 -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
Andrey Lushnikov
eb7bd9d7d3
test: setup sandbox on linux (#3530)
Drop all the `--no-sandbox` bits from tests and infrastructure. Instead, configure
Travis to enable user namespace clone.
2018-11-12 23:26:16 -08:00
Andrey Lushnikov
27ea226bbc
test: fix workers test (#3527) 2018-11-09 18:44:53 -08:00
Darío Kondratiuk
b9f2104f43 test(cookies): Remove duplicated test. (#3492)
We have the same test on line 130 https://github.com/GoogleChrome/puppeteer/blob/v1.10.0/test/cookies.spec.js#L130
2018-11-04 11:48:31 -08:00
Andrey Lushnikov
6b65407ab6
test: unflake cookie test on windows (#3489) 2018-11-02 13:23:44 -07: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
eca3c6bed2
test(cookies): cookies from headful now work in headless (#3481)
This patch enables cookie test. The actual upstream patch
that fixed the issue:
- https://crrev.com/599696 - Headless: support cookie encryption

Fixes #921.
2018-11-01 18:51:56 -07:00
Andrey Lushnikov
3596c5f7e2
fix(page.evaluate): better function serialization (#3480)
References #1665
2018-11-01 16:43:21 -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
0fd3bfb986 test(CSSCoverage): failing test when a stylesheet was recently added (#3400)
If nobody forces a layout, CSS coverage is inconsistent. This causes some flakes on the bots. The test in this PR fails 90% of the time on my local machine.
2018-10-12 13:49:59 -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
Andrey Lushnikov
8becb31754
test: add failing test for page.select (#3346)
References #3327.
2018-10-04 10:41:38 -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
85aca8e1a5
chore(testserver): prepare test server (#3294) 2018-09-24 12:46:39 -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
a1a211d9e7
chore: nicer stack highlight (#3259)
Highlight part of the stack that points to where the actual
test failure happened.
2018-09-17 23:22:53 +01:00
Andrey Lushnikov
d547b9d24a
fix(browser): browser closing/disconnecting should abort navigations (#3245)
Fixes #2721.
2018-09-14 19:44:54 +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
c644a3bbd3
test: make sure zero-width screenshots don't hang (#3214)
References #2672.
2018-09-11 19:07:57 +01:00
Andrey Lushnikov
d54c7edeae
fix(page): Page.goto should properly handle historyAPI in beforeunload (#3198)
Fixes #2764.
2018-09-05 22:59:29 +01:00
Andrey Lushnikov
7f9e276733
feat(network): introduce Response.statusText() (#3193)
Fixes #317.
2018-09-05 21:03:24 +01:00
Andrey Lushnikov
1ba2b8540d
feat(network): introduce Response.remoteAddress() (#3192)
Closes #2171.
2018-09-04 20:39:59 +01:00
Andrey Lushnikov
22c0ce63ce
test: cleanup newly added test for navigation referer (#3179)
Make sure that referer that is passed as `page.goto` option doesn't
override subrequest referers.
2018-09-04 19:05:48 +01:00
Andrey Lushnikov
32c0363ade
feat(chromium): roll Chromium to r588429 (#3181)
This roll includes:
- https://crrev.com/588420 - DevTools: teach request interception to work with
  Security.setIgnoreCertificateErrors

Fixes #1159.
2018-09-04 10:04:27 +01:00
Ali Ahmad
464f3b4ca2 feat(page): Add 'referer' as a parameter to Page.goto() (#3128)
If referer is passed to the options object its value will be used as the referer instead of the value set by `Page.setExtraHTTPHeaders()`.

This is the correct way to set referer header: otherwise, the `referer` header will override all the document subrequests.

Fixes #3090.
2018-09-03 20:06:58 +01:00
Andrey Lushnikov
17029281a9
feat(page): Introduce page.setGeolocation method (#3160)
Fixes #1077
2018-08-31 18:04:12 +01:00
Andrey Lushnikov
50d6c2d3c6
feat(browsercontext): implement BrowserContext.overridePermissions (#3159)
Introduce an API to manage permissions per browser context:
- BrowserContext.overridePermissions(origin, permissions)
- BrowserContext.clearPermissionOverrides()

Fixes #846.
2018-08-30 23:36:09 +01:00
Andrey Lushnikov
df459ba6cd
feat(chromium): roll Chromium to r587164 (#3153)
This roll includes:
- https://crrev.com/584293 - DevTools: execute scripts in addScriptToEvaluateOnLoad in order
- https://crrev.com/585630 - DevTools: introduce Browser.grantPermissions
- https://crrev.com/587156 - Revert "[Base] Use background mode for ThreadPriority::BACKGROUND threads (behind feature) (reland)."

The "revert" patch fixes headless functionality on windows.

References #846.
Fixes #3106.
2018-08-30 01:02:53 +01:00
Andrey Lushnikov
ce64ae22f4
test: add test for request interception with 302 after POST (#3105)
References #3089
2018-08-17 10:51:27 -07:00
Andrey Lushnikov
be7626fa5e
fix: revert ExecutionContext reporting. (#3058)
It turned out that almost any usecase requires helper methods to access
DOM inside the ExecutionContext.

Instead of exposing execution contexts as-is, we should introduce
IsolatedWorld as a first-class citizen that will hold execution contexts
inside.
2018-08-09 18:14:21 -07:00
Andrey Lushnikov
204c7ec8c4
feat: introduce puppeteer/Errors (#3056)
This patch adds a new require, `puppeteer/Errors`, that
holds all the Puppeteer-specific error classes.

Currently, the only custom error class we use is `TimeoutError`. We'll
expand in future with `CrashError` and some others.

Fixes #1694.
2018-08-09 16:51:12 -07:00
Andrey Lushnikov
231a2be971
feat: expose frame's execution contexts (#3048)
This patch exposes frame's execution contexts, making it possible
to debug extension's content scripts.

This is a resurrected #2812.
2018-08-09 14:57:08 -07:00
Andrey Lushnikov
40466cb3a4
feat(launcher): ignoreDefaultArgs to accept array of options (#3049)
If `ignoreDefaultArgs` is given an array of options, than
these options will be excluded from the default command-line
flags.
2018-08-08 19:10:10 -07:00
Joel Einbinder
6825088644 feat(launcher): allow options to be passed into puppeteer.defaultArgs (#2950) 2018-08-07 13:22:04 -07:00
Joel Einbinder
25632133e2 feat: add option to specify the default viewport (#3005)
Fixes #1183.
2018-08-01 16:23:03 -07:00
Andrey Lushnikov
0c49bf5245
test: use new browser context for every page test (#3010)
This allows us:
- dogfood browser contexts the way we want them to be used
- simplifies the dance around service workers / cookies setting up and tier down.
2018-08-01 15:49:41 -07:00
Andrey Lushnikov
9c96a9283f
test: fix flakiness of certain extension tests (#3011) 2018-08-01 14:57:19 -07:00
Andrey Lushnikov
c018ff1555
feat(browsercontext): add BrowserContext.pages() method (#3003) 2018-07-31 13:24:29 -07:00
Joel Einbinder
3335d369d3 fix: typing emoji (#2824)
This changes sendCharacter to use document.execCommand instead of sending a `'char'` event from the protocol. This is more aligned with how input would come in from emoji keyboards, and removes the 3ish byte limit on characters that can be sent which prevented larger emoji from being rendered correctly.

Emoji will still fail to type correctly if typing them into an iframe that is in shadow dom.

fixes #1096
2018-07-31 11:22:26 -07:00
Andrey Lushnikov
1931cb479e
feat(Chromium): roll Chromium to r579032 (#2989)
This patch rolls Chromium to r579032. The patch includes:
- https://crrev.com/577366 - DevTools: report redirect responses only if response interception is enabled
- https://crrev.com/577212 - DevTools: intercept requests resulting from redirects
- https://crrev.com/578934 - DevTools: Add a protocol method to insertText

Interception Logic in DevTools protocol has changed regarding redirects;
this patch migrates interceptions to dispatch "request" events based on
requestWillBeSent event.
2018-07-30 19:09:10 -07:00
Andrey Lushnikov
5bcb7cf512
test: add test with request interception and cookies (#2988)
Fixes #2970.
2018-07-30 19:05:19 -07:00
Andrey Lushnikov
0c825de1f8
test: unflake page test that was causing us a lot of CI flakes (#2993) 2018-07-30 18:36:33 -07:00
Andrey Lushnikov
89f968b96a
test: try to fix CSS coverage flakes on win (#2992) 2018-07-30 18:36:21 -07:00
Andrey Lushnikov
4bbaa9d4f5
test: do not handle sigint for all the browsers launched in tests (#2990)
Puppeteer's default handler issues "process.exit(130)", causing
test runner to shut too early.

As a result, test runner doesn't show run summary.
2018-07-30 18:07:01 -07:00
Andrey Lushnikov
2c9599496a
test: make sure referer header is reported with request interception (#2986)
The referer header has been fixed some time ago.

References #469.
2018-07-30 18:05:27 -07:00
Andrey Lushnikov
392d3b94bd
Revert "chore(tests): redirect debugError to the output category of tests (#2969)" (#2987)
This reverts commit c5fe1dbdbb.
2018-07-30 16:41:39 -07:00
Joel Einbinder
c5fe1dbdbb chore(tests): redirect debugError to the output category of tests (#2969)
I have seen some flaky test failures where it would be nice to have run the tests with `DEBUG=puppeteer:error`. Instead of always running tests like that, I am redirecting `debugError` to the output category of the test. This is the same thing that we do for Chromium's stderr.

As a drive-by, I added an additional `debugError` where we were usually a try..finally pattern.
2018-07-30 11:16:12 -07:00
Andy Fleming
3d12f1f279 feat(FrameManager): improve waiting for selector to be hidden error message (#2911)
Fixes #2854
2018-07-26 16:24:04 -07:00
Andrey Lushnikov
56368aa07a
fix(page): page.click should work with disabled javascript (#2907)
Unfortunately, disabling javascript in page prevents any microtasks
to be executed even from puppeteer-originating javascript. As a
result, the IntersectionObserver hack we use to conditionally
scroll into view doesn't work.

To workaround this, we start always scrolling before clicking if
page's javascript is disabled.

Fixes #2898
2018-07-18 18:51:18 -07:00
Andrey Lushnikov
66fa0d3d53
test: cleanup page.waitForRequest/page.waitForResponse tests (#2880)
This patch removes unnecessary regexp tests and unifies all tests
between each other.
2018-07-12 15:32:18 -07:00
Matthew Shirley
726c8dc046 feat(page): introduce waitForRequest and waitForResponse methods (#2776)
This patch introduces `page.waitForRequest` and `page.waitForResponse` helper methods.

Fixes #2362
2018-07-12 14:36:31 -07:00
Andrey Lushnikov
3ebbf125ff
fix(coverage): report anonymous scripts with debugger:// urls (#2875)
Chrome DevTools shows anonymous scripts with yellow background and names
them with `debugger://VM<scriptId>` prefix.

This patch starts reporting the same debugger:// urls for anonymous
scripts in puppeteer's JS coverage. This might simplify debugging, e.g.
using `debugger;` statement to reveal the script in DevTools and later
matching it against the one in the coverage.
2018-07-11 21:05:16 -07:00
Andrey Lushnikov
254bc80811
chore: cleanup ElementHandle.isIntersectingViewport (#2874)
This patch:
- simplifies test reusing the `offscreenbuttons.html` asset
- aligns IntersectionObserver usage with the one we have for
  `ElementHandle._scrollIntoViewIfNeeded`.
2018-07-11 21:04:36 -07:00
Pavel Pomerantsev
12bc1e1a62 feat(coverage): add an option to collect coverage of anonymous scripts (#2796)
This patch adds `reportAnonymousScripts` option to the `coverage.startJSCoverage` method. With this option, anonymous scripts are reported as well.

Fixes #2777
2018-07-11 18:38:34 -07:00
Bogdan Ponomarenko
96c558d544 feat(elementhandle): introduce elementHandle.isIntersectingViewport() method. (#2673)
This patch introduces  `elementHandle.isIntersectingViewport()` method returns
true if element is visible in the viewport.

Fixes #2629.
2018-07-11 17:51:04 -07:00
Yaniv Efraim
cfc0571c1a feat: better timeout stack trace (#2843)
fixes #2653
2018-07-05 02:39:09 +03:00
Andrey Lushnikov
5955affab0
fix(page.click): teach puppeteer click wrapped links (#2822)
This patch teaches Puppeteer to click elements that are
part of inline layout and that wrap on multiple lines.

Fixes #2798.
2018-06-29 12:03:02 -07:00
Andrey Lushnikov
871b204fd1
refactor: simplify EmulationManager (#2816)
EmualationManager used to be injecting touch hooks to properly
support touch emulation.

However, these are no longer necessary, since https://crbug.com/133915
is long fixed.
2018-06-28 18:48:44 -07:00
Andrey Lushnikov
c4acc63775
feat(chromium): roll Chromium to r571040 (#2814)
This roll includes:
- https://crrev.com/570566 - DevTools: teach DOM.getBoxModel to work with SVG nodes

Fixes #1247.
2018-06-28 13:22:52 -07:00
Andrey Lushnikov
d6741eca08
test: add test that verifies pptr works with SVG nodes (#2805)
References #1247
2018-06-26 18:03:00 -07:00
Andrey Lushnikov
f55d005cbe
fix(page): teach page.click() to click partially offscreen buttons (#2806)
Originally, we use `Element.scrollIntoViewIfNeeded` to make sure
button is on screen before trying to click it.

However, `Element.scrollIntoViewIfNeeded` doesn't work in certain
scenarios, e.g. when element is partially visible and horizontal
scrolling is required to make it fully visible.

This patch polyfills `element.scrollIntoViewIfNeeded` using
IntersectionObserver and `Element.scrollIntoView`.

Fixes #2804.
2018-06-26 18:00:55 -07:00
Andrey Lushnikov
6ca43cf761
docs(api.md): clarify docs about waitForNavigation (#2788) 2018-06-26 13:42:50 -07:00
Yaniv Efraim
aae73f5fd7 feat(worker): implement pageerror event from a worker (#2795)
Fixes #2761
2018-06-25 15:10:36 -07:00
Andrey Lushnikov
a460114945
test: fix appveyour flakiness (#2779)
Crashpad sometimes prevents us from removing a folder in tests.

References #2778.
2018-06-20 13:52:36 -07:00
Andrey Lushnikov
4178b989d2
test: add test that breaks subsequent page.goto (#2775)
References #2764.
2018-06-20 13:51:47 -07:00
Andrey Lushnikov
dcae6bcff4
feat(chromium): roll Chromium to r568432 (#2769)
This roll includes:
- https://crrev.com/568341 - DevTools: force-create execution contexts for mixed content iframes

Fixes #2709.
2018-06-19 13:46:08 -07:00
Andrey Lushnikov
37dbfc2608
test: fix random tests flakiness (#2770)
These tests were not awaiting `page.evaluate` command, so
page could have been closed before the command returned.
2018-06-19 10:35:13 -07:00
Andrey Lushnikov
af0bd15d88
test: split out ignoreHTTPSErrors tests (#2745)
We'll get more of these soon.
2018-06-14 16:48:14 -07:00
Andrey Lushnikov
c430138845
test: drop PDF tests (#2744)
We fully rely on upstream PDF functionality. Our PDF tests are inferior
to those upstream and inconvenient to write.
2018-06-14 16:42:10 -07:00
Joel Einbinder
73f9c48081 feat: nicer protocol error messages (#2742)
This patch:
- stops appending `undefined` to our protocol messages unnecessarily.
- rewrites `Cannot find execution context id` to `Execution context was destroyed, most likely because of a navigation.` when it occurs from a Puppeteer ExecutionContext. The error message is left alone if it occurs via a CDPSession.
2018-06-14 15:27:59 -07:00
Yaniv Efraim
9a650c818d feat(element-handle): remove throw in case of empty elementHandle (#2740)
Fixes #2708
2018-06-14 14:28:52 -07:00
Yaniv Efraim
38f112f395 feat(target): add support for target.page for 'backgroud_page' (#2600)
This patch teaches `target.page()` method to attach to extension background pages.

Fixes #2438
2018-06-14 13:58:51 -07:00
Andrey Lushnikov
ddfdaf97c5
fix(page): fix race condition in WaitTask (#2739)
This patch eliminates a common race condition with WaitTask, that
happens when predicate function gets resolved right before the execution
context gets destroyed.
This situation results in a "Cannot find context with specified id undefined"
exception.

Credits go to @jakub300 for his wonderful [investigation](https://github.com/GoogleChrome/puppeteer/issues/1325#issuecomment-395472092).

Fixes #1325.
2018-06-14 11:39:51 -07:00
Georgii Dolzhykov
9498b1057b fix(helpers): support thrown strings and numbers in getExceptionMessage (#2715)
Of course, strings aren't proper errors, but scripts sometimes do that, and Puppeteer loses such error messages.
2018-06-14 10:23:13 -07:00
Georgii Dolzhykov
93e128931f test: make tests work on non-English locales (#2736)
`Data.prototype.toString` may return non-ASCII characters, which aren't accepted by `setHeader`.

E.g., on Russian locale, it might look like this:
```
> new Date().toString()
'Thu Jun 14 2018 13:11:50 GMT+0300 (Финляндия (лето))'
```
2018-06-14 10:18:02 -07:00
Joel Einbinder
75ba86f41a
fix: emit all arguments from worker console logs (#2697)
Log.entryAdded doesn't report all the arguments from console logs. This PR switches to use Runtime.consoleAPICalled.

fixes #2640
2018-06-07 11:21:35 -07:00
Joel Einbinder
2ff0adcad8 feat: worker convenience methods (#2677)
This patch:
- adds `worker.evaluate` and `worker.evaluateHandle` methods as a shortcut to their execution context equivalents.
- makes the error messages a bit nicer when interacting with a closed worker (as opposed to a closed page).
- moves the worker tests into their own spec file.
2018-06-06 20:16:17 -05:00
Andrey Lushnikov
d8023726c5
fix: disable OOPIF by default (#2661)
This patch disables OOPIF by default.

**NOTE**: this is a temporary bandaid for the time we're crafting
the full-fledged support for site isolation over DevTools protocol.

References #2548.
2018-06-01 15:20:37 -07:00
Andrey Lushnikov
9955a1e673
fix(browser): ensure first page is created when browser is launched (#2658)
It's impossible to launch chromium without initial page.
This patch makes sure that `puppeteer.launch()` always returns a browser
with at least one page user can connect to.
2018-06-01 13:57:50 -07:00
Andrey Lushnikov
07b91f61a9
test: split out headful tests into headful.spec.js (#2657) 2018-06-01 13:48:34 -07:00
Andrey Lushnikov
724fa512cf
feat(network): introduce Request.isNavigationRequest() method (#2633)
This patch introduces `Request.isNavigationRequest()` method.

Fixes #2627, #1132.
2018-05-31 17:38:30 -07:00
Jan Potoms
f6356683cd feat(targets): add target.opener() (#2641)
This adds a `.opener` property to a target so that its origin can be tracked.
For now returns `null` when there's no `openerId`.

Fixes #1830
2018-05-31 17:06:29 -07:00
Andrey Lushnikov
0b94fa70eb
chore: stop using console.assert everywhere (#2646)
Since Node 10, `console.assert` no longer throws an AssertionError.
(This is generally good since it aligns Node.js with Browsers.)

This patch migrates all usages of `console.assert` in our codebase.
- All the `lib/` and testing code is migrated onto a handmade `assert`
function. This is to make Puppeteer transpilation / bundling easier.
- All the tooling is switched to use Node's `assert` module.

Fixes #2547.
2018-05-31 16:53:51 -07:00
Andrey Lushnikov
1c0ecc3d9c
test: fix flaky test (#2650)
When launching browser with a default URL, the page is not necessarily
loaded when we're reaching into it.
2018-05-31 16:39:49 -07:00
Andrey Lushnikov
0ba72df67d
test: verify ignoreHTTPSErrors works with puppeteer.connect (#2648)
References #2642.
2018-05-31 16:04:48 -07:00
Joel Einbinder
1c2adf61e9 fix(workers): workaround worker execution context flakiness (#2596)
Some of the worker tests were failing on the bots. After investigating, I found one race in the test, and one race upstream in Chromium which I filed upstream as https://crbug.com/846099. But I added a small hack here as a temporary workaround.

References #2632
2018-05-30 18:08:27 -07:00
Yotam Laufer
469b910a2d feat(page): allow screenshot to return a base64 string (#2586)
Fixes #2566
2018-05-30 14:27:08 -07:00
Joel Einbinder
1bbd094624 feat(test): enable dumpio in tests #2610
This patch allows logging the output of the Chromium process to be enabled in tests by passing in the environment variable `DUMPIO=true`.

Additionally, the `stderr` of the Chromium process will always be logged in the the "Output" section of failing page tests.
2018-05-29 15:45:03 -07:00
Joel Einbinder
8e12d197a2 fix(tests): normalize scrollbars in headful tests (#2622)
Scrollbars look different on different platforms, so must be made invisible in tests. As a drive-by, xdescribe was broken with the new test runner.

References #2524
2018-05-29 15:30:08 -07:00
Yaniv Efraim
b8df8bdf4a feat(launcher): launch browser with 'about:blank' by default (#2594)
fixes #2402
2018-05-25 17:26:40 -07:00
Vasyl Pahut
1e07925e26 feat(elementhandle): add elementHandle.$$eval method (#2589)
Fixes #2401
2018-05-25 16:56:51 -07:00
Alex Veligura
32f4c173c8 feat(page): add page.isClosed method (#2588)
Fixes #2501.
2018-05-25 16:53:57 -07:00
Andrey Lushnikov
debfe7e0b1
fix(page): respect timeout 0 in page.waitForFunction (#2563)
The in-page task should not set timeout when timeout is 0.

Fixes #2540.
2018-05-25 16:45:04 -07:00
Joel Einbinder
93fe2b57d6 feat(Page): introduce workers (#2560)
This adds `page.workers()`, and two events `workercreated` and `workerdestroyed`. It also forwards logs from a worker into the page `console` event.

Only dedicated workers are supported for now, ServiceWorkers will probably work differently because they aren't necessarily associated with a single page.

Fixes #2350.
2018-05-21 14:31:11 -07:00
Yaniv Efraim
b474f2ce87 test: add a missing test for elementHandle. (#2580) 2018-05-21 13:08:31 -07:00
Andrey Lushnikov
2d9e5a0d25
test: add test that validates that pages open with userDataDir arg (#2564)
References #2538.
2018-05-17 14:49:03 -07:00
Andrey Lushnikov
2d82e0891a
chore: bump dependencies (#2559)
This patch bumps dependencies so that `npm audit` doesn't yell
at us.

Drive-by: fix browsercontext test to run nicely in parallel mode.
2018-05-16 15:35:51 -07:00
Rafal Jarmolkovič
23d25a6e12 feat(Target): Pass through "background_page" types (#2439) (#2493) 2018-05-16 14:36:34 -07:00
Andrey Lushnikov
3b03ff65c7
feat(BrowserContext): introduce Browser Contexts. (#2523)
This patch introduces Browser Contexts and methods to manage them:
- `browser.createIncognitoBrowserContext()` - to create new incognito
  context
- `browser.browserContext()` - to get all existing contexts
- `browserContext.dispose()` - to dispose incognito context.

Fixes #85.
2018-05-10 13:26:08 -07:00
Denny Ku(kuni)
88b996877f feat(ElementHandle): introduce elementHandle.$eval (#2407)
This patch introduces `elementHandle.$eval` method.

References #2401.
2018-05-08 18:17:59 -07:00
Joel Einbinder
1d225cfa17 fix: allow user gesture restricted code to be run in page.evaluate (#2503)
Fixes #2502
2018-05-04 21:45:16 +03:00
Andrey Lushnikov
a310d57d84
feat(Page): add option to run 'beforeunload' when closing the page (#2478)
Today, `page.close()` method doesn't run page's beforeunload listeners.
This way users can be sure that `page.close()` actually closes the
page.

This patch adds an optional `runBeforeUnload` option to the
`page.close()` method that would run beforeunload listeners. Note:
running beforeunload handlers might cancel page closing.

Fixes #2386.
2018-05-03 01:51:45 +03:00
Yaniv Efraim
e236887bbb feat(Page): report 'Log' domain entries as 'console' events (#2400)
Fixes #1939
2018-04-28 00:40:09 -04:00
Andrey Lushnikov
58c46680f3
fix(Page): fix page.goto to return Response when page pushes new state (#2468)
]Fixes #2411.
2018-04-28 00:15:40 -04:00
Andrey Lushnikov
eded38c82a
test: verify file url interception works as expected (#2451)
This was fixed upstream: https://crrev.com/550319
Rolled into pptr: https://github.com/GoogleChrome/puppeteer/pull/2393

Fixes #1506.
2018-04-26 13:32:23 -07:00
Andrey Lushnikov
b96815aa72
test: verify Page.goto fails when server returns 204 (#2452)
Fixed upstream: https://crrev.com/551261
Rolled into pptr: https://github.com/GoogleChrome/puppeteer/pull/2393

Fixes #1879.
2018-04-25 20:20:11 -07:00
yujiosaka
e9dc3ae74f test(server): Fix mismatch between args and annotations (#2426) 2018-04-23 10:01:16 -07:00
Andrey Lushnikov
37cc9f567d
chore(deps): bump dependencies (#2397)
Fixes #2394
2018-04-17 14:51:03 -07:00
Yaniv Efraim
ed4be10ae3 Chore: replace depracated 'new Buffer' with 'Buffer.from' (#2396)
See [Buffer](https://nodejs.org/docs/latest-v9.x/api/buffer.html) for more details
2018-04-17 13:49:01 -07:00
Arne Martin Aurlien
082b11aa57 Add Page.browser() method (#2387)
Call page.browser() to get the browser instance associated with a
page.

Fixes #2275
2018-04-17 10:37:17 -07:00
Andrey Lushnikov
6eb6ce0ec9
test: make sure page.goto works when subframes return 204. (#2361)
References #1879.
2018-04-16 16:53:10 -07:00
Yaniv Efraim
98bb2615ad feat(Tracing): return a buffer from tracing.stop (#2360)
Fixes #2148
2018-04-12 08:26:50 -07:00
Andrey Lushnikov
04991ad025
test: consolidate network tests in one file (#2355) 2018-04-11 15:25:42 -07:00
Andrey Lushnikov
f8cba455ba
fix(Network): explicitly throw on content request for redirect response (#2352)
DevTools protocol doesn't support returning body of redirect responses.
We should explicitly throw in this case.

References #1896.
2018-04-10 20:22:18 -07:00
Andrey Lushnikov
18f2ecdffd
fix(Launcher): launch chrome with --disable-dev-shm-usage by default (#2351)
Fixes #1834.
2018-04-10 20:05:27 -07:00
Andrey Lushnikov
0b64242f85
test: add missing rm function to test.js (#2349)
This was missing while we were splitting the tests.

Fixes #2236.
2018-04-10 18:05:10 -07:00
Andrey Lushnikov
a7d59b587e
fix(Page): Page.waitForNavigation should correctly handle mixed content (#2339)
This patch teaches Page.waitForNavigation to correctly handle navigation
to pages that have frames that might never load.

These frames include:
- frames which main resource loading was aborted due to mixed-content
  error
- frames that artificially called `window.stop()` to interrupt loading
  themselves

Fixes #1936.
2018-04-10 15:59:41 -07:00
Andrey Lushnikov
5089d2ec2e
fix(BrowserFetcher): ensure executable has proper permissions (#2342)
This patch ensures Chromium executable has permissions to be executed
by non-owner users.

Fixes #2283.
2018-04-10 14:11:59 -07:00
Andrey Lushnikov
fafd156d7b
fix(Page): support anchor navigation (#2338)
This patch fixes puppeteer navigation primitives to work with
same-document navigation.

Same-document navigation happens when document's URL is changed,
but document instance is not re-created. Some common scenarios
for same-document navigation are:
- History API
- anchor navigation

With this patch:
- pptr starts dispatching `framenavigated` event when frame's URL gets
changed due to same-document navigation
- `page.waitForNavigation` now works with same-document navigation
- `page.goBack()` and `page.goForward()` are handled correctly.

Fixes #257.
2018-04-09 23:38:20 -07:00
Andrey Lushnikov
c5902de5d8
fix(Page): fix Page.evaluate with Symbols in arrays (#2340)
Fixes #2295.
2018-04-09 22:02:35 -07:00
Andrey Lushnikov
5d106f79d8
test: flatten tests (#2337)
Today, we have tests split into multiple files, with files pulling
tests from some other files.

This patch starts explicitly gathering all tests from the same
`test.js` file.

Drive-By: move one test from `browser.spec.js` into `puppeteer.spec.js`
since it starts browser itself.
2018-04-09 16:38:00 -07:00
Andrey Lushnikov
06d61919ef
test: refactor utils.waitForEvents into utils.waitEvent (#2336)
This simplifies waiting for events in tests.
2018-04-09 15:46:05 -07:00
Andrey Lushnikov
c86c12e605
fix(Launcher): consume protocol errors when initiating browser.close() (#2332)
Handle errors properly while sending Browser.close()

Fixes #1429.
2018-04-09 14:49:02 -07:00
Andrey Lushnikov
45d97e572a
feat(Chromium): roll Chromium to r549031 (#2327)
This roll includes:
- https://crrev.com/549003 - DevTools: make pptr tests pass with DCHECKs.

The patch fixes a browser crash that happens during browser close.
As a result, cookies were not saved properly (and thus the flaky test we
had).

Fixes #1537.
2018-04-06 21:53:25 -07:00
Andrey Lushnikov
35e34db198
feat(Page): introduce Page.setBypassCSP (#2324)
This patch introduces `page.setBypassCSP` method that allows clients
to ignore Content-Security-Policy for a given page.

Fixes #1229.
2018-04-06 16:35:50 -07:00
Andrey Lushnikov
846c0800b1
feat(Page): Page.addScriptTag should throw when blocked by CSP (#2320)
This patch teaches Page.addScriptTag and Page.addStyleTag to throw
an error when blocked by CSP.

References #1229.
2018-04-06 13:17:55 -07:00
Andrey Lushnikov
4663b43a62
test: add test on Page.evaluateOnNewDocument with CSP (#2319)
This patch adds a test that Page.evaluateOnNewDocument works
with CSP: there's been some concerns on the bugtracker before.

References #1229
2018-04-05 23:40:14 -07:00
Andrey Lushnikov
98093f0763
feat(Chromium): roll Chromium to r548153 (#2312)
This roll includes:
- https://crrev.com/547982 - v8 roll that includes [fixed
  Runtime.callFunctionOn](1637818671) method

The upstream fix makes it possible to run frame.waitFor* functions on
pages with strict CSP.

References #1229.
2018-04-04 13:56:24 -07:00
Andrey Lushnikov
f925158733
test: add test for page.waitForFunction with script CSP (#2305)
This patch adds a test to fixate page.waitForFunction behavior
for pages with CSP.

References #1229.
2018-04-03 15:21:08 -07:00
JoelEinbinder
94c32e4bc8 feat(Launcher): introduce pipe option (#2288)
This patch introduces a new `pipe` option to the launcher to connect over a pipe.

In certain environments, exposing web socket for remote debugging is a security risk.
Pipe connection eliminates this risk.
2018-04-03 15:05:27 -07:00
Yaniv Efraim
dde45faaeb feat(FrameManage): improve errors from frame.waitFor* methods (#2292)
This patch adds title for WaitTask, using it later in generating error messages and
making exceptions much more traceable.

Fixes #2037
2018-03-30 12:37:56 -07:00
Andrey Lushnikov
c4da19bd23
test(ElementHandle.boxModel): remake test to make it more readable (#2287)
This patch:
- re-makes test for EH.boxModel to make it more readable
- slightly changes wording in the `docs/api.md`.

References #1357.
2018-03-29 17:25:52 -07:00
Yaniv Efraim
41d5838297 feat(ElementHandle): add ElementHandle.boxModel method (#2256)
This patch introduces ElementHandle.boxModel to get element's
box model.

Fixes #1357
2018-03-29 13:52:28 -07:00
Yaniv Efraim
ebe17371b0 chore: break page.spec.js to smaller files (#2257)
Break some large chunks into smaller files. This change will remove ~600 lines from `page.spec.js`
2018-03-29 10:42:23 -07:00
Yaniv Efraim
abb05e069d feat(page): add an option to disable timeout for waitForFunction (#2252)
This patch adds support for `timeout: 0` to disable timeout for the following functions:
- `page.waitForFunction`
- `page.waitForXPath`
- `page.waitForSelector`
and their `frame` counterparts.

Fixes #2200
2018-03-28 16:34:37 -07:00
JoelEinbinder
d46e157f19 feat(Page): page 'close' event (#2232)
This patch adds 'page.close' event.

References #952.
2018-03-28 13:11:51 -07:00
Yaniv Efraim
47481967c5 test: Break 'page.spec.js' to smaller files (#2218)
This patch breaks huge `page.spec.js` into a bunch of smaller files.
2018-03-19 20:00:12 -07:00
Yaniv Efraim
38c6873fbb test: break test.js into smaller files (#2193)
This patch breaks test.js into smaller files:
- `page.spec.js`
- `puppeteer.spec.js`

Fixes #2082
2018-03-16 15:33:31 -07:00
Andrey Lushnikov
ec3025fe84
feat(Network): implement request.redirectChain() api (#2194)
The request.redirectChain() returns all the requests issued to fetch
the resource.

Fixes #1816.
2018-03-15 17:17:38 -07:00
Andrey Lushnikov
c4b1ac99b0
test: another attempt to fix sw test #2201 2018-03-15 16:58:02 -07:00
Andrey Lushnikov
150e5a9bbf
test: eliminate racy pattern in multiple tests (#2202)
This patch eliminates a race pattern we've been using in a bunch
of tests.
2018-03-15 16:53:34 -07:00
JoelEinbinder
309cafb876 feat(Chromium): roll chromium to r543305 (#2196)
This roll contains a [fix](https://chromium-review.googlesource.com/c/chromium/src/+/963302) for boundingBox not forcing a layout, and the patch contains a corresponding test.
2018-03-15 16:37:10 -07:00
Andrey Lushnikov
4b7fbf8ee0
test: fix serviceWorker test flakiness (#2195)
This patch starts waiting on serviceWorker registration.
2018-03-14 17:55:12 -07:00
Yaniv Efraim
625c7ebdda feat(FrameManager): add type=module to addScriptTag (#2090)
This patch adds a new "type" option to the `addScriptTag` method that
allows adding "module" tags to the page.

Fixes #2078
2018-03-14 13:07:48 -07:00
Juan Sebastian velez Posada
52d3bc05de feat(Page): introduce url at error message at page.goto (#2174)
Now the error message will come with the url where the error was
generated.

Fixes #2165.
2018-03-12 15:38:05 -07:00
JoelEinbinder
0defecf197 fix(test): add missing test for making sure chrome is closed (#2109) 2018-03-07 09:01:43 +03:00
Andrey Lushnikov
223b59254c
feat(ElementHandle): implement ElementHandle.contentFrame() (#2094)
This patch adds ElementHandle.contentFrame() method that allows
to get a reference to the Frame owned by the iframe.

Fixes #433.
2018-02-23 21:22:53 -08:00
JoelEinbinder
e2b96df4d7 chore(test): simplify element screenshot tests (#2093) 2018-02-23 15:54:26 -08:00
Frankie Bagnardi
56a475f86b feat: elHandle:screenshot captures full element (#1787)
feat: make ElementHandle.screenshot work with large elements

This patch increases the viewport size if the element is bigger than
viewport.

Fixes #1779
2018-02-23 14:13:08 -08:00
Andrey Lushnikov
fc2a10440f
fix(evaluate): throw error when page reloads during page.evaluate. (#2073)
Fixes #2021.
2018-02-22 19:10:17 -08:00
Yaniv Efraim
66887743ea fix(Launcher): fix dumpio bug (#2071)
This patch fixes `dumpio` launcher option.

Fixes #2046
2018-02-22 19:06:13 -08:00
JoelEinbinder
d75fdb7098 fix(Browser): wait for the page to close in the browser in page.close (#2064)
Fixes #1491
2018-02-21 16:08:29 -08:00
Andrey Lushnikov
fc94f98247
feat(Targets): expose browser target (#2036)
This patch exposes "browser" target to the list of targets.
2018-02-15 13:24:24 -08:00
Andrey Lushnikov
e8a085ccfb
feat(appMode): support pipes for appMode (#2032)
This patch starts using pipes as a transport to
the browser instance instead of websocket.
2018-02-14 17:51:29 -08:00
Andrey Lushnikov
43c0feb2f2
fix(Network): fulfill security details for response redirects (#2025)
This patch:
- starts fulfilling security details for redirect responses
- changes `response.securityDetails()` to return null if the response
  is served over non-secure connection
2018-02-14 16:08:20 -08:00
Andrey Lushnikov
ee5ec3e630
test: await browser closing in tests (#2022) 2018-02-13 14:39:13 -08:00
Andrey Lushnikov
ae22ef30b3
feat(ExecutionContext): introduce ExecutionContext.frame() (#1972)
This patch introduces ExecutionContext.frame() that returns Frame
associated with this Execution Context.

This allows to associate console messages with the originating frame,
if any.
2018-02-13 14:02:44 -08:00
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
JoelEinbinder
700244a29a test: dont race against the mutation observer (#2016) 2018-02-13 11:00:38 -08:00