mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix(performance): use Runtime.getProperties for improved performance (#12561)
This commit is contained in:
parent
0b2999f7b1
commit
8b2059f82a
@ -87,6 +87,23 @@ export class CdpJSHandle<T = unknown> extends JSHandle<T> {
|
|||||||
override remoteObject(): Protocol.Runtime.RemoteObject {
|
override remoteObject(): Protocol.Runtime.RemoteObject {
|
||||||
return this.#remoteObject;
|
return this.#remoteObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override async getProperties(): Promise<Map<string, JSHandle<unknown>>> {
|
||||||
|
// 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<string, JSHandle>();
|
||||||
|
for (const property of response.result) {
|
||||||
|
if (!property.enumerable || !property.value) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
result.set(property.name, this.#world.createCdpHandle(property.value));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user