fix(browser): retain passive coverage and failure identity (#13231)

This commit is contained in:
morluto authored and GitHub committed 2026-11-21 23:03:00 +00:00
1 parent cfa04985c2
commit eba41afd6c
6 files changed
+240 -252

No files matched your search

+1 -1
View File
@@ -64,7 +64,7 @@ export async function startBrowserVerifierSite() {
}
if (request.url === "/screenshot-noise") {
response.setHeader("content-type", "text/html");
response.end(`<!doctype html><html><body style="margin:0"><canvas width="2048" height="1536"></canvas><script>
response.end(`<!doctype html><html><body style="margin:0"><canvas style="display:block" width="2048" height="1536"></canvas><script>
const context = document.querySelector('canvas').getContext('2d');
const image = context.createImageData(2048, 1536);
let state = 0x6d2b79f5;
+27 -21
View File
@@ -3,11 +3,9 @@ import {
requireMcpToolError,
} from "./mcp-verifier-results.mjs";
import assert from "node:assert/strict";
import { execFile } from "node:child_process";
import { mkdtemp, readFile, rm } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { promisify } from "node:util";
import { fileURLToPath } from "node:url";
import { chromium } from "playwright-core";
import { Client } from "@modelcontextprotocol/client";
@@ -15,14 +13,12 @@ import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";
import { parseEvidence } from "../../dist/domain/evidence.js";
import { webScreenshotSchema } from "../../dist/domain/webScreenshot.js";
import { comparePngScreenshots } from "../../dist/domain/pngVisualDiff.js";
import { withVerifierCleanup } from "./verifier-cleanup.mjs";
import { createVerifierCommands } from "./verify-commands.mjs";
/** Verify a real, large PNG through production CLI and stdio MCP boundaries. */
export async function verifyLargeScreenshotE2e(endpoint, origin) {
const browser = await chromium.connectOverCDP(endpoint);
const context = await browser.newContext({
viewport: { width: 2048, height: 1536 },
deviceScaleFactor: 1,
});
const commands = await createVerifierCommands();
const entrypoint = fileURLToPath(new URL("../rea.mjs", import.meta.url));
const env = {
PATH: process.env.PATH ?? "/usr/bin:/bin",
@@ -31,17 +27,32 @@ export async function verifyLargeScreenshotE2e(endpoint, origin) {
};
let client;
let transport;
try {
let browser;
let context;
return withVerifierCleanup(async () => {
browser = await chromium.connectOverCDP(endpoint);
context = await browser.newContext({
viewport: { width: 2048, height: 1536 },
deviceScaleFactor: 1,
});
const page = await context.newPage();
await page.goto(`${origin}/screenshot-noise`);
await page.waitForFunction(() => document.body.dataset.ready === "true");
assert.deepEqual(
await page.evaluate(() => [
document.documentElement.scrollWidth,
document.documentElement.scrollHeight,
]),
[2048, 1536],
"Noise canvas must fill the intended viewport without document overflow",
);
const targets = await (await fetch(`${endpoint}/json/list`)).json();
const target = targets.find((value) => value.url === page.url());
assert.ok(
target,
"Owned screenshot page is absent from actual CDP discovery",
);
const { stdout } = await promisify(execFile)(
const { stdout } = await commands.exec(
process.execPath,
[
entrypoint,
@@ -120,18 +131,13 @@ export async function verifyLargeScreenshotE2e(endpoint, origin) {
matched_large_buffer: true,
png_bytes: bytes.byteLength,
};
} finally {
try {
if (client !== undefined) await client.close();
} finally {
try {
if (transport !== undefined) await transport.close();
} finally {
await context.close();
await browser.close();
}
}
}
}, [
() => client?.close(),
() => transport?.close(),
() => context?.close(),
() => browser?.close(),
() => commands.close(),
]);
}
const verifyDefaultScreenshotDelivery = async ({