mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-28 13:26:04 -06:00
fix(browser): clamp non-finite viewport dimensions
This commit is contained in:
@@ -203,6 +203,21 @@ describe("pw-tools-core aria snapshot storage", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("clamps non-finite viewport dimensions to the minimum size", async () => {
|
||||
const page = { setViewportSize: vi.fn(async () => {}) };
|
||||
getPageForTargetId.mockResolvedValue(page);
|
||||
|
||||
const mod = await import("./pw-tools-core.snapshot.js");
|
||||
await mod.resizeViewportViaPlaywright({
|
||||
cdpUrl: "http://127.0.0.1:9222",
|
||||
targetId: "tab-1",
|
||||
width: Number.NaN,
|
||||
height: Number.POSITIVE_INFINITY,
|
||||
});
|
||||
|
||||
expect(page.setViewportSize).toHaveBeenCalledWith({ width: 1, height: 1 });
|
||||
});
|
||||
|
||||
it("stores role fallback metadata when backend markers are unavailable", async () => {
|
||||
const page = { id: "page-1" };
|
||||
const mod = await import("./pw-tools-core.snapshot.js");
|
||||
|
||||
@@ -455,8 +455,8 @@ export async function resizeViewportViaPlaywright(opts: {
|
||||
const page = await getPageForTargetId(opts);
|
||||
ensurePageState(page);
|
||||
await page.setViewportSize({
|
||||
width: Math.max(1, Math.floor(opts.width)),
|
||||
height: Math.max(1, Math.floor(opts.height)),
|
||||
width: resolveIntegerOption(opts.width, 1, { min: 1 }),
|
||||
height: resolveIntegerOption(opts.height, 1, { min: 1 }),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user