fix(browser): clamp non-finite viewport dimensions · openclaw/openclaw@59cec74
steipete
·
2026-05-29
·
via Recent Commits to openclaw:main
File tree
extensions/browser/src/browser
| Original file line number | Diff line number | Diff line change |
|---|
@@ -203,6 +203,21 @@ describe("pw-tools-core aria snapshot storage", () => {
|
203 | 203 | ); |
204 | 204 | }); |
205 | 205 | |
| 206 | +it("clamps non-finite viewport dimensions to the minimum size", async () => { |
| 207 | +const page = { setViewportSize: vi.fn(async () => {}) }; |
| 208 | +getPageForTargetId.mockResolvedValue(page); |
| 209 | + |
| 210 | +const mod = await import("./pw-tools-core.snapshot.js"); |
| 211 | +await mod.resizeViewportViaPlaywright({ |
| 212 | +cdpUrl: "http://127.0.0.1:9222", |
| 213 | +targetId: "tab-1", |
| 214 | +width: Number.NaN, |
| 215 | +height: Number.POSITIVE_INFINITY, |
| 216 | +}); |
| 217 | + |
| 218 | +expect(page.setViewportSize).toHaveBeenCalledWith({ width: 1, height: 1 }); |
| 219 | +}); |
| 220 | + |
206 | 221 | it("stores role fallback metadata when backend markers are unavailable", async () => { |
207 | 222 | const page = { id: "page-1" }; |
208 | 223 | const mod = await import("./pw-tools-core.snapshot.js"); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -455,8 +455,8 @@ export async function resizeViewportViaPlaywright(opts: {
|
455 | 455 | const page = await getPageForTargetId(opts); |
456 | 456 | ensurePageState(page); |
457 | 457 | await page.setViewportSize({ |
458 | | -width: Math.max(1, Math.floor(opts.width)), |
459 | | -height: Math.max(1, Math.floor(opts.height)), |
| 458 | +width: resolveIntegerOption(opts.width, 1, { min: 1 }), |
| 459 | +height: resolveIntegerOption(opts.height, 1, { min: 1 }), |
460 | 460 | }); |
461 | 461 | } |
462 | 462 | |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。