Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove extraneous parameters from IsolatedWorld constructor #8837

Merged
merged 1 commit into from Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 2 additions & 12 deletions src/common/Frame.ts
Expand Up @@ -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),
};
}

Expand Down
25 changes: 13 additions & 12 deletions src/common/IsolatedWorld.ts
Expand Up @@ -121,10 +121,7 @@ export interface IsolatedWorldChart {
* @internal
*/
export class IsolatedWorld {
#frameManager: FrameManager;
#client: CDPSession;
#frame: Frame;
#timeoutSettings: TimeoutSettings;
#documentPromise: Promise<ElementHandle<Document>> | null = null;
#contextPromise: DeferredPromise<ExecutionContext> = createDeferredPromise();
#detached = false;
Expand All @@ -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;
}
Expand Down