diff --git a/packages/puppeteer-core/src/cdp/JSHandle.ts b/packages/puppeteer-core/src/cdp/JSHandle.ts index bba5f96b5db..9238c6f3982 100644 --- a/packages/puppeteer-core/src/cdp/JSHandle.ts +++ b/packages/puppeteer-core/src/cdp/JSHandle.ts @@ -87,6 +87,23 @@ export class CdpJSHandle extends JSHandle { override remoteObject(): Protocol.Runtime.RemoteObject { return this.#remoteObject; } + + override async getProperties(): Promise>> { + // We use Runtime.getProperties rather than iterative version for + // improved performance as it allows getting everything at once. + const response = await this.client.send('Runtime.getProperties', { + objectId: this.#remoteObject.objectId!, + ownProperties: true, + }); + const result = new Map(); + for (const property of response.result) { + if (!property.enumerable || !property.value) { + continue; + } + result.set(property.name, this.#world.createCdpHandle(property.value)); + } + return result; + } } /**