Skip to content

armgit / rea

Public Imported from GitHub
0

Reverse engineer anything with agents, from app behavior down to native binaries.

fix(browser): disclose connected platform-emulation teardown limits

morluto2ff086796ad7
diff --git a/src/browser/BrowserScenarioPartialObservation.ts b/src/browser/BrowserScenarioPartialObservation.ts
index 380417514..cc83ed155 100644
--- a/src/browser/BrowserScenarioPartialObservation.ts
+++ b/src/browser/BrowserScenarioPartialObservation.ts
@@ -57,6 +57,7 @@ const browserScenarioLimitations = (
? [
"CDP attachment cannot recover pre-attach events or guarantee launch-time context options.",
`Attached locale ${scenario.environment.locale} applies to Intl formatting only; navigator.language(s) and Accept-Language remain caller-controlled. Use launch mode for matching page and request languages.`,
+ "Detaching a CDP page session may clear caller-owned navigator.platform emulation. REA cannot snapshot the caller's complete user-agent/client-hint state before attachment; use launch mode to avoid mutating that external browser.",
]
: []),
];
diff --git a/src/browser/PlaywrightBrowserScenarioProvider.test.ts b/src/browser/PlaywrightBrowserScenarioProvider.test.ts
index 6917c8dce..300592beb 100644
--- a/src/browser/PlaywrightBrowserScenarioProvider.test.ts
+++ b/src/browser/PlaywrightBrowserScenarioProvider.test.ts
@@ -78,6 +78,10 @@ const scenario = (
},
});
+const connectedPlatformEmulationLimitation = expect.stringContaining(
+ "Detaching a CDP page session may clear caller-owned navigator.platform emulation",
+);
+
type SnapshotKind = BrowserScenario["capture"]["after_each_step"][number];
interface FakeSessionFailures {
@@ -355,7 +359,9 @@ describe("PlaywrightBrowserScenarioProvider", () => {
expect(session.closeCalls).toBe(1);
expect(result.value.completeness.equality_eligible).toBe(false);
});
+});
+describe("connected browser scenario captures", () => {
it("disconnects external CDP sessions and marks pre-attach events missing", async () => {
const session = new FakeSession("connect");
const provider = new PlaywrightBrowserScenarioProvider(() =>
@@ -374,8 +380,37 @@ describe("PlaywrightBrowserScenarioProvider", () => {
equality_eligible: false,
missing_sections: ["events"],
});
+ expect(result.value.limitations).toEqual(
+ expect.arrayContaining([connectedPlatformEmulationLimitation]),
+ );
expect(session.closeCalls).toBe(1);
});
+
+ it("retains the attached platform-emulation limitation in partial observations", async () => {
+ const session = new FakeSession("connect", {
+ capture: { call: 1, error: new Error("fixture capture failure") },
+ });
+ const provider = new PlaywrightBrowserScenarioProvider(() =>
+ Promise.resolve(session),
+ );
+ const result = await provider.captureScenario(
+ scenario({ mode: "connect" }),
+ );
+
+ expect(result.ok).toBe(false);
+ if (result.ok) return;
+ expect(projectAnalysisError(result.error)).toMatchObject({
+ details: {
+ partial_observation: {
+ capture: {
+ limitations: expect.arrayContaining([
+ connectedPlatformEmulationLimitation,
+ ]),
+ },
+ },
+ },
+ });
+ });
});
describe("PlaywrightBrowserScenarioProvider timing", () => {