From c12512822a546e7bfdefd2c68f020aab2a308f4f Mon Sep 17 00:00:00 2001 From: zeeker999 <13848632+zeeker999@users.noreply.github.com> Date: Wed, 19 Apr 2023 17:00:08 +0800 Subject: [PATCH] feat(webworker): expose WebWorker.client (#10042) Co-authored-by: Alex Rudenko --- docs/api/puppeteer.webworker.md | 6 ++++++ packages/puppeteer-core/src/common/WebWorker.ts | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/docs/api/puppeteer.webworker.md b/docs/api/puppeteer.webworker.md index d0f683ffae9..3723f438ce4 100644 --- a/docs/api/puppeteer.webworker.md +++ b/docs/api/puppeteer.webworker.md @@ -36,6 +36,12 @@ for (const worker of page.workers()) { } ``` +## Properties + +| Property | Modifiers | Type | Description | +| -------- | --------------------- | --------------------------------------- | ------------------------------------------------ | +| client | readonly | [CDPSession](./puppeteer.cdpsession.md) | The CDP session client the WebWorker belongs to. | + ## Methods | Method | Modifiers | Description | diff --git a/packages/puppeteer-core/src/common/WebWorker.ts b/packages/puppeteer-core/src/common/WebWorker.ts index d4265741e55..fface119ad1 100644 --- a/packages/puppeteer-core/src/common/WebWorker.ts +++ b/packages/puppeteer-core/src/common/WebWorker.ts @@ -122,6 +122,13 @@ export class WebWorker extends EventEmitter { return this.#url; } + /** + * The CDP session client the WebWorker belongs to. + */ + get client(): CDPSession { + return this.#client; + } + /** * If the function passed to the `worker.evaluate` returns a Promise, then * `worker.evaluate` would wait for the promise to resolve and return its