From 0812df2f5eeeb26863bcc521e534d1df89354eba Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Fri, 22 Aug 2025 17:53:30 -0700 Subject: [PATCH] chore(extension): do not complain about old extension version (#937) --- extension/src/ui/connect.tsx | 61 +------------------------------ extension/tests/extension.spec.ts | 19 +++------- src/extension/cdpRelay.ts | 2 - 3 files changed, 8 insertions(+), 74 deletions(-) diff --git a/extension/src/ui/connect.tsx b/extension/src/ui/connect.tsx index 0f0f1f1..0a80a61 100644 --- a/extension/src/ui/connect.tsx +++ b/extension/src/ui/connect.tsx @@ -22,8 +22,7 @@ import type { TabInfo } from './tabItem.js'; type Status = | { type: 'connecting'; message: string } | { type: 'connected'; message: string } - | { type: 'error'; message: string } - | { type: 'error'; versionMismatch: { pwMcpVersion: string; extensionVersion: string; downloadUrl: string } }; + | { type: 'error'; message: string }; const ConnectApp: React.FC = () => { const [tabs, setTabs] = useState([]); @@ -59,23 +58,6 @@ const ConnectApp: React.FC = () => { return; } - const pwMcpVersion = params.get('pwMcpVersion'); - const extensionVersion = chrome.runtime.getManifest().version; - if (pwMcpVersion !== extensionVersion) { - const downloadUrl = params.get('downloadUrl') || `https://github.com/microsoft/playwright-mcp/releases/download/v${extensionVersion}/playwright-mcp-extension-v${extensionVersion}.zip`; - setShowButtons(false); - setShowTabList(false); - setStatus({ - type: 'error', - versionMismatch: { - pwMcpVersion: pwMcpVersion || 'unknown', - extensionVersion, - downloadUrl - } - }); - return; - } - void connectToMCPRelay(relayUrl); // If this is a browser_navigate command, hide the tab list and show simple allow/reject @@ -199,50 +181,11 @@ const ConnectApp: React.FC = () => { ); }; -const VersionMismatchError: React.FC<{ pwMcpVersion: string; extensionVersion: string; downloadUrl: string }> = ({ pwMcpVersion, extensionVersion, downloadUrl }) => { - const readmeUrl = 'https://github.com/microsoft/playwright-mcp/blob/main/extension/README.md'; - - const handleDownloadAndOpenExtensions = () => { - // Start download - const link = document.createElement('a'); - link.href = downloadUrl; - link.download = `playwright-mcp-extension-v${extensionVersion}.zip`; - document.body.appendChild(link); - link.click(); - document.body.removeChild(link); - - setTimeout(() => { - chrome.tabs.query({ active: true, currentWindow: true }, tabs => { - if (tabs[0]?.id) - chrome.tabs.update(tabs[0].id, { url: 'chrome://extensions/' }); - }); - }, 1000); // Wait 1 second for download to initiate - }; - - return ( -
- Incompatible Playwright MCP version: {pwMcpVersion} (extension version: {extensionVersion}).{' '} - to download the matching extension, then drag and drop it into the Chrome Extensions page.{' '} - See installation instructions for more details. -
- ); -}; const StatusBanner: React.FC<{ status: Status }> = ({ status }) => { return (
- {'versionMismatch' in status ? ( - - ) : ( - status.message - )} + {status.message}
); }; diff --git a/extension/tests/extension.spec.ts b/extension/tests/extension.spec.ts index 174ad79..cff28d6 100644 --- a/extension/tests/extension.spec.ts +++ b/extension/tests/extension.spec.ts @@ -18,7 +18,6 @@ import fs from 'fs'; import path from 'path'; import { fileURLToPath } from 'url'; import { chromium } from 'playwright'; -import packageJSON from '../../package.json' assert { type: 'json' }; import { test as base, expect } from '../../tests/fixtures.js'; import type { Client } from '@modelcontextprotocol/sdk/client/index.js'; @@ -117,7 +116,7 @@ async function startWithExtensionFlag(browserWithExtension: BrowserWithExtension return client; } -const testWithOldVersion = test.extend({ +const testWithOldExtensionVersion = test.extend({ pathToExtension: async ({}, use, testInfo) => { const extensionDir = testInfo.outputPath('extension'); const oldPath = fileURLToPath(new URL('../dist', import.meta.url)); @@ -216,7 +215,7 @@ for (const [mode, startClientMethod] of [ await confirmationPagePromise; }); - testWithOldVersion(`extension version mismatch (${mode})`, async ({ browserWithExtension, startClient, server, useShortConnectionTimeout }) => { + testWithOldExtensionVersion(`works with old extension version (${mode})`, async ({ browserWithExtension, startClient, server, useShortConnectionTimeout }) => { useShortConnectionTimeout(500); // Prelaunch the browser, so that it is properly closed after the test. @@ -233,19 +232,13 @@ for (const [mode, startClientMethod] of [ arguments: { url: server.HELLO_WORLD }, }); - const confirmationPage = await confirmationPagePromise; - await expect(confirmationPage.locator('.status-banner')).toHaveText(`Incompatible Playwright MCP version: ${packageJSON.version} (extension version: 0.0.1). Click here to download the matching extension, then drag and drop it into the Chrome Extensions page. See installation instructions for more details.`); + const selectorPage = await confirmationPagePromise; + // For browser_navigate command, the UI shows Allow/Reject buttons instead of tab selector + await selectorPage.getByRole('button', { name: 'Allow' }).click(); expect(await navigateResponse).toHaveResponse({ - result: expect.stringContaining('Extension connection timeout.'), - isError: true, + pageState: expect.stringContaining(`- generic [active] [ref=e1]: Hello, world!`), }); - - const downloadPromise = confirmationPage.waitForEvent('download'); - await confirmationPage.locator('.status-banner').getByRole('button', { name: 'Click here' }).click(); - const download = await downloadPromise; - expect(download.url()).toBe(`https://github.com/microsoft/playwright-mcp/releases/download/v0.0.1/playwright-mcp-extension-v0.0.1.zip`); - await download.cancel(); }); } diff --git a/src/extension/cdpRelay.ts b/src/extension/cdpRelay.ts index 3fd7b9c..c7791db 100644 --- a/src/extension/cdpRelay.ts +++ b/src/extension/cdpRelay.ts @@ -29,7 +29,6 @@ import { WebSocket, WebSocketServer } from 'ws'; import { httpAddressToString } from '../mcp/http.js'; import { logUnhandledError } from '../utils/log.js'; import { ManualPromise } from '../mcp/manualPromise.js'; -import { packageJSON } from '../utils/package.js'; import type websocket from 'ws'; import type { ClientInfo } from '../browserContextFactory.js'; @@ -120,7 +119,6 @@ export class CDPRelayServer { version: clientInfo.version, }; url.searchParams.set('client', JSON.stringify(client)); - url.searchParams.set('pwMcpVersion', packageJSON.version); if (toolName) url.searchParams.set('newTab', String(toolName === 'browser_navigate')); const href = url.toString();