chore: convert console resource to tool (#193)

This commit is contained in:
Pavel Feldman
2025-04-15 18:01:59 -07:00
committed by GitHub
parent e4331313f9
commit 5c2e11017d
7 changed files with 66 additions and 61 deletions

View File

@@ -111,18 +111,21 @@ export class Context {
if (this._currentTab === tab)
this._currentTab = this._tabs[Math.min(index, this._tabs.length - 1)];
const browser = this._browser;
if (this._browserContext && !this._tabs.length) {
void this._browserContext.close().then(() => browser?.close()).catch(() => {});
this._browser = undefined;
this._browserContext = undefined;
}
if (this._browserContext && !this._tabs.length)
void this.close();
}
async close() {
if (!this._browserContext)
return;
await this._browserContext.close();
const browserContext = this._browserContext;
const browser = this._browser;
this._browserContext = undefined;
this._browser = undefined;
await browserContext?.close().then(async () => {
await browser?.close();
}).catch(() => {});
}
private async _ensureBrowserContext() {