Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

Revert "fix(cli): don't crash the response when navigating closes the last tab" (#41931)

Simon Knott18e7ca5421c3
diff --git a/packages/playwright-core/src/tools/backend/response.ts b/packages/playwright-core/src/tools/backend/response.ts
index d28de34496..5a35236996 100644
--- a/packages/playwright-core/src/tools/backend/response.ts
+++ b/packages/playwright-core/src/tools/backend/response.ts
@@ -275,8 +275,7 @@ export class Response {
if (this._includeSnapshot !== 'none' || tabHeaders.some(header => header.changed)) {
if (tabHeaders.length !== 1)
addSection('Open tabs', renderTabsMarkdown(tabHeaders));
- if (tabHeaders.length)
- addSection('Page', renderTabMarkdown(tabHeaders.find(h => h.current) ?? tabHeaders[0]));
+ addSection('Page', renderTabMarkdown(tabHeaders.find(h => h.current) ?? tabHeaders[0]));
}
// Handle modal states.
diff --git a/tests/mcp/cli-navigation.spec.ts b/tests/mcp/cli-navigation.spec.ts
index 3d07790288..74f606fadf 100644
--- a/tests/mcp/cli-navigation.spec.ts
+++ b/tests/mcp/cli-navigation.spec.ts
@@ -52,10 +52,3 @@ test('run-code', async ({ cli, server }) => {
const { output } = await cli('run-code', '() => page.title()');
expect(output).toContain('"Title"');
});
-
-test('goto chrome:// page that closes the tab does not crash the response', async ({ cli, server, mcpBrowser }) => {
- test.skip(mcpBrowser !== 'chromium' && mcpBrowser !== 'chrome', 'chrome:// pages are chromium-specific');
- await cli('open', server.HELLO_WORLD);
- const { output } = await cli('goto', 'chrome://extensions/');
- expect(output).toContain('No open tabs. Navigate to a URL to create one.');
-});