diff --git a/tests/mcp/cli-webmcp.spec.ts b/tests/mcp/cli-webmcp.spec.ts
index 3b447626ce8d5..70e55813b5d5b 100644
--- a/tests/mcp/cli-webmcp.spec.ts
+++ b/tests/mcp/cli-webmcp.spec.ts
@@ -49,6 +49,12 @@ function serveMain(server: any, body: string) {
});
}
+// Reloading the frame once replaces the initial blank page's window in Chromium
+// and works around the bug where tools do not register.
+function iframe(src: string) {
+ return ``;
+}
+
test('webmcp-list and webmcp-call', async ({ cli, server, mcpBrowser }, testInfo) => {
await writeWebMCPConfig(mcpBrowser, testInfo);
serveMain(server, ``);
+ serveMain(server, `${iframe('/frame.html')}`);
server.setRoute('/frame.html', (req: any, res: any) => {
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end(``);
+ serveMain(server, `${iframe('/frame.html')}`);
server.setRoute('/frame.html', (req: any, res: any) => {
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end(``);
@@ -191,7 +197,7 @@ test('webmcp-call disambiguates same-name tools in identical same-origin frames'
// Two iframes of the very same URL each own a tool called "echo", so the frame URL alone
// cannot address them and the listing falls back to the frame position.
- serveMain(server, ``);
+ serveMain(server, `${iframe('/widget.html')}${iframe('/widget.html')}`);
server.setRoute('/widget.html', (req: any, res: any) => {
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end(`