diff --git a/src/common/ElementHandle.ts b/src/common/ElementHandle.ts index 3078ee202ca8a..6737960733971 100644 --- a/src/common/ElementHandle.ts +++ b/src/common/ElementHandle.ts @@ -1,9 +1,8 @@ import {Protocol} from 'devtools-protocol'; import {assert} from '../util/assert.js'; -import {CDPSession} from './Connection.js'; import {ExecutionContext} from './ExecutionContext.js'; -import {FrameManager} from './FrameManager.js'; import {Frame} from './Frame.js'; +import {FrameManager} from './FrameManager.js'; import { MAIN_WORLD, PUPPETEER_WORLD, @@ -80,13 +79,12 @@ export class ElementHandle< */ constructor( context: ExecutionContext, - client: CDPSession, remoteObject: Protocol.Runtime.RemoteObject, frame: Frame, page: Page, frameManager: FrameManager ) { - super(context, client, remoteObject); + super(context, remoteObject); this.#frame = frame; this.#page = page; this.#frameManager = frameManager; diff --git a/src/common/JSHandle.ts b/src/common/JSHandle.ts index 70536309260e9..c2c070bbdafb5 100644 --- a/src/common/JSHandle.ts +++ b/src/common/JSHandle.ts @@ -78,7 +78,6 @@ export class JSHandle { */ [__JSHandleSymbol]?: T; - #client: CDPSession; #disposed = false; #context: ExecutionContext; #remoteObject: Protocol.Runtime.RemoteObject; @@ -87,7 +86,7 @@ export class JSHandle { * @internal */ get client(): CDPSession { - return this.#client; + return this.#context._client; } /** @@ -102,11 +101,9 @@ export class JSHandle { */ constructor( context: ExecutionContext, - client: CDPSession, remoteObject: Protocol.Runtime.RemoteObject ) { this.#context = context; - this.#client = client; this.#remoteObject = remoteObject; } @@ -196,7 +193,7 @@ export class JSHandle { assert(this.#remoteObject.objectId); // We use Runtime.getProperties rather than iterative building because the // iterative approach might create a distorted snapshot. - const response = await this.#client.send('Runtime.getProperties', { + const response = await this.client.send('Runtime.getProperties', { objectId: this.#remoteObject.objectId, ownProperties: true, }); @@ -247,7 +244,7 @@ export class JSHandle { return; } this.#disposed = true; - await releaseObject(this.#client, this.#remoteObject); + await releaseObject(this.client, this.#remoteObject); } /** diff --git a/src/common/WebWorker.ts b/src/common/WebWorker.ts index 83495267dc7fe..1b42822373d30 100644 --- a/src/common/WebWorker.ts +++ b/src/common/WebWorker.ts @@ -93,7 +93,7 @@ export class WebWorker extends EventEmitter { return consoleAPICalled( event.type, event.args.map((object: Protocol.Runtime.RemoteObject) => { - return new JSHandle(context, this.#client, object); + return new JSHandle(context, object); }), event.stackTrace ); diff --git a/src/common/util.ts b/src/common/util.ts index b242d2c3a142d..025e3dab254df 100644 --- a/src/common/util.ts +++ b/src/common/util.ts @@ -222,14 +222,13 @@ export function createJSHandle( const frameManager = frame._frameManager; return new ElementHandle( context, - context._client, remoteObject, frame, frameManager.page(), frameManager ); } - return new JSHandle(context, context._client, remoteObject); + return new JSHandle(context, remoteObject); } /**