diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cbc3f6e5..0dbb7341 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,7 +60,7 @@ jobs: - name: Build and toolchain regressions / 构建及工具链回归 working-directory: desktop - run: node --test scripts/check-built-syntax.test.mjs scripts/check-monaco-sanitizer.test.mjs scripts/check-jsdom-undici.test.mjs scripts/check-source-map.test.mjs scripts/check-nanoid.test.mjs scripts/check-browserslist.test.mjs scripts/windows-resource-reporter.test.mjs + run: node --test scripts/check-built-syntax.test.mjs scripts/check-monaco-sanitizer.test.mjs scripts/check-jsdom-undici.test.mjs scripts/check-source-map.test.mjs scripts/check-nanoid.test.mjs scripts/check-browserslist.test.mjs scripts/windows-resource-reporter.test.mjs scripts/check-playwright-windows-socket.test.mjs - name: Documentation artifact isolation / 文档产物隔离 working-directory: desktop diff --git a/desktop/package.json b/desktop/package.json index 138fc24f..cf5565fd 100644 --- a/desktop/package.json +++ b/desktop/package.json @@ -69,7 +69,8 @@ "monaco-editor@0.54.0>dompurify": "3.4.17" }, "patchedDependencies": { - "monaco-editor@0.54.0": "patches/monaco-editor@0.54.0.patch" + "monaco-editor@0.54.0": "patches/monaco-editor@0.54.0.patch", + "playwright-core@1.61.0": "patches/playwright-core@1.61.0.patch" } } } diff --git a/desktop/patches/playwright-core@1.61.0.patch b/desktop/patches/playwright-core@1.61.0.patch new file mode 100644 index 00000000..ae2b299d --- /dev/null +++ b/desktop/patches/playwright-core@1.61.0.patch @@ -0,0 +1,13 @@ +diff --git a/lib/coreBundle.js b/lib/coreBundle.js +index 1d36a373cb14a856c9a69e218df5183bb250d2f0..30a4e53f61e91f359f02a08d2a647bd80d368b48 100644 +--- a/lib/coreBundle.js ++++ b/lib/coreBundle.js +@@ -34423,6 +34423,8 @@ var init_chromiumSwitches = __esm({ + "AutoDeElevate", + // See https://github.com/microsoft/playwright/issues/37714 + "RenderDocument", ++ // Backport Playwright #43605 for Windows loopback errors. / 回移 Playwright #43605,缓解 Windows 本地回环错误。 ++ "TcpPortRandomizationWin", + // Prevents downloading optimization hints on startup. + "OptimizationHints", + // Disables forced sign-in in Edge. diff --git a/desktop/pnpm-lock.yaml b/desktop/pnpm-lock.yaml index 8969e772..c1f77e97 100644 --- a/desktop/pnpm-lock.yaml +++ b/desktop/pnpm-lock.yaml @@ -11,6 +11,9 @@ patchedDependencies: monaco-editor@0.54.0: hash: c7f64946d625e479b23bdb9d4061de89e58669cad61f1ce650b62157bb8a7200 path: patches/monaco-editor@0.54.0.patch + playwright-core@1.61.0: + hash: 5da6c72b3cda8868adc235fbdccb10d019c2c1598385e2e47e97b4e219dae970 + path: patches/playwright-core@1.61.0.patch importers: @@ -5172,11 +5175,11 @@ snapshots: dependencies: find-up: 3.0.0 - playwright-core@1.61.0: {} + playwright-core@1.61.0(patch_hash=5da6c72b3cda8868adc235fbdccb10d019c2c1598385e2e47e97b4e219dae970): {} playwright@1.61.0: dependencies: - playwright-core: 1.61.0 + playwright-core: 1.61.0(patch_hash=5da6c72b3cda8868adc235fbdccb10d019c2c1598385e2e47e97b4e219dae970) optionalDependencies: fsevents: 2.3.2 diff --git a/desktop/scripts/check-playwright-windows-socket.test.mjs b/desktop/scripts/check-playwright-windows-socket.test.mjs new file mode 100644 index 00000000..99fa02ae --- /dev/null +++ b/desktop/scripts/check-playwright-windows-socket.test.mjs @@ -0,0 +1,46 @@ +import { spawnSync } from "node:child_process"; +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { fileURLToPath } from "node:url"; + +test("Playwright preserves its defaults and disables Windows TCP port randomization / Playwright 保留默认设置并禁用 Windows TCP 端口随机化", () => { + // Node exits on Chromium's flags without starting a browser or server. / Node 遇到 Chromium 参数即退出,不启动浏览器或服务器。 + const launch = ` + const { chromium } = require('@playwright/test'); + chromium.launch({ executablePath: process.execPath }).catch(() => {}); + `; + const result = spawnSync(process.execPath, ["-e", launch], { + cwd: fileURLToPath(new URL("..", import.meta.url)), + env: { ...process.env, DEBUG: "pw:browser" }, + encoding: "utf8", + timeout: 15_000, + }); + assert.equal(result.error, undefined); + assert.equal(result.status, 0); + const line = result.stderr.split(/\r?\n/).find((entry) => entry.includes("")); + assert.ok(line, "launch arguments are available / 可读取启动参数"); + const featureArgs = [...line.matchAll(/(?:^|\s)--disable-features=([^\s]+)/g)]; + assert.equal(featureArgs.length, 1, "one effective feature list / 仅有一个生效的特性列表"); + const features = new Set(featureArgs[0][1].split(",")); + for (const feature of [ + "AvoidUnnecessaryBeforeUnloadCheckSync", + "BoundaryEventDispatchTracksNodeRemoval", + "DestroyProfileOnBrowserClose", + "DialMediaRouteProvider", + "GlobalMediaControls", + "HttpsUpgrades", + "LensOverlay", + "MediaRouter", + "PaintHolding", + "ThirdPartyStoragePartitioning", + "Translate", + "AutoDeElevate", + "RenderDocument", + "OptimizationHints", + "msForceBrowserSignIn", + "msEdgeUpdateLaunchServicesPreferredVersion", + "TcpPortRandomizationWin", + ]) { + assert.ok(features.has(feature), `missing feature / 缺少特性: ${feature}`); + } +});