Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore(mcp): bump default extension protocol to v2 (#40678)
Yury Semikhatsky3649db560ff9
diff --git a/packages/playwright-core/src/tools/mcp/cdpRelay.ts b/packages/playwright-core/src/tools/mcp/cdpRelay.tsindex c0a79d6828..b41fddf0bc 100644--- a/packages/playwright-core/src/tools/mcp/cdpRelay.ts+++ b/packages/playwright-core/src/tools/mcp/cdpRelay.ts@@ -22,8 +22,8 @@* - /extension/guid - Extension connection** Protocol version is controlled by PLAYWRIGHT_EXTENSION_PROTOCOL env variable:- * - v1 (default): single-tab, extension manages debugger attachment- * - v2: multi-tab, relay manages debugger via chrome.* APIs+ * - v1: single-tab, extension manages debugger attachment+ * - v2 (default): multi-tab, relay manages debugger via chrome.* APIs*/import { spawn } from 'child_process';diff --git a/packages/playwright-core/src/tools/mcp/protocol.ts b/packages/playwright-core/src/tools/mcp/protocol.tsindex 8a79958c4d..06c02525f7 100644--- a/packages/playwright-core/src/tools/mcp/protocol.ts+++ b/packages/playwright-core/src/tools/mcp/protocol.ts@@ -21,7 +21,7 @@ export const LATEST_VERSION = 2;// The protocol version used by default when PLAYWRIGHT_EXTENSION_PROTOCOL is// not set. May lag behind LATEST_VERSION while a new version is rolling out.-export const DEFAULT_VERSION = 1;+export const DEFAULT_VERSION = 2;// Structural mirrors of @types/chrome shapes used over the wire. The extension// imports the real chrome.* types and they are structurally compatible.diff --git a/tests/extension/extension-fixtures.ts b/tests/extension/extension-fixtures.tsindex b53fc598c2..b68c1d4b54 100644--- a/tests/extension/extension-fixtures.ts+++ b/tests/extension/extension-fixtures.ts@@ -57,9 +57,9 @@ export const test = base.extend<TestFixtures, WorkerFixtures & ExtensionTestOptiprotocolVersion: [2, { option: true, scope: 'worker' }],_protocolEnv: [async ({ protocolVersion }, use) => {- // Default is 1.- if (protocolVersion === 2)- process.env.PLAYWRIGHT_EXTENSION_PROTOCOL = '2';+ // Default is 2.+ if (protocolVersion === 1)+ process.env.PLAYWRIGHT_EXTENSION_PROTOCOL = '1';elsedelete process.env.PLAYWRIGHT_EXTENSION_PROTOCOL;await use();diff --git a/tests/extension/extension.spec.ts b/tests/extension/extension.spec.tsindex 52dd553877..9a7066cb9c 100644--- a/tests/extension/extension.spec.ts+++ b/tests/extension/extension.spec.ts@@ -58,8 +58,7 @@ test(`connect.html protocolVersion search param matches fixture option`, async (expect(url.searchParams.get('protocolVersion')).toBe(String(protocolVersion));});-test(`protocolVersion defaults to 1`, async ({ startExtensionClient, server, protocolVersion }) => {- // test.fail(true, 'Server default is currently 2; this test guards the expected default of 1');+test(`protocolVersion defaults to 2`, async ({ startExtensionClient, server, protocolVersion }) => {const saved = process.env.PLAYWRIGHT_EXTENSION_PROTOCOL;delete process.env.PLAYWRIGHT_EXTENSION_PROTOCOL;@@ -76,7 +75,7 @@ test(`protocolVersion defaults to 1`, async ({ startExtensionClient, server, proconst selectorPage = await confirmationPagePromise;const url = new URL(selectorPage.url());- expect(url.searchParams.get('protocolVersion')).toBe('1');+ expect(url.searchParams.get('protocolVersion')).toBe('2');process.env.PLAYWRIGHT_EXTENSION_PROTOCOL = saved;});