Skip to content

Commit

Permalink
cherry-pick(#20336): Revert "chore: respect headless option when reus…
Browse files Browse the repository at this point in the history
…ing browser (#19980)" (#20340)

This reverts commit e674ea2.
  • Loading branch information
dgozman committed Jan 24, 2023
1 parent f8a46e3 commit aea542f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/playwright-core/src/remote/playwrightConnection.ts
Expand Up @@ -220,7 +220,10 @@ export class PlaywrightConnection {
}

if (!browser) {
browser = await playwright[(this._options.browserName || 'chromium') as 'chromium'].launch(serverSideCallMetadata(), this._options.launchOptions);
browser = await playwright[(this._options.browserName || 'chromium') as 'chromium'].launch(serverSideCallMetadata(), {
...this._options.launchOptions,
headless: !!process.env.PW_DEBUG_CONTROLLER_HEADLESS,
});
browser.on(Browser.Events.Disconnected, () => {
// Underlying browser did close for some reason - force disconnect the client.
this.close({ code: 1001, reason: 'Browser closed' });
Expand Down Expand Up @@ -284,6 +287,8 @@ function launchOptionsHash(options: LaunchOptions) {
if (copy[key] === defaultLaunchOptions[key])
delete copy[key];
}
for (const key of optionsThatAllowBrowserReuse)
delete copy[key];
return JSON.stringify(copy);
}

Expand All @@ -295,3 +300,7 @@ const defaultLaunchOptions: LaunchOptions = {
headless: true,
devtools: false,
};

const optionsThatAllowBrowserReuse: (keyof LaunchOptions)[] = [
'headless',
];
1 change: 1 addition & 0 deletions tests/library/debug-controller.spec.ts
Expand Up @@ -30,6 +30,7 @@ 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);
Expand Down

0 comments on commit aea542f

Please sign in to comment.