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
2 changes: 1 addition & 1 deletion packages/playwright-core/browsers.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
},
{
"name": "webkit",
"revision": "2318",
"revision": "2319",
"installByDefault": true,
"revisionOverrides": {
"mac14": "2251",
Expand Down
1 change: 1 addition & 0 deletions packages/playwright-core/src/cli/DEPS.list
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
../remote/
../server/trace/viewer/
../tools/cli-client/program.ts
../tools/mcp/program.ts
../tools/trace/traceCli.ts
../bootstrap.ts
node_modules/commander
Expand Down
8 changes: 7 additions & 1 deletion packages/playwright-core/src/cli/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { installBrowsers, uninstallBrowsers, installDeps } from './installAction
import { runTraceInBrowser, runTraceViewerApp } from '../server/trace/viewer/traceViewer';
import { screenshot, pdf } from './browserActions';
import { program as cliProgram } from '../tools/cli-client/program';
import { decorateMCPCommand } from '../tools/mcp/program';

import type { TraceViewerServerOptions } from '../server/trace/viewer/traceViewer';
import type { Command } from 'commander';
Expand Down Expand Up @@ -236,14 +237,19 @@ export function decorateProgram(program: Command) {
addTraceCommands(program, logErrorAndExit);

program
.command('cli', { hidden: true })
.command('cli')
.description('run playwright cli commands from terminal')
.allowExcessArguments(true)
.allowUnknownOption(true)
.helpOption(false)
.action(async options => {
process.argv.splice(process.argv.indexOf('cli'), 1);
cliProgram().catch(logErrorAndExit);
});

decorateMCPCommand(program
.command('mcp')
.description('run the Playwright MCP server'));
}

function logErrorAndExit(e: Error) {
Expand Down
10 changes: 8 additions & 2 deletions packages/playwright-core/src/tools/mcp/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,18 @@ export function decorateMCPCommand(command: Command) {
},
disposed: async backend => {
clientCount--;
if (sharedBrowserPromise && clientCount > 0)
const browserContext = (backend as BrowserBackend).browserContext;

if (sharedBrowserPromise && clientCount > 0) {
if (config.browser.isolated) {
testDebug('close context');
await browserContext.close().catch(() => { });
}
return;
}

testDebug('close browser');
sharedBrowserPromise = undefined;
const browserContext = (backend as BrowserBackend).browserContext;
await browserContext.close().catch(() => { });
await browserContext.browser()?.close().catch(() => { });
}
Expand Down
10 changes: 4 additions & 6 deletions tests/library/modernizr.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async function checkFeatures(name: string, context: BrowserContext, server: Test
}
}

it('Safari Desktop', async ({ browser, browserName, platform, httpsServer, headless, channel, isFrozenWebkit }) => {
it('Safari Desktop', async ({ browser, browserName, platform, httpsServer, channel, isFrozenWebkit }) => {
it.skip(browserName !== 'webkit');
it.skip(browserName === 'webkit' && platform === 'darwin' && os.arch() === 'x64', 'Modernizr uses WebGL which is not available on Intel macOS - https://bugs.webkit.org/show_bug.cgi?id=278277');
it.skip(isFrozenWebkit);
Expand All @@ -58,8 +58,7 @@ it('Safari Desktop', async ({ browser, browserName, platform, httpsServer, headl
if (platform === 'linux' || channel === 'webkit-wsl') {
expected.speechrecognition = false;
expected.mediastream = false;
if (headless)
expected.todataurlwebp = true;
expected.todataurlwebp = true;

// GHA
delete actual.variablefonts;
Expand Down Expand Up @@ -90,7 +89,7 @@ it('Safari Desktop', async ({ browser, browserName, platform, httpsServer, headl
expect(actual).toEqual(expected);
});

it('Mobile Safari', async ({ playwright, browser, browserName, platform, httpsServer, headless, channel, isFrozenWebkit }) => {
it('Mobile Safari', async ({ playwright, browser, browserName, platform, httpsServer, channel, isFrozenWebkit }) => {
it.skip(browserName !== 'webkit');
it.skip(browserName === 'webkit' && platform === 'darwin' && os.arch() === 'x64', 'Modernizr uses WebGL which is not available on Intel macOS - https://bugs.webkit.org/show_bug.cgi?id=278277');
it.skip(isFrozenWebkit);
Expand Down Expand Up @@ -122,8 +121,7 @@ it('Mobile Safari', async ({ playwright, browser, browserName, platform, httpsSe
if (platform === 'linux' || channel === 'webkit-wsl') {
expected.speechrecognition = false;
expected.mediastream = false;
if (headless)
expected.todataurlwebp = true;
expected.todataurlwebp = true;

// GHA
delete actual.variablefonts;
Expand Down
4 changes: 3 additions & 1 deletion tests/mcp/http.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ test('http transport browser sigint', async ({ serverEndpoint, server }) => {
});
});

test('http transport browser lifecycle (isolated, multiclient)', async ({ serverEndpoint, server }) => {
test('http transport browser lifecycle (isolated, multiclient)', { annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/41539' } }, async ({ serverEndpoint, server }) => {
const { url, stderr } = await serverEndpoint({ args: ['--isolated'] });

const transport1 = new StreamableHTTPClientTransport(new URL('/mcp', url));
Expand Down Expand Up @@ -200,6 +200,7 @@ test('http transport browser lifecycle (isolated, multiclient)', async ({ server
'delete http session': 3,
'create context': 3,
'create browser (isolated)': 1,
'close context': 2,
'close browser': 1,
});
});
Expand Down Expand Up @@ -229,6 +230,7 @@ test('http transport browser lifecycle (isolated, concurrent clients)', { annota
'delete http session': 3,
'create context': 3,
'create browser (isolated)': 1,
'close context': 2,
'close browser': 1,
});
});
Expand Down
1 change: 1 addition & 0 deletions tests/mcp/sse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ test('sse transport browser lifecycle (isolated, multiclient)', async ({ serverE
'delete SSE session': 3,
'create context': 3,
'create browser (isolated)': 1,
'close context': 2,
'close browser': 1,
});
});
Expand Down
16 changes: 16 additions & 0 deletions tests/page/page-click.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1223,6 +1223,22 @@ it('should fire contextmenu event on right click in correct order', async ({ pag
await expect.poll(() => entries).toEqual(['mousedown', 'contextmenu', 'mouseup']);
});

it('should click after a right click', { annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/39246' } }, async ({ page, browserName }) => {
// On webkit the native context menu opened by the right click swallows the
// following left click, so the button never receives it.
it.fixme(browserName === 'webkit');
await page.setContent(`
<button>Click me</button>
<script>
const button = document.querySelector('button');
button.addEventListener('click', () => button.textContent = 'Clicked!');
</script>
`);
await page.getByRole('button').click({ button: 'right' });
await page.getByRole('button').click();
await expect(page.getByRole('button')).toHaveText('Clicked!');
});

it('should set PointerEvent.pressure on pointerdown', async ({ page, isLinux, headless }) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/35844' });
await page.setContent(`
Expand Down
Loading