Commit Graph

963 Commits

Author SHA1 Message Date
jrandolf
5cf9b4de8d
feat: use an xpath query handler (#8730) 2022-08-04 15:45:21 +02:00
Alex Rudenko
2abd772c9c feat: detect Firefox in connect() automatically (#8718)
This PR implements automatic detection of the Firefox product when the `.connect()` method is used. This partially undoes the breaking change in https://github.com/puppeteer/puppeteer/pull/8520 but it's also a breaking change on its own since we don't accept an explicit product name anymore (it does not look like it was used anyway).
2022-08-02 13:18:51 +00:00
Alex Rudenko
6f81b23728 fix: address flakiness in frame handling (#8688)
When we attach to a frame, we send a call to get
the page frame tree from CDP. Based on the tree data
we look up the parent frame if parentId is provided.
The problem is that the call to get the page frame
tree could take arbitrary time and the calls for the
parent and child frames might happen at the same time.
So the situation where the frame tree for the child frame
is resolved before the parent frame is known is fairly
common.

This PR addresses the issue by awaiting for the parent
frame id before attempting to register a child frame.
2022-08-02 13:18:47 +00:00
Alex Rudenko
2cbfdeb0ca feat: use CDP's auto-attach mechanism (#8520)
* feat: use CDP's auto-attach mechanism

In this PR, we refactor Puppeteer to make use of the CDP's auto-attach mechanism. This allows the backend to pause
new targets and give Puppeteer a chance to configure them properly. This fixes the flakiness related to dealing with
OOPIFs and should fix some other issues related to the network interception and navigations. If those are not fixed completely by this PR, the PR serves a solid base for fixing them.

Closes https://github.com/puppeteer/puppeteer/issues/8507, https://github.com/puppeteer/puppeteer/issues/7990
Unlocks https://github.com/puppeteer/puppeteer/issues/3667

BREAKING CHANGE: With Chromium, Puppeteer will now attach to page/iframe targets immediately to allow reliable configuration of targets.
2022-08-02 13:18:07 +00:00
Alex Rudenko
2abb9f0c14
fix: taking a screenshot with null viewport should be possible (#8680)
Closes #8673
2022-07-21 10:34:18 +02:00
Alex Rudenko
af08c5c903
feat: expose the page getter on Frame (#8657)
* feat: expose the page getter on Frame

Closes #8654

* test: add a test
2022-07-11 21:06:35 +02:00
Asen Bozhilov
b47f066c2c
fix(page): fix page.#scrollIntoViewIfNeeded method (#8631)
This patch fixes page.#scrollIntoViewIfNeeded, so that it works with devtools protocol.
Now it blocks the main thread and waits until the scrolling action finishes in Chrome.
Fallbacks to the old implementation if `DOM.scrollIntoViewIfNeeded` is not supported for Firefox.

Issues: #8627, #1805
2022-07-08 06:53:45 +00:00
Alex Rudenko
d0c4291995
fix: expose a RemoteObject getter (#8642)
Closes #8639
2022-07-07 13:04:28 +00:00
jrandolf
5ff205dc8b
fix: extends ElementHandle to Nodes (#8552)
* fix: extends `ElementHandle` to `Node`s (#8552)
2022-07-06 09:05:37 +02:00
jrandolf
28e236f1a6
chore: use --parallel (#8612) 2022-07-05 14:42:55 +02:00
jrandolf
32c9f3e6fb
chore: update contributing.md (#8616) 2022-07-01 16:29:21 +02:00
jrandolf
066f440ba7
feat: add documentation (#8593) 2022-07-01 11:52:39 +00:00
Levi Pesin
79e11985ba
feat: add fromSurface option to page.screenshot (#8496) 2022-06-27 12:37:37 +00:00
Alex Rudenko
329195011f
chore: fix chrome-headless ci (#8560) 2022-06-27 12:35:09 +02:00
jrandolf
7001322cd1
feat: export public types only (#8584) 2022-06-27 09:24:23 +02:00
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