refactor: reuse otherTarget on createTarget (#10957)

This commit is contained in:
Darío Kondratiuk 2023-09-20 10:58:30 -03:00 committed by GitHub
parent af42663edb
commit 3fc8da9955
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -275,7 +275,7 @@ export class CdpBrowser extends BrowserBase {
const createSession = (isAutoAttachEmulated: boolean) => { const createSession = (isAutoAttachEmulated: boolean) => {
return this.#connection._createSession(targetInfo, isAutoAttachEmulated); return this.#connection._createSession(targetInfo, isAutoAttachEmulated);
}; };
const targetForFilter = new OtherTarget( const otherTarget = new OtherTarget(
targetInfo, targetInfo,
session, session,
context, context,
@ -294,7 +294,7 @@ export class CdpBrowser extends BrowserBase {
this.#screenshotTaskQueue this.#screenshotTaskQueue
); );
} }
if (this.#isPageTargetCallback(targetForFilter)) { if (this.#isPageTargetCallback(otherTarget)) {
return new PageTarget( return new PageTarget(
targetInfo, targetInfo,
session, session,
@ -318,13 +318,7 @@ export class CdpBrowser extends BrowserBase {
createSession createSession
); );
} }
return new OtherTarget( return otherTarget;
targetInfo,
session,
context,
this.#targetManager,
createSession
);
}; };
#onAttachedToTarget = async (target: CdpTarget) => { #onAttachedToTarget = async (target: CdpTarget) => {