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