Files
rea/tests/boundary/browser/cdpBrowserProvider.support.ts
T
morluto 0bd14ca16c fix(browser): preserve uncertain main-frame navigation identity
Own CDP frame applicability and identity at the parsed event boundary. Preserve malformed or incomplete main-frame facts, recognize replacement roots, and carry the same document identity through captures, screenshots, timelines, and execution windows.

Validation: full check:ci and docs:check; 763 browser and dispatch tests passed, 6 skipped. Independent source and fixture-lifecycle review passed. Local real-Chrome behavior was not exercised.

Closes #5665
2026-10-21 07:16:47 +08:00

34 lines
906 B
TypeScript

import { afterEach } from "vitest";
import type {
FakeCdpBrowser,
FakeOptions,
} from "../../fixtures/fakeCdpBrowser.js";
const browsers: FakeCdpBrowser[] = [];
afterEach(async () => {
await Promise.all(browsers.splice(0).map(async (browser) => browser.close()));
});
export const trackBrowser = (browser: FakeCdpBrowser): void => {
browsers.push(browser);
};
export const frameNavigated = (
command: Parameters<NonNullable<FakeOptions["commandEvents"]>>[0],
frame: unknown,
) => ({
method: "Page.frameNavigated",
...(command.sessionId === undefined ? {} : { sessionId: command.sessionId }),
params: { frame },
});
export const waitFor = async (ready: () => boolean, description: string) => {
const deadline = Date.now() + 5_000;
while (!ready()) {
if (Date.now() > deadline) throw new Error(description);
await new Promise((resolve) => setTimeout(resolve, 10));
}
};