From 5fba0dc93220ae518942a2363b72e89718bceaf7 Mon Sep 17 00:00:00 2001 From: jrandolf <101637635+jrandolf@users.noreply.github.com> Date: Wed, 24 Aug 2022 17:04:54 +0200 Subject: [PATCH] chore: remove unnecessary constructor parameters (#8837) --- src/common/Frame.ts | 14 ++------------ src/common/IsolatedWorld.ts | 25 +++++++++++++------------ 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/src/common/Frame.ts b/src/common/Frame.ts index 62ad69cd63d..0c74b4206ff 100644 --- a/src/common/Frame.ts +++ b/src/common/Frame.ts @@ -211,18 +211,8 @@ export class Frame { updateClient(client: CDPSession): void { this.#client = client; this.worlds = { - [MAIN_WORLD]: new IsolatedWorld( - client, - this._frameManager, - this, - this._frameManager.timeoutSettings - ), - [PUPPETEER_WORLD]: new IsolatedWorld( - client, - this._frameManager, - this, - this._frameManager.timeoutSettings - ), + [MAIN_WORLD]: new IsolatedWorld(this), + [PUPPETEER_WORLD]: new IsolatedWorld(this), }; } diff --git a/src/common/IsolatedWorld.ts b/src/common/IsolatedWorld.ts index 2a3b0a4d948..66a79b56471 100644 --- a/src/common/IsolatedWorld.ts +++ b/src/common/IsolatedWorld.ts @@ -121,10 +121,7 @@ export interface IsolatedWorldChart { * @internal */ export class IsolatedWorld { - #frameManager: FrameManager; - #client: CDPSession; #frame: Frame; - #timeoutSettings: TimeoutSettings; #documentPromise: Promise> | null = null; #contextPromise: DeferredPromise = createDeferredPromise(); #detached = false; @@ -148,21 +145,25 @@ export class IsolatedWorld { return `${name}_${contextId}`; }; - constructor( - client: CDPSession, - frameManager: FrameManager, - frame: Frame, - timeoutSettings: TimeoutSettings - ) { + constructor(frame: Frame) { // Keep own reference to client because it might differ from the FrameManager's // client for OOP iframes. - this.#client = client; - this.#frameManager = frameManager; this.#frame = frame; - this.#timeoutSettings = timeoutSettings; this.#client.on('Runtime.bindingCalled', this.#onBindingCalled); } + get #client(): CDPSession { + return this.#frame._client(); + } + + get #frameManager(): FrameManager { + return this.#frame._frameManager; + } + + get #timeoutSettings(): TimeoutSettings { + return this.#frameManager.timeoutSettings; + } + frame(): Frame { return this.#frame; }