Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 20
container:
image: mcr.microsoft.com/playwright:v1.63.0-noble
image: mcr.microsoft.com/playwright:v1.65.0-noble
options: --user pwuser --init --ipc=host
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'
Expand Down Expand Up @@ -172,7 +172,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 15
container:
image: mcr.microsoft.com/playwright:v1.63.0-noble
image: mcr.microsoft.com/playwright:v1.65.0-noble
options: --user pwuser --init --ipc=host
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'
Expand Down Expand Up @@ -237,9 +237,9 @@ jobs:
include:
- { os: ubuntu-latest, browser: firefox }
- { os: ubuntu-latest, browser: webkit }
- { os: macos-14, browser: webkit }
- { os: macos-14, browser: firefox }
- { os: macos-14, browser: chromium }
- { os: macos-15, browser: webkit }
- { os: macos-15, browser: firefox }
- { os: macos-15, browser: chromium }
steps:
- name: Checkout code
shell: bash
Expand Down Expand Up @@ -277,7 +277,7 @@ jobs:

- run: npm ci
- run: npx playwright install --with-deps ${{ matrix.browser }}
- if: ${{ matrix.browser != 'chromium' && !(matrix.os == 'macos-14' && matrix.browser == 'webkit') }}
- if: ${{ matrix.browser != 'chromium' }}
run: npx vitest run tests/numpad-keys.integration.test.ts
env:
MCP_TEST_BROWSER_NAME: ${{ matrix.browser }}
Expand Down
103 changes: 57 additions & 46 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ Crawl and aggregate accessibility violations across multiple pages. Writes a JSO
- `excludePathPatterns` - Regex patterns to skip (default: `logout|signout`)
- `reportFile` - Custom output filename

