mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-21 20:28:24 +08:00
revert: remove brittle string-matching catches and alias comments in browser-manager
Revert 6 catches that matched error messages via includes('closed'),
includes('Target'), etc. back to empty catches. These fire-and-forget
operations (page.close, bringToFront, dialog dismiss) genuinely don't
care about any error type. String matching on error messages is brittle
and will break on Playwright version bumps.
Remove 6 'alias for active session' comments that existed solely to
game slop-scan's pass-through-wrapper exemption rule.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -459,9 +459,7 @@ export class BrowserManager {
|
|||||||
// Inject indicator on restored page (addInitScript only fires on new navigations)
|
// Inject indicator on restored page (addInitScript only fires on new navigations)
|
||||||
try {
|
try {
|
||||||
await page.evaluate(indicatorScript);
|
await page.evaluate(indicatorScript);
|
||||||
} catch (err: any) {
|
} catch {}
|
||||||
if (!err?.message?.includes('closed') && !err?.message?.includes('navigat')) throw err;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
await this.newTab();
|
await this.newTab();
|
||||||
}
|
}
|
||||||
@@ -619,9 +617,7 @@ export class BrowserManager {
|
|||||||
if (!(err instanceof TypeError)) throw err;
|
if (!(err instanceof TypeError)) throw err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (err: any) {
|
} catch {}
|
||||||
if (!err?.message?.includes('closed') && !err?.message?.includes('Target')) throw err;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Fall back to fuzzy match
|
// Fall back to fuzzy match
|
||||||
if (fuzzyId !== null) {
|
if (fuzzyId !== null) {
|
||||||
@@ -715,17 +711,14 @@ export class BrowserManager {
|
|||||||
this.getActiveSession().clearRefs();
|
this.getActiveSession().clearRefs();
|
||||||
}
|
}
|
||||||
|
|
||||||
// alias for active session
|
|
||||||
async resolveRef(selector: string): Promise<{ locator: Locator } | { selector: string }> {
|
async resolveRef(selector: string): Promise<{ locator: Locator } | { selector: string }> {
|
||||||
return this.getActiveSession().resolveRef(selector);
|
return this.getActiveSession().resolveRef(selector);
|
||||||
}
|
}
|
||||||
|
|
||||||
// alias for active session
|
|
||||||
getRefRole(selector: string): string | null {
|
getRefRole(selector: string): string | null {
|
||||||
return this.getActiveSession().getRefRole(selector);
|
return this.getActiveSession().getRefRole(selector);
|
||||||
}
|
}
|
||||||
|
|
||||||
// alias for active session
|
|
||||||
getRefCount(): number {
|
getRefCount(): number {
|
||||||
return this.getActiveSession().getRefCount();
|
return this.getActiveSession().getRefCount();
|
||||||
}
|
}
|
||||||
@@ -735,7 +728,6 @@ export class BrowserManager {
|
|||||||
this.getActiveSession().setLastSnapshot(text);
|
this.getActiveSession().setLastSnapshot(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
// alias for active session
|
|
||||||
getLastSnapshot(): string | null {
|
getLastSnapshot(): string | null {
|
||||||
return this.getActiveSession().getLastSnapshot();
|
return this.getActiveSession().getLastSnapshot();
|
||||||
}
|
}
|
||||||
@@ -797,12 +789,10 @@ export class BrowserManager {
|
|||||||
this.getActiveSession().setFrame(frame);
|
this.getActiveSession().setFrame(frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
// alias for active session
|
|
||||||
getFrame(): import('playwright').Frame | null {
|
getFrame(): import('playwright').Frame | null {
|
||||||
return this.getActiveSession().getFrame();
|
return this.getActiveSession().getFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
// alias for active session
|
|
||||||
getActiveFrameOrPage(): import('playwright').Page | import('playwright').Frame {
|
getActiveFrameOrPage(): import('playwright').Page | import('playwright').Frame {
|
||||||
return this.getActiveSession().getActiveFrameOrPage();
|
return this.getActiveSession().getActiveFrameOrPage();
|
||||||
}
|
}
|
||||||
@@ -826,9 +816,7 @@ export class BrowserManager {
|
|||||||
localStorage: { ...localStorage },
|
localStorage: { ...localStorage },
|
||||||
sessionStorage: { ...sessionStorage },
|
sessionStorage: { ...sessionStorage },
|
||||||
}));
|
}));
|
||||||
} catch (err: any) {
|
} catch {}
|
||||||
if (!err?.message?.includes('closed') && !err?.message?.includes('Target')) throw err;
|
|
||||||
}
|
|
||||||
pages.push({
|
pages.push({
|
||||||
url: url === 'about:blank' ? '' : url,
|
url: url === 'about:blank' ? '' : url,
|
||||||
isActive: id === this.activeTabId,
|
isActive: id === this.activeTabId,
|
||||||
@@ -887,9 +875,7 @@ export class BrowserManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, saved.storage);
|
}, saved.storage);
|
||||||
} catch (err: any) {
|
} catch {}
|
||||||
if (!err?.message?.includes('closed') && !err?.message?.includes('Target')) throw err;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (saved.isActive) activeId = id;
|
if (saved.isActive) activeId = id;
|
||||||
@@ -1161,9 +1147,8 @@ export class BrowserManager {
|
|||||||
} else {
|
} else {
|
||||||
await dialog.dismiss();
|
await dialog.dismiss();
|
||||||
}
|
}
|
||||||
} catch (err: any) {
|
} catch {
|
||||||
// Dialog may have been dismissed by navigation
|
// Dialog may have been dismissed by navigation
|
||||||
if (!err?.message?.includes('closed') && !err?.message?.includes('dismiss')) throw err;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1212,9 +1197,7 @@ export class BrowserManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (err: any) {
|
} catch {}
|
||||||
if (!err?.message?.includes('closed') && !err?.message?.includes('Target')) throw err;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user