Skip to content
Open
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/src/tools/mcp/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export async function resolveCLIConfigForMCP(cliOptions: CLIOptions, env?: NodeJ

const browser = await validateBrowserConfig(result.browser);
if (browser.launchOptions.headless === undefined)
browser.launchOptions.headless = os.platform() === 'linux' && !process.env.DISPLAY;
browser.launchOptions.headless = os.platform() === 'linux' && !process.env.DISPLAY && !process.env.WAYLAND_DISPLAY;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from what im reading it seems like $WAYLAND_DISPLAY is often a string, and some forums suggest setting it to something known to be nonexistent (e.g. WAYLAND_DISPLAY=no) so im not sure we can just falsy check it here

can you please give a bit more of an explanation as to your setup so we can better understand why this would solve the problem and is the best approach to do so?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea why people set WAYLAND_DISPLAY to "no" as opposed to simply unsetting it. Anyway, the reason somebody does this is most likely because they want to use X11 instead, i.e. DISPLAY is set anyway, so this is not a problem.

The reason why I need this is because X11 is widely considered to be fairly insecure all around; none of the tools I'm using need it any more; and because I want the installation to be as minimal as possible (don't want to assemble a Docker image with a heap of unused X11 libraries and all that …).

Alternate solution: add an explicit "--headed" option …

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding --headed sounds like a right approach if you deliberately want to run headed browser.


validateOutputDir(result.outputDir);

Expand Down
2 changes: 1 addition & 1 deletion packages/playwright/src/mcp/test/testContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class TestContext {
if (options?.headless !== undefined)
this.computedHeaded = !options.headless;
else
this.computedHeaded = !process.env.CI && !(os.platform() === 'linux' && !process.env.DISPLAY);
this.computedHeaded = !process.env.CI && !(os.platform() === 'linux' && !process.env.DISPLAY && !process.env.WAYLAND_DISPLAY);
}

private async _enqueue<T>(fn: () => Promise<T>): Promise<T> {
Expand Down
Loading