**Behind a login:** the crawl shares the browser context, so signing in with `browser_navigate` / `browser_fill_form` first is enough. Alternatively record a session with `npx playwright@1.63.0 codegen --save-storage=auth.json <login-url>` (pinned to the server's own Playwright, so the recorded state matches what it replays) and start the server with `--storage-state ./auth.json` — fresh contexts receive it at creation, and default persistent mode uses a disposable profile that cannot combine with `--user-data-dir`. Existing CDP and VS Code contexts reject imports before taking a snapshot or resetting storage; add `--isolated` for CDP, or sign in interactively. `--extension` refuses storage imports entirely. On Playwright 1.63.0, IndexedDB snapshots can lose `Map` and `Set` contents, so a captured state is not a lossless backup of those records. Extend `excludePathPatterns` with anything else that ends the session (account deletion, session revocation, account/locale switchers) — it replaces the default, so keep `logout|signout` in the list. If the crawl loses cookies it started with, the result opens with `WARNING: cookie(s) …` lines and the report carries a `sessionLosses` list naming, per lost cookie, the page reached after any redirect, even when that page failed to load; if one of them was the session cookie, everything scanned after that page was audited signed-out. Monitoring continues past the first loss (each cookie is reported once, where it vanished), and URLs discovered mid-crawl join cookie tracking before being visited. Cookie values are not compared and a cookie the browser dropped at its own expiry is ignored, but any other cookie the crawl started with and lost is reported — nothing marks a cookie as an authentication one.
**Behind a login:** the crawl shares the browser context, so signing in with `browser_navigate` / `browser_fill_form` first is enough. Alternatively record a session with `npx playwright@1.65.0 codegen --save-storage=auth.json <login-url>` (pinned to the server's own Playwright, so the recorded state matches what it replays) and start the server with `--storage-state ./auth.json` — fresh contexts receive it at creation, and default persistent mode uses a disposable profile that cannot combine with `--user-data-dir`. Existing CDP and VS Code contexts reject imports before taking a snapshot or resetting storage; add `--isolated` for CDP, or sign in interactively. `--extension` refuses storage imports entirely. Extend `excludePathPatterns` with anything else that ends the session (account deletion, session revocation, account/locale switchers) — it replaces the default, so keep `logout|signout` in the list. If the crawl loses cookies it started with, the result opens with `WARNING: cookie(s) …` lines and the report carries a `sessionLosses` list naming, per lost cookie, the page reached after any redirect, even when that page failed to load; if one of them was the session cookie, everything scanned after that page was audited signed-out. Monitoring continues past the first loss (each cookie is reported once, where it vanished), and URLs discovered mid-crawl join cookie tracking before being visited. Cookie values are not compared and a cookie the browser dropped at its own expiry is ignored, but any other cookie the crawl started with and lost is reported — nothing marks a cookie as an authentication one.

### scan_page_matrix

Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
"axe-core": "4.14.0",
"commander": "^15.0.0",
"debug": "^4.4.3",
"playwright": "1.63.0",
"playwright-core": "1.63.0",
"playwright": "1.65.0",
"playwright-core": "1.65.0",
"re2": "^1.26.1",
"ws": "^8.22.0",
"zod": "^4.6.7"
Expand Down
4 changes: 2 additions & 2 deletions src/browserContextFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ async function navigateReplacementPages(replaced: { page: playwright.Page, url:

export function assertReusedContextStorageStateSupported(config: FullConfig): void {
if (config.browser.contextOptions?.storageState)
throw new Error('Cannot apply --storage-state to an existing browser context on Playwright 1.63.0: its rollback snapshot can run service-worker-served scripts and alter storage. Use a fresh context (for CDP, add --isolated), or omit --storage-state and sign in interactively. No storage snapshot or reset was attempted.');
throw new Error('Cannot apply --storage-state to an existing browser context: on Playwright 1.63.0 its rollback snapshot ran service-worker-served scripts and altered storage, and imports into existing contexts stay disabled until revalidated. Use a fresh context (for CDP, add --isolated), or omit --storage-state and sign in interactively. No storage snapshot or reset was attempted.');
}

function createContextFactory(config: FullConfig): BrowserContextFactory {
Expand Down Expand Up @@ -669,7 +669,7 @@ function cdpConnectHeaders(clientInfo: ClientInfo, browserConfig: FullConfig['br
return Object.keys(headers).length ? headers : undefined;
}

const cdpAttachTimeoutHint = 'The CDP WebSocket connected, but Playwright did not finish attaching before the timeout. An existing tab can block the attach: on Playwright 1.63.0 a tab without a renderer (crashed, or discarded by Memory Saver) never answers, and a sleeping or unresponsive tab can stall it. Reload or close that tab in the browser yourself, or attach to a separate browser, then retry; a longer --cdp-timeout helps only when the attach is merely slow.';
const cdpAttachTimeoutHint = 'The CDP WebSocket connected, but Playwright did not finish attaching before the timeout. An existing tab can block the attach: a sleeping or unresponsive tab can stall it, and on Playwright 1.63.0 so did a tab without a renderer (crashed, or discarded by Memory Saver). Reload or close that tab in the browser yourself, or attach to a separate browser, then retry; a longer --cdp-timeout helps only when the attach is merely slow.';

function isCdpAttachTimeout(error: unknown): error is Error {
return error instanceof Error && error.name === 'TimeoutError' && error.message.includes('<ws connected>');
Expand Down
20 changes: 10 additions & 10 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ async function validateResolvedConfig(config: FullConfig): Promise<FullConfig> {
throw new Error('outputDir must not be blank: provide a directory path, or omit the option to use a temp directory.');
validateProfileDirName(config.browser.profileDirName);
applyDefaultChromiumSandbox(config);
warnAboutAuthenticatedProxies(config);
return config;
}

Expand All @@ -160,15 +159,22 @@ function normalizeRedactUrlParams(config: FullConfig): void {
config.redactUrlParams = config.redactUrlParams.map(name => name.trim());
}

const plainBypassEntry = /^\.?[a-z0-9-]+(\.[a-z0-9-]+)*$/i;

function applyProxyToClientCertificates(config: FullConfig): void {
const { contextOptions, launchOptions } = config.browser;
if (!contextOptions.clientCertificates?.length)
return;
const proxy = contextOptions.proxy ?? launchOptions.proxy;
if (proxy?.bypass?.trim())
throw new Error('clientCertificates with proxy.bypass is unsupported on Playwright 1.63.0: the certificate interceptor ignores bypass rules. Use a separate browser configuration for these routes; no browser was started.');
// With certificates, Playwright routes every request through its certificate
// interceptor, which matches bypass entries only as domain suffixes. Reject
// browser-specific syntax there rather than silently proxying those routes.
const unsupported = proxy?.bypass?.split(',').map(entry => entry.trim()).filter(entry => entry && !plainBypassEntry.test(entry));
if (unsupported?.length)
throw new Error(`clientCertificates supports only host and domain entries in proxy.bypass, such as "example.com" or ".example.com"; unsupported: ${unsupported.map(entry => JSON.stringify(entry)).join(', ')}. Wildcards, ports, IP ranges and <local> are not applied by Playwright's certificate interceptor. No browser was started.`);
Comment thread
JustasMonkev marked this conversation as resolved.
Resolved
// The interceptor compares entries against the lowercased URL hostname as-is.
if (proxy)
contextOptions.proxy = proxy;
contextOptions.proxy = proxy.bypass ? { ...proxy, bypass: proxy.bypass.toLowerCase() } : proxy;
}

const maxTimerDelayMs = 2_147_483_647;
Expand Down Expand Up @@ -205,12 +211,6 @@ function applyDefaultChromiumSandbox(config: FullConfig): void {
browser.chromiumSandboxDefaulted = true;
}

function warnAboutAuthenticatedProxies(config: FullConfig): void {
const { launchOptions, contextOptions } = config.browser;
if ([launchOptions.proxy, contextOptions.proxy].some(proxy => proxy?.username || proxy?.password))
process.stderr.write('WARNING: Playwright 1.63.0 may send authenticated proxy credentials to a website\'s 401 authentication challenge. This warning does not prevent the leak. Avoid authenticated proxies until a Playwright release containing https://github.com/microsoft/playwright/pull/43482 is adopted.\n');
}

type MobileSource = 'env' | 'cli';
type ConfigLayers = { file: Config, env: Config, cli: Config };
type OptionLayers = { env: CLIOptions, cli: CLIOptions };
Expand Down
2 changes: 1 addition & 1 deletion src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class ContextRegistry {

const contextRegistry = new ContextRegistry();

type TraceHub = { users: number, ready: Promise<void> };
type TraceHub = { users: number, ready: Promise<unknown> };
const traceHubs = new WeakMap<playwright.BrowserContext, TraceHub>();

type IdleGroup = {
Expand Down
25 changes: 9 additions & 16 deletions src/inputRecorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,19 @@ const addMissingPageAlias = (
else
recorded.unshift(declarationAction);
};
const recorderParams = {
mode: 'recording',
recorderMode: 'api',
omitCallTracking: true,
language: 'javascript',
};
const recorderParams = { language: 'javascript' };

type RecorderSink = {
actionAdded: (page: playwright.Page, data: actions.Action | actions.ActionInContext, code: string) => void;
actionUpdated: (page: playwright.Page, data: actions.Action | actions.ActionInContext, code: string) => void;
signalAdded: (page: playwright.Page, data: actions.Signal | actions.SignalInContext, code: string) => void;
};

// Playwright starts one programmatic recording per client connection, always in
// 'recording' mode with call tracking omitted; starting a second one throws.
type PlaywrightRecorderControl = {
_enableRecorder(params: typeof recorderParams, sink: RecorderSink): Promise<void>;
_disableRecorder(): Promise<void>;
_startRecording(params: typeof recorderParams, sink: RecorderSink): Promise<void>;
_stopRecording(): Promise<void>;
};

class RecorderHub {
Expand All @@ -89,11 +86,7 @@ class RecorderHub {

constructor(browserContext: playwright.BrowserContext) {
this._browserContext = browserContext;
this.ready = this.arm();
}

arm(): Promise<void> {
return this._enqueue(() => this._arm());
this.ready = this.ensureArmed();
}

ensureArmed(): Promise<void> {
Expand All @@ -108,7 +101,7 @@ class RecorderHub {
if (this.starting || this.recorders.size || this.recordings.size)
return;
try {
await this._control()._disableRecorder();
await this._control()._stopRecording();
} finally {
this._armed = false;
}
Expand All @@ -120,7 +113,7 @@ class RecorderHub {
}

private async _arm(): Promise<void> {
await this._control()._enableRecorder(recorderParams, this._sink);
await this._control()._startRecording(recorderParams, this._sink);
this._armed = true;
}

Expand Down Expand Up @@ -250,7 +243,7 @@ export class InputRecorder {
await hub.ready;
if (existingHub) {
await new Promise(resolve => setTimeout(resolve, recorderBufferMs));
await hub.arm();
await hub.ensureArmed();
}
for (const [index, page] of browserContext.pages().entries())
target.pageIndexes.set(page, index);
Expand Down
2 changes: 1 addition & 1 deletion src/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ function configureBaseProgram() {
.option('--port <port>', 'port to listen on for MCP Streamable HTTP transport.')
.option('--profile-dir-name <name>', 'name of the Chrome profile directory to connect to with --extension, for example "Profile 1". Requires --user-data-dir. Defaults to the last-used profile that has the extension installed.')
.option('--proxy-bypass <bypass>', 'comma-separated domains to bypass proxy, for example ".com,chromium.org,.domain.com"')
.option('--proxy-server <proxy>', 'specify proxy server, for example "http://myproxy:3128", "http://user:password@myproxy:3128" or "socks5://myproxy:8080". WARNING: Playwright 1.63.0 may leak proxy credentials to website 401 challenges; avoid authenticated proxies until the upstream fix is released and adopted')
.option('--proxy-server <proxy>', 'specify proxy server, for example "http://myproxy:3128", "http://user:password@myproxy:3128" or "socks5://myproxy:8080"')
.option('--redact-url-params <names>', 'comma-separated URL parameter names to mask in response and saved session text (case-insensitive); an empty value clears the list. Does not change browser requests or binary artifacts.', toolNameList)
.option('--save-session', 'Whether to save the Playwright MCP session into the output directory.')
.option('--save-trace', 'Whether to save the Playwright Trace of the session into the output directory.')
Expand Down
18 changes: 12 additions & 6 deletions tests/browser-upgrade-controls.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,14 @@ const versions = {
};
// Only the measured paired pin may retain these upstream deviations. An upgrade
// must pass the intended behavior instead of inheriting a known failure.
const pinned = versions.playwright === '1.63.0' && versions.playwrightCore === '1.63.0';
const paired = versions.playwright === versions.playwrightCore ? versions.playwright : undefined;
const pinned = paired === '1.63.0';
// Still present on 1.65.0: Linux WebKit lost aborts reproduced there, and
// 1.65.0 keeps macOS 14 on the frozen r2251 bundle while still sending the
// PushAPIEnabled setting that bundle rejects.
const knownOn = (...measured: string[]) => paired !== undefined && measured.includes(paired);
const mac14WebKit = browserName === 'webkit' && process.platform === 'darwin' && os.release().startsWith('23.');
const knownPageSetupFailure = pinned && mac14WebKit;
const knownPageSetupFailure = knownOn('1.63.0', '1.65.0') && mac14WebKit;
let browser: playwright.Browser | undefined;
let backend: BrowserServerBackend | undefined;
let directory: string | undefined;
Expand Down Expand Up @@ -203,9 +208,10 @@ it.skipIf(knownPageSetupFailure)('delivers navigation errors, bounds stalled loa
await fresh.goto(origin + target, { waitUntil: 'domcontentloaded', timeout: 3000 });
} catch (error) {
// #42957's abort-before-request order was protocol-confirmed on
// pinned Linux WebKit. Only its served-but-uncommitted signature
// may time out; a containing fix must deliver cancellation promptly.
const knownTimeout = pinned && process.platform === 'linux' && error instanceof playwright.errors.TimeoutError;
// Linux WebKit with 1.63.0 and still reproduces with 1.65.0. Only its
// served-but-uncommitted signature may time out; a containing fix
// must deliver cancellation promptly.
const knownTimeout = knownOn('1.63.0', '1.65.0') && process.platform === 'linux' && error instanceof playwright.errors.TimeoutError;
const deliveredAbort = error instanceof Error && error.message.startsWith('page.goto: Load request cancelled');
if (!knownTimeout && !deliveredAbort)
throw error;
Expand Down Expand Up @@ -247,7 +253,7 @@ it.skipIf(!mac14WebKit)('characterizes actual macOS 14 WebKit page setup (#42964
if (first === 'stalled')
await browser.close();
const result = await creating;
if (pinned) {
if (knownPageSetupFailure) {
if (!('error' in result) || !(result.error instanceof Error))
throw new Error('Expected the pinned WebKit page-setup error');
expect(result.error.message).toContain('Unknown setting: PushAPIEnabled');
Expand Down
4 changes: 2 additions & 2 deletions tests/browserSessions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function makeFactory() {
browserContext.pages = vi.fn().mockReturnValue([]);
browserContext.route = vi.fn().mockResolvedValue(undefined);
// Only exercised when a test enables --save-session (the input recorder).
browserContext._enableRecorder = vi.fn().mockResolvedValue(undefined);
browserContext._startRecording = vi.fn().mockResolvedValue(undefined);
const close = vi.fn().mockResolvedValue(undefined);
created.push({ browserContext, close, newPage });
return { browserContext, close };
Expand Down Expand Up @@ -321,7 +321,7 @@ describe('browser sessions', () => {
page.setDefaultTimeout = vi.fn();
page.url = () => 'about:blank';
created[0].browserContext.emit('page', page);
const sink = created[0].browserContext._enableRecorder.mock.calls[0][1];
const sink = created[0].browserContext._startRecording.mock.calls[0][1];
sink.actionAdded(page, { name: 'click', signals: [] }, 'await page.click();');
sink.signalAdded(page, { name: 'navigation', url: 'https://example.com' }, "await page.goto('https://example.com');");

Expand Down
Loading
Loading