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

References #19746.
This commit is contained in:
Dmitry Gozman 2023-01-10 10:49:53 -08:00 committed by GitHub
parent 3918e33c91
commit e674ea217f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 11 deletions

View file

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

View file

@ -30,7 +30,6 @@ type Fixtures = {
const test = baseTest.extend<Fixtures>({ const test = baseTest.extend<Fixtures>({
wsEndpoint: async ({ }, use) => { wsEndpoint: async ({ }, use) => {
process.env.PW_DEBUG_CONTROLLER_HEADLESS = '1';
const server = new PlaywrightServer({ path: '/' + createGuid(), maxConnections: Number.MAX_VALUE, enableSocksProxy: false }); const server = new PlaywrightServer({ path: '/' + createGuid(), maxConnections: Number.MAX_VALUE, enableSocksProxy: false });
const wsEndpoint = await server.listen(); const wsEndpoint = await server.listen();
await use(wsEndpoint); await use(wsEndpoint);