Commit Graph

998 Commits

Author SHA1 Message Date
Pablo Matías Gomez
9787a1d8df
fix: clean up tmp profile dirs when browser is closed (#8580)
* fix: clean up tmp profile dirs when browser is closed
2022-06-27 07:40:30 +02:00
Alex Rudenko
fb7d31e369
feat(chromium): roll to Chromium 104.0.5109.0 (r1011831) (#8569)
* feat(chromium): roll to Chromium 104.0.5109.0 (r1011831)

* test: update a11y test expectations
2022-06-24 14:13:31 +00:00
Alex Rudenko
383e855847
fix: CSS coverage should work with empty stylesheets (#8570)
Closes #8535
2022-06-24 14:17:16 +02:00
jrandolf
8100cbb295
fix: infer unioned handles (#8562) 2022-06-24 06:40:08 +00:00
jrandolf
ebcb8a2760
chore: split JSHandle.ts (#8551) 2022-06-23 11:31:43 +02:00
jrandolf
26c3acbb07
feat!: type inference for evaluation types (#8547)
This PR greatly improves the types within Puppeteer:

- **Almost everything** is auto-deduced.
  - Parameters don't need to be specified in the function. They are deduced from the spread.
  - Return types don't need to be specified. They are deduced from the function. (More on this below)
  - Selections based on tag names correctly deduce element type, similar to TypeScript's mechanism for `getElementByTagName`.
- [**BREAKING CHANGE**] We've removed the ability to declare return types in type arguments for the following reasons:
  1. Setting them will indubitably break auto-deduction.
  2. You can just use `as ...` in TypeScript to coerce the correct type (given it makes sense).
- [**BREAKING CHANGE**] `waitFor` is officially gone.

To migrate to these changes, there are only four things you may need to change:
- If you set a return type using the `ReturnType` type parameter, remove it and use `as ...` and `HandleFor` (if necessary).
 `evaluate<ReturnType>(a: number, b: number) => {...}, a, b)`
 `(await evaluate(a, b) => {...}, a, b)) as ReturnType`
 `evaluateHandle<ReturnType>(a: number, b: number) => {...}, a, b)`
 `(await evaluateHandle(a, b) => {...}, a, b)) as HandleFor<ReturnType>`
- If you set any type parameters in the *parameters* of an evaluation function, remove them.  
 `evaluate(a: number, b: number) => {...}, a, b)`
 `evaluate(a, b) => {...}, a, b)`
- If you set any type parameters in the method's declaration, remove them.
 `evaluate<(a: number, b: number) => void>((a, b) => {...}, a, b)`
 `evaluate(a, b) => {...}, a, b)`
2022-06-23 11:29:46 +02:00
jrandolf
347101883f
chore: split Launcher.ts (#8544) 2022-06-23 00:13:39 +02:00
jrandolf
84712cbc28
chore: use Google's TS style guide's format config (#8542) 2022-06-22 15:25:44 +02:00
jrandolf
ce0dd25349
chore: use braces in function bodies (#8525) 2022-06-15 12:42:21 +02:00
jrandolf
570087ea94
chore: use strict typing in tests (#8524)
* The testing tsconfig.json inherits from the base TS config.
  * A lot of type assertions have been inserted...a lot.
* All testing utilities have migrated to TS.
* text-diff is being replaced with diff for TS compatibility.
* ProtocolError has been added to PuppeteerErrors and PuppeteerErrors is no longer a record (it's been frozen).
* Fixes a small bug where null was an allowable media type in emulation (should be undefined).
2022-06-15 12:09:22 +02:00
jrandolf
80373f7a12
chore: use composite builds for tests (#8522) 2022-06-15 12:05:25 +02:00
jrandolf
e6442dd767
chore: use curly (#8519) 2022-06-14 13:55:35 +02:00
jrandolf
0678343b53
chore: move helper.js to util.js (#8510) 2022-06-14 13:16:21 +02:00
jrandolf
6c960115a3
chore: use private fields (#8506) 2022-06-13 11:16:25 +02:00
jrandolf
733cbecf48
chore: use c8 coverage (#8495) 2022-06-10 18:49:14 +02:00
jrandolf
4d359906a4
fix: use error-like (#8504) 2022-06-10 15:27:42 +02:00
Alex Rudenko
58ff348b76
chore: skip an oopif test for headful and chrome headless (#8501) 2022-06-10 12:39:18 +02:00
jrandolf
75c3f94a54
chore: namespace commands (#8494) 2022-06-10 11:55:53 +02:00
jrandolf
465a7c405f
feat: export puppeteer methods (#8493) 2022-06-09 19:00:50 +02:00
jrandolf
b30f3f44cd
fix: parse empty options in <select> (#8489) 2022-06-09 13:27:34 +02:00
jrandolf
e8378666c6
fix: don't throw on bad access (#8472) 2022-06-07 16:17:21 +02:00
Alex Rudenko
5c9050aea0
fix: use isPageTargetCallback in Browser::pages() (#8460) 2022-06-02 13:27:31 +02:00
jrandolf
30438e6532
chore: use ts-doc and factor out importFSModule (#8449) 2022-06-01 11:11:09 +02:00
jrandolf
b4e751f29c
feat: use strict typescript (#8401) 2022-05-31 16:34:16 +02:00
Junyan
92110151d9
fix: multiple same request event listener (#8404) 2022-05-30 20:34:08 +00:00
Julian Descottes
f866274360
chore: enable anchor navigation tests for Firefox (#8394) 2022-05-25 06:46:17 +00:00
Alex Rudenko
f657233ca4
test: skip dumpio test in non-headless modes (#8388) 2022-05-24 11:50:49 +00:00
Alex Rudenko
ea47ff0766
chore: fix failing test for the chrome headless (#8364) 2022-05-19 07:41:29 +00:00
jrandolf
74380303ac
fix: only check loading iframe in lifecycling (#8348) 2022-05-17 12:15:44 +00:00
Alex Rudenko
24dfbd5f7f
chore: remove console.log from test (#8351) 2022-05-16 10:04:57 +02:00
Alex Rudenko
3b66a2c47e
feat: allow handling other targets as pages internally (#8336)
Co-authored-by: jrandolf <101637635+jrandolf@users.noreply.github.com>
2022-05-13 08:04:46 +02:00
Alex Rudenko
0ae8936f5e
chore: disable failing permission test (#8337) 2022-05-12 20:09:23 +02:00
Pirikara
a61144d437
fix: If currentNode and root are the same, do not include them in the result (#8332)
* fix: If currentNode and root are the same, do not include them in the result

* fix: Tests that only child element is included in the result

Co-authored-by: jrandolf <101637635+jrandolf@users.noreply.github.com>
2022-05-11 12:17:02 +00:00
Alex Rudenko
7eaadafe19
feat: add waitForXPath to ElementHandle (#8329) 2022-05-10 12:45:20 +02:00
Alex Rudenko
553959884f
fix: make sure inner OOPIFs can be attached to (#8304) 2022-05-04 07:46:38 +02:00
Alex Rudenko
e841d7f9f3
fix: tests failing in headful (#8273)
* fix: test failing in headful

* fix: install Firefox for headful tests

* fix: skip favicon.ico requests in test

* fix: auth test in headful

* fix: disable NetworkTimeServiceQuerying

* fix: filter more favicon requests

* fix: network test with favicon

* fix: improve fixes
2022-05-02 11:37:21 +02:00
Darío Kondratiuk
f39eb70f2f
test: run Frame.evaluate tests on Firefox (#8296) 2022-05-02 08:21:19 +02:00
Darío Kondratiuk
25d363bf9c
test: move async predicate to waitForResponse describe (#8285) 2022-04-28 14:51:57 +00:00
jrandolf
7a51bff47f
feat: add back and forward mouse buttons (#8284) 2022-04-27 21:00:07 +00:00
Alex Rudenko
912dfbaf48
test: disable a failing Firefox test (#8286) 2022-04-27 17:34:53 +02:00
Alex Rudenko
1308d9aa6a
feat: support chrome headless mode (#8260)
* feat: support chrome headless mode

Co-authored-by: Ergün Erdoğmuş <erdogmusergun@gmail.com>
2022-04-25 13:11:23 +02:00
Henrik Skupin
c6cf1a9f27 fix: use different test names for browser specific tests in launcher.spec.ts (#8250) 2022-04-20 12:09:40 +02:00
Matheus Marabesi
e93faadc21
fix(network.spec.ts): typo in the word should (#8223) 2022-04-19 13:24:53 +00:00
Henrik Skupin
b6504d7186
fix: also kill Firefox when temporary profile is used (#8233)
* fix: also kill Firefox when temporary profile is used

* fix: use separate tests for Puppeteer.launch should filter out ignored default arguments
2022-04-19 12:09:23 +00:00
Joel Baranick
91a8e73b11
fix: forget queuedEventGroup when emitting response in responseReceivedExtraInfo (#8234) (#8239) 2022-04-19 09:28:44 +00:00
Julian Descottes
2b45027d25
fix: enable page.spec event handler test for firefox (#8214) 2022-04-08 13:01:03 +00:00
Julian Descottes
04e5c88997
fix: ignore favicon requests in page.spec event handler tests (#8208) 2022-04-07 16:06:12 +00:00
Alex Rudenko
0955225b51
fix: consider existing frames when waiting for a frame (#8200) 2022-04-07 15:05:36 +02:00
Junyan
c1dcd857e3
feat: respond multiple headers with same key (#8183) 2022-04-05 09:06:35 +00:00
Junyan
37ede68770
fix: get extra headers from Fetch.requestPaused event (#8162) 2022-03-28 07:54:24 +00:00
Alex Rudenko
34775e5831
fix: waitForNavigation in OOPIFs (#8117) 2022-03-09 12:24:17 +01:00
James Diefenderfer
3feca325a9
fix: Inherit browser-level proxy settings from incognito context (#7770)
* chore: add request proxy tests

* fix: inherit browser-level proxy settings from incognito context

* fix: skip test on Windows
2022-03-07 10:12:26 +00:00
Matheus Marabesi
9ca57f190c
chore(network): avoid using if/else inside test case (#8095) 2022-03-04 07:50:09 +01:00
Martina Ferrari
3b8b9adde5
fix(tests): ensure all tests honour BINARY envvar (#8092)
Without this patch, two tests ignore the BINARY envvar, and fail when not using
the embedded chromium, unless the chromium executable path is defined via
PUPPETEER_EXECUTABLE_PATH, which should not be considered according to the
docs.
2022-03-03 14:05:49 +00:00
Alex Rudenko
85decdc28d
fix: regression in --user-data-dir handling (#8060) 2022-02-23 19:21:17 +00:00
jrandolf
e9278fcfcf
feat: export Frame._client through getter (#8041)
Co-authored-by: Randolf Jung <jrandolf@chromium.org>
2022-02-21 14:58:37 +00:00
Tmk
dbf0639822
feat: add support for async waitForTarget (#7885)
* feat: add support for async waitForTarget

* fix: add timeout

* fix: potential async bugs
2022-02-18 12:05:29 +01:00
Michael Mok
5c308b0704
fix: ensure dom binding is not called after detach (#8024)
* fix: ensure dom binding is not called after detatch

Fixes #7814

* refactor: detach listeners instead

* refactor: safer approach

* fix: test in test/page.spec.ts

Co-authored-by: Alex Rudenko <OrKoN@users.noreply.github.com>
2022-02-17 15:52:51 +00:00
omjadas
30b3d49b0d
feat(HTTPResponse): expose timing information (#8025) 2022-02-15 11:16:49 +01:00
Nick Schonning
b2bf70fc3b
chore: update prettier globs and format files (#7856)
* chore: update prettier globs and format files

* fix: remove reference to Markdownlint
2022-02-11 20:29:43 +01:00
Josh Bielick
6d6ea9bf59
fix: always use ENV executable path when present (#7985)
Some recent changes to allow arm64 environments (including M1 macs) to
launch a chromium installation successfully before arm-compatible builds
were downloadable prevented the usage of PUPPETEER_EXECUTABLE_PATH in
some environments. Currently, when the platform is not darwin and the
arch is arm64, an executable cannot be specified using the environment
variable.

Generally speaking, environment variables have highest precedence for
options such as this since they depend on system configuration.

These change:

1. allow the ENV variable to always be used when defined and not
   specified in LaunchOptions (and when not puppeteer-core)
2. Retain the existing behavior of assuming /usr/bin/chromium-browser on
   platforms like Ubuntu (exact if-conditions preserved to avoid any
   breaking changes)
3. Add some tests for this particular portion of the code.
2022-02-11 13:07:31 +00:00
jrandolf
8ff9d598bf
chore(deps): update deps
Signed-off-by: Randolf Jung <jrandolf@chromium.org>

Co-authored-by: Randolf Jung <jrandolf@chromium.org>
2022-02-09 14:49:25 +00:00
jrandolf
96c3f943b2
feat(chromium): roll to Chromium 99.0.4844.16 (r961656) (#7960)
Co-authored-by: Randolf Jung <jrandolf@chromium.org>
2022-02-04 12:18:53 +01:00
Alex Rudenko
a55c86fac5
feat(chromium): roll to Chromium 98.0.4758.0 (r950341) (#7907) 2022-01-17 13:40:38 +00:00
Alex Rudenko
a566263ba2
fix: apply OOPIF offsets to bounding box and box model calls (#7906)
The doc for boundingBox says that it should return the boundingBox
relative to the main frame, therefore, this fix would make the
actual implementation correspond to the documentation. boxModel
documentation does not have this note but I think it'd make sense
to have it match the behaviour of the boundingBox API.
2022-01-17 14:19:43 +01:00
Alex Rudenko
d7937b806d
fix: error for pre-existing OOPIFs (#7899)
Issues: #7844, #7896
2022-01-17 07:00:00 +00:00
Alex Rudenko
486bbe010d
fix: correctly compute clickable points for elements inside OOPIFs (#7900)
Issues: #7849
2022-01-17 07:32:52 +01:00
Alex Rudenko
8d8e874b07
fix: make sure ElementHandle.waitForSelector is evaluated in the right context (#7843)
So it appears that all bindings are added to the secondary world and all
evaluations are also running there. ElementHandle.evaluate is returning
handles from the main world though. Therefore, we need to be careful
and adopt handles to the right context before doing waitForSelector
So it appears that all bindings are added to the secondary world and all
evaluations are also running there. ElementHandle.evaluate is returning
handles from the main world though. Therefore, we need to be careful
and adopt handles to the right context before doing waitForSelector.
2021-12-21 09:53:20 +01:00
Alex Rudenko
1c44551f1b
fix: predicate arguments for waitForFunction (#7845)
The same predicate function is used by the waitForFunction
API that does not need the context element.

Issues: #7836
2021-12-15 08:40:56 +00:00
Alex Rudenko
36207c5efe
fix: disable a test failing on Firefox (#7846) 2021-12-15 09:17:56 +01:00
Ben Allfree
824242246d
fix!: typo in 'already-handled' constant of the request interception API (#7813)
Issues:  #7745, #7747, #7780
Co-authored-by: Rodrigo Fernández <fdez.romero@gmail.com>
2021-12-09 14:57:40 +00:00
Alex Rudenko
c03429444d
feat: implement Element.waitForSelector (#7825)
Co-authored-by: Johan Bay <jobay@google.com>
Co-authored-by: Mathias Bynens <mathias@qiwi.be>
2021-12-09 11:51:14 +00:00
Ben Allfree
dc23b7535c
feat: expose HTTPRequest intercept resolution state and clarify docs (#7796)
Co-authored-by: Rodrigo Fernández <fdez.romero@gmail.com>
2021-12-07 08:48:42 +01:00
Ben Allfree
636b0863a1
fix: handle multiple/duplicate Fetch.requestPaused events (#7802)
Issues: #7475, #6696, #7225
2021-12-03 20:13:44 +01:00
Alex Rudenko
a26b12b7c7
fix: parse statusText from the extraInfo event (#7798)
Issues: #7458
2021-11-26 09:17:34 +01:00
Alex Rudenko
ac162c561e
feat(chromium)!: roll to Chromium 97.0.4692.0 (r938248)
Issues: #7458
2021-11-23 08:19:14 +01:00
Henrik Skupin
4c3caaa3f9
chore: re-enable tests for Firefox related to fixed Input.dispatchMouseEvent issues (#7776)
Issues: #7115
2021-11-19 08:50:31 +01:00
Henrik Skupin
790c7a0eb9
feat: support for custom user data (profile) directory for Firefox (#7684)
When using a custom Firefox profile for Puppeteer the modified
preferences as present in prefs.js need to be reset once the
profile is no longer needed by Puppeteer. If not done this could
cause side-effects when the profile is used next time outside
of Puppeteer.

As ride-along fix the "--foreground" argument for Firefox will
only be used on MacOS because that's the only supported platform.
2021-11-10 13:31:15 +01:00
Andy Earnshaw
b0319ecc89
fix(ariaqueryhandler): allow single quotes in aria attribute selector (#7750)
This updates the regular expression used to parse aria attribute
selectors so that single quotes may be used as an alternative to double
quotes, e.g. `aria/Single button[role='button']`.

Issues: #7721

Co-authored-by: Andy Earnshaw <andy.earnshaw@gmail.com>
2021-11-09 13:05:10 +01:00
Jan Scheffler
03c9ecca40
feat: improve error message for response.buffer() (#7669) 2021-10-29 13:44:40 +00:00
Jan Scheffler
4d9dc8c0e6
feat(oop iframes)!: integrate OOP iframes with the frame manager (#7556)
This pull request to adds better support for OOP iframes (see #2548)

The current problem with OOP iframes is that they are moved to a different target. Because of this, the previous versions of Puppeteer pretty much ignored them.
This change extends the FrameManager to already take OOP iframes into account and hides the fact that those frames are actually in different targets.
Further work needs to be done to also make the NetworkManager aware of these and to make sure that settings like emulations etc. are also properly passed down to the new targets.
2021-10-28 11:25:49 +02:00
Jan Scheffler
07febca04b
feat: handle unhandled promise rejections in tests (#7722)
In some situations, Puppeteer is left in an invalid state because protocol errors that could have been handled by the user where just hidden from them. This patch removes some of these cases and also makes sure that unhandled promise rejections lead to a test failure in mocha.
2021-10-27 13:43:57 +02:00
Jan Scheffler
2d37430838
chore: update types for JSHandle (#7650)
Closes #7583
2021-10-07 16:04:08 +00:00
Edgard Lorraine Messias
d0cb9436a3
fix(page): fix page.off method for request event (#7624)
This patch fixes page.off for request event

Closes: #7572
2021-10-04 06:59:46 +00:00
Mikkel Snitker
fd607b1095
chore: propagate 'Invalid header' errors (#7020)
Enable developers to handle 'Invalid header' errors instead of hiding them to make sure they can address them properly.
Co-authored-by: Jan Scheffler <janscheffler@chromium.org>
2021-10-04 06:18:03 +00:00
Josh Grime
44c9ec67c5
fix(page): fallback to default in exposeFunction when using imported module (#6365) 2021-09-29 18:32:49 +02:00
Jan Scheffler
a271145b06
feat: add initiator to HTTPRequest (#7614)
Co-Authored-By: atersolis <atersolis@atersolis.net>
2021-09-29 15:14:21 +00:00
Tan Li Hau
26145e9a24
feat: add custom debugging port option (#4993) 2021-09-29 16:05:18 +02:00
Darío Kondratiuk
7069cfedda
test: remove duplicated test on jshandle.spec.ts (#7606)
`should work with primitives` is a duple of `should use the same JS wrappers`
2021-09-28 09:26:42 +00:00
Jan Scheffler
113489d3b5
fix(launcher): launcher.launch() should pass 'timeout' option #5180 (#7596)
Co-authored-by: Bob Jamison <bob.jamison@pearson.com>
2021-09-27 10:01:35 +02:00
dmitrysteblyuk
f2e19276ac
chore: add hared TaskQueue for page.screenshot() again (#6714) 2021-09-23 14:37:35 +02:00
Alex Rudenko
7341d9fadd
fix: request an animation frame to fix flaky clickablePoint test (#7587)
Sometimes an element has not been layed out yet and, in this case,
clickablePoint fails because backend cannot compute content quads.

Co-authored-by: Jan Scheffler <janscheffler@chromium.org>
2021-09-22 12:48:24 +02:00
Jonathan Church
43a9268325
feat: add webp to screenshot options (#7565) 2021-09-21 14:26:20 +00:00
Alex Rudenko
99ca842124
feat(page): expose page.client() (#7582)
Puppeteer already allows creating a new CDP session
via target.createCDPSession but there is no way
to get access to any existing session to send
some additional commands.
2021-09-21 07:39:47 +00:00
Alex Rudenko
2b5c0019dc
feat: add ability to specify offsets for JSHandle.click (#7573)
Until now, the click would be always sent to the middle
point of the target element. With this change, one can define
offsets relative to the border box of the elements and click
different areas of an element.
2021-09-20 09:01:32 +00:00
Max White
eda5171279
feat: add durableStorage to allowed permissions (#5295) 2021-09-16 10:35:36 +00:00
Ron0115
54c4318016
feat: add threshold to Page.isIntersectingViewport (#6497) 2021-09-15 22:56:50 +02:00
Yosuke Kurami
cb4470a6d9
feat(coverage): option for raw V8 script coverage (#6454) 2021-09-15 18:54:24 +00:00
Xavier Prud'homme
caa2b732fe
fix(frame): fix Frame.waitFor's XPath pattern detection (#5184)
Up to now, only strings starting with '//' are considered as to XPath selectors. Unfortunately, this is too restricting. This fix allows valid XPath selectors starting with: '/', './', and even '(//*[1])'
2021-09-15 11:45:59 +00:00
Peter Marshall
726cb14003
chore: remove unused tracing category for cpu profiling (#5866) 2021-09-15 11:59:38 +02:00