Skip to content

armgit / rea

Public Imported from GitHub
0

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

fix(browser): release attached viewport overrides without resizing the external page

Lucienf6cfbfcc554f
diff --git a/scripts/lib/browser-scenario-environment-e2e.mjs b/scripts/lib/browser-scenario-environment-e2e.mjs
index 1804402f3..0528d358a 100644
--- a/scripts/lib/browser-scenario-environment-e2e.mjs
+++ b/scripts/lib/browser-scenario-environment-e2e.mjs
@@ -126,17 +126,22 @@ export async function verifyScenarioEnvironment(endpoint, targetId, origin) {
});
try {
await client.connect(transport);
+ const definition = (await client.listTools()).tools.find(
+ ({ name }) => name === "capture_browser_scenario",
+ );
+ assert.ok(definition, "Scenario tool is absent from the current catalog");
assertCapture(
requireMcpEvidenceResult(
- await client.callTool({
- name: "capture_browser_scenario",
- arguments: scenario,
- }),
+ await client.callTool(
+ { name: "capture_browser_scenario", arguments: scenario },
+ { toolDefinition: definition },
+ ),
"capture_browser_scenario",
),
);
await verifyConcurrentMcpCapture({
client,
+ definition,
connection,
endpoint,
targetId,
@@ -198,6 +203,7 @@ export async function verifyScenarioEnvironment(endpoint, targetId, origin) {
const verifyConcurrentMcpCapture = async ({
client,
+ definition,
connection,
endpoint,
targetId,
@@ -226,7 +232,7 @@ const verifyConcurrentMcpCapture = async ({
const callTool = (arguments_, signal) => {
const pending = client.callTool(
{ name: "capture_browser_scenario", arguments: arguments_ },
- { signal, timeout: 60_000 },
+ { signal, timeout: 60_000, toolDefinition: definition },
);
void pending.catch(() => {});
pendingCalls.push(pending);
diff --git a/src/browser/PlaywrightScenarioBrowser.ts b/src/browser/PlaywrightScenarioBrowser.ts
index 88fdda0f8..cd2d5a65a 100644
--- a/src/browser/PlaywrightScenarioBrowser.ts
+++ b/src/browser/PlaywrightScenarioBrowser.ts
@@ -288,11 +288,8 @@ const configureAttachedEnvironment = async (
environment: BrowserScenario["environment"],
signal: AbortSignal | undefined,
): Promise<void> => {
- await page.setViewportSize({
- width: environment.viewport.width,
- height: environment.viewport.height,
- });
- throwIfScenarioCancelled(signal);
+ // setViewportSize also resizes the external browser window. The scenario's
+ // CDP metrics override below supplies the viewport and expires on disconnect.
await page.emulateMedia({
colorScheme: environment.color_scheme,
reducedMotion: environment.reduced_motion,
@@ -307,6 +304,7 @@ const configureAttachedEnvironment = async (
height: environment.viewport.height,
deviceScaleFactor: environment.viewport.device_scale_factor,
mobile: false,
+ dontSetVisibleSize: true,
});
throwIfScenarioCancelled(signal);
await session.send("Emulation.setLocaleOverride", {