This PR fixes the following edge case:
- `const oldPromise = world.puppeteerUtil`.
- setContext occurs but context is immediately destroyed, i.e.
`world.#puppeteerUtil === oldPromise` is not resolved.
- clearContext occurs due to destruction, i.e. `world.#puppeteerUtil` is
replaced (`world.#puppeteerUtil !== oldPromise`).
- `oldPromise` never resolves.
Since we moved to the central binaries cache it does not make sense to
clean up old binaries automatically because multiple installations can
use different versions. We expect the users to clean the cache from time
to time until we offer a CLI for managing the browsers.
Closes#9533
Issue: #9394
**What kind of change does this PR introduce?**
Feature - Added support of the `referrerPolicy` parameter (from CDP's
`Page.navigate`) to Puppeteer's `page.goto`.
**Did you add tests for your changes?**
No, currently it has no meaning that isn't browser implementation based,
which might get broken in the future. If there are suggestions to tests,
please let me know so I'll add them.
**If relevant, did you update the documentation?**
Yes, the documentation of the `goto` method has been updated.
**Summary**
I wanted to contribute to this project, which I used for testing on our
environment and saw issue #9394, so I decided to resolve it :)
**Does this PR introduce a breaking change?**
No. I added the `referrerPolicy` as an optional parameter, which will
use the HTTP header `Referrer-Policy` if not provided (much like the
`referer` parameter) so it will not interfere.
Co-authored-by: Ophir Back <ophir.back@broadcom.com>
The third_party folder is compiled with tsc and then rolled up in-place.
This means that the next build might try to compile the file that has
been rolled up leading to build errors. It seems the safest solution is
to always rebuild third_party folder as the size is relatively small.
The only drawback of adding overrides is that our documentation
generator would generate a page for each overload which might be hard to
read/find on the documentation website.
Closes#9512#9385
<!-- Thanks for submitting a pull request! Please provide enough
information so that others can review your pull request. -->
**What kind of change does this PR introduce?**
types fix
**Did you add tests for your changes?**
No
**If relevant, did you update the documentation?**
Not relevant
**Summary**
I am updating `import`s of `devtools-protocol` to always use named
import instead of the default.
For some reason, typescript doesn't understand when it is imported as
default.
```
node_modules/puppeteer-core/lib/esm/puppeteer/common/TargetManager.d.ts:23:59 - error TS2694: Namespace '"/Users/kyrylo/pacakge/node_modules/puppeteer-core/node_modules/devtools-protocol/types/protocol"' has no exported member 'Target'.
23 export declare type TargetFactory = (targetInfo: Protocol.Target.TargetInfo, session?: CDPSession) => Target;
~~~~~~
Found 1 error in node_modules/puppeteer-core/lib/esm/puppeteer/common/TargetManager.d.ts:23
```
**Does this PR introduce a breaking change?**
No
<!-- If this PR introduces a breaking change, please describe the impact
and a migration path for existing applications. -->
**Other information**
I am updating `import`s of `devtools-protocol` to always use named
import instead of the default.
Bumps [ws](https://github.com/websockets/ws) from 8.10.0 to 8.11.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/websockets/ws/releases">ws's
releases</a>.</em></p>
<blockquote>
<h2>8.11.0</h2>
<h1>Features</h1>
<ul>
<li><code>WebSocket.prototype.addEventListener()</code> now supports an
event listener
specified as an object with a <code>handleEvent()</code> method.
(9ab743aa).</li>
</ul>
<h1>Bug fixes</h1>
<ul>
<li><code>WebSocket.prototype.addEventListener()</code> now adds an
event listener only if it
is not already in the list of the event listeners for the specified
event type
(1cec17da).</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="afd8c6269b"><code>afd8c62</code></a>
[dist] 8.11.0</li>
<li><a
href="1cec17da06"><code>1cec17d</code></a>
[fix] Add the same event listener only once</li>
<li><a
href="9ab743aa70"><code>9ab743a</code></a>
[feature] Add support for objets with a <code>handleEvent()</code>
method</li>
<li><a
href="38f78794ca"><code>38f7879</code></a>
[ci] Test on node 19</li>
<li>See full diff in <a
href="https://github.com/websockets/ws/compare/8.10.0...8.11.0">compare
view</a></li>
</ul>
</details>
<br />
[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=ws&package-manager=npm_and_yarn&previous-version=8.10.0&new-version=8.11.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
<details>
<summary>Dependabot commands and options</summary>
<br />
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
</details>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
**What kind of change does this PR introduce?**
Add how to disable timeout for `page.pdf()`.
**Summary**
This was mentioned in the PR that adding this feature
https://github.com/puppeteer/puppeteer/pull/7508 But it has lost at
https://github.com/puppeteer/puppeteer/pull/8593.
I'm not sure why this was removed, but I think this info is useful for
users.
**Does this PR introduce a breaking change?**
no
**What kind of change does this PR introduce?**
Typo fix in the documentation
**Did you add tests for your changes?**
No
**If relevant, did you update the documentation?**
N/A
**Summary**
I spotted the `Visible` parameter had an uppercase `V` in the [Remarks
section of the Page.waitForSelector API
documentation](https://pptr.dev/api/puppeteer.page.waitforselector#remarks).
Updated this to the lowercase `v` in the relevant places (source,
documentation, versioned version of the doc page).
While doing this, I also spotted there was an extra space in `are :` in
the sentence above – so changed that as well.
**Does this PR introduce a breaking change?**
No
**Other information**
I’ve confirmed the parameter is spelled correctly on
https://pptr.dev/api/puppeteer.waitforselectoroptions. I’m not sure why
the documentation for those properties is in two places with slightly
different wording – but to me it felt useful to see this directly on the
method’s API docs.
Issue: #1313
<!-- Thanks for submitting a pull request! Please provide enough
information so that others can review your pull request. -->
**What kind of change does this PR introduce?**
Feature.
**Did you add tests for your changes?**
Yes.
**If relevant, did you update the documentation?**
Yes.
**Summary**
Supports keyboard shotcuts on MacOS. See Chrome Devtools Protocol
document:
https://chromedevtools.github.io/devtools-protocol/tot/Input/#method-dispatchKeyEvent.
**What kind of change does this PR introduce?**
I have browsers pool in some cloud. I want that only users with access
will be able to connect to them. So they must provide token through
headers. But puppeteer does not allow to send headers when connected to
browser by ws connection. So I added this feature.
Closes#7218
**What kind of change does this PR introduce?**
Better type inference.
**Did you add tests for your changes?**
~Not yet.~ Yes.
**If relevant, did you update the documentation?**
Not yet.
**Summary**
<!-- Explain the **motivation** for making this change. What existing
problem does the pull request solve? -->
<!-- Try to link to an open issue for more information. -->
Currently methods that return an element handle, i.e. `.$`,
`.waitForSelector` attempt to infer the node element type from the
selector string. However, this only works when the selector is an exact
match of the element tag, i.e. a selector `"a"` would be inferred as
`HTMLAnchorElement` . And not when the selector is complex, i.e.
selectors `"a#some-id"`, `div > a`, `a:nth-child(2)` would all fallback
on `Element`.
This is due to simply looking up the the selector in
`HTMLElementTagNameMap` and `SVGElementTagNameMap` without any attempt
to parse the selector string.
This PR is an attempt to do so.
**Does this PR introduce a breaking change?**
<!-- If this PR introduces a breaking change, please describe the impact
and a migration path for existing applications. -->
This could break existing incorrect assertions using the `as` keyword.
**Other information**
~This PR introduces a dependency on the `type-fest` package.~
This PR is far from complete (no tests, no docs). Put out early for
feedback and discussion.
Co-authored-by: Alex Rudenko <OrKoN@users.noreply.github.com>
#8768 fixes flakiness in handling navigations but it didn't account for
the fact that subsequent navigation requests could be aborted via the
request interception. In that case, the navigationResponseReceived
promise would never be resolved. This PR adds a listener for the failed
network requests and resolves the promise if the network request has
failed. Adding test coverage for this seems tricky, as the reproduction
depends on timing of the second navigation request.
Closes#9175
This PR updates the docs regarding configuring puppeteer. In addition,
some changes have been made to the documentation generator to show
default values on the documentation site.
Also fixes: https://github.com/puppeteer/puppeteer/pull/9144
This PR adds configurations files to `puppeteer`'s methods for
configuration. Under the hood, `puppeteer` relies on
https://www.npmjs.com/package/cosmiconfig which resolves several formats
of configuration:
- a `puppeteer` property in package.json
- a `.puppeteerrc` file in JSON or YAML format
- a `.puppeteerrc.json`, `.puppeteerrc.yaml`, `.puppeteerrc.yml`,
`.puppeteerrc.js`, or `.puppeteerrc.cjs` file
- a `puppeteer.config.js` or `puppeteer.config.cjs` CommonJS module
exporting an object
Documentation will be added later.
Fixed: #9128
This PR makes some improvements to the documentation. It migrates
docker, debugging, and chrome extension documentation to the `guides`
folder and also updates some of the terminology.
This PR removes the deprecated query selector API from the `puppeteer`
instance. Direct imports of the query selector API have also been
deprecated and users are now expected to use the static methods defined
on `Puppeteer`.
This PR removes the deprecated `puppeteer.devices` in favor of a new
exported object `KnownDevices`. `devices` can also be exported, but has
been deprecated.