fix(browser): release attached viewport overrides without resizing the external page
Co-authored-by: dakjdakd <164857476+dakjdakd@users.noreply.github.com>
This commit is contained in:
1 parent
6c9161d617
commit
f6cfbfcc55
2 files changed
+14
-10
No files matched your search
@@ -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);
|
||||
|
||||
@@ -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", {
|
||||
|
||||
Reference in new issue
Block a user