fix(stealth): 修复 launch 选项与测试基线不一致问题

在 stealth 默认策略下保留自定义 user-agent,不再被 CDP 覆盖。

同步更新 protocol/browser/launch/file-access 相关测试预期,并放宽 browser.test 的 hook 超时以消除偶发超时。
This commit is contained in:
leeguooooo
2026-02-24 17:42:12 +09:00
parent aef8fcc038
commit ec011f46ff
6 changed files with 48 additions and 30 deletions
+7 -2
View File
@@ -445,7 +445,10 @@ export class BrowserManager {
): Promise<void> {
const policy = this.getStealthPolicy();
if (!policy.applyInitScripts) return;
await applyStealthScripts(context, options);
await applyStealthScripts(context, {
...options,
userAgent: this.contextUserAgent,
});
this.logStealthPolicy('init-script applied');
}
@@ -1693,7 +1696,9 @@ export class BrowserManager {
this.cdpEndpoint = null;
if (stealthPolicy.enabled && browserType === 'chromium') {
await applyBrowserLevelStealth(this.browser);
await applyBrowserLevelStealth(this.browser, {
userAgent: contextUserAgent,
});
}
if (!options.userAgent && stealthPolicy.enabled && browserType === 'chromium') {