Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore: respect headless option when reusing browser (#19980)

Dmitry Gozmane674ea217f5f
diff --git a/packages/playwright-core/src/remote/playwrightConnection.ts b/packages/playwright-core/src/remote/playwrightConnection.ts
index 005918f686..d3b8f1762a 100644
--- a/packages/playwright-core/src/remote/playwrightConnection.ts
+++ b/packages/playwright-core/src/remote/playwrightConnection.ts
@@ -220,10 +220,7 @@ export class PlaywrightConnection {
}
if (!browser) {
- browser = await playwright[(this._options.browserName || 'chromium') as 'chromium'].launch(serverSideCallMetadata(), {
- ...this._options.launchOptions,
- headless: !!process.env.PW_DEBUG_CONTROLLER_HEADLESS,
- });
+ browser = await playwright[(this._options.browserName || 'chromium') as 'chromium'].launch(serverSideCallMetadata(), this._options.launchOptions);
browser.on(Browser.Events.Disconnected, () => {
// Underlying browser did close for some reason - force disconnect the client.
this.close({ code: 1001, reason: 'Browser closed' });
@@ -287,8 +284,6 @@ function launchOptionsHash(options: LaunchOptions) {
if (copy[key] === defaultLaunchOptions[key])
delete copy[key];
}
- for (const key of optionsThatAllowBrowserReuse)
- delete copy[key];
return JSON.stringify(copy);
}
@@ -300,7 +295,3 @@ const defaultLaunchOptions: LaunchOptions = {
headless: true,
devtools: false,
};
-
-const optionsThatAllowBrowserReuse: (keyof LaunchOptions)[] = [
- 'headless',
-];
diff --git a/tests/library/debug-controller.spec.ts b/tests/library/debug-controller.spec.ts
index fc1f224335..855709a11a 100644
--- a/tests/library/debug-controller.spec.ts
+++ b/tests/library/debug-controller.spec.ts
@@ -30,7 +30,6 @@ type Fixtures = {
const test = baseTest.extend<Fixtures>({
wsEndpoint: async ({ }, use) => {
- process.env.PW_DEBUG_CONTROLLER_HEADLESS = '1';
const server = new PlaywrightServer({ path: '/' + createGuid(), maxConnections: Number.MAX_VALUE, enableSocksProxy: false });
const wsEndpoint = await server.listen();
await use(wsEndpoint);