cherry-pick(#20336): Revert "chore: respect headless option when reusing browser (#19980)" (#20340)

This reverts commit e674ea217f.
This commit is contained in:
Dmitry Gozman 2023-01-24 13:06:01 -08:00 коммит произвёл GitHub
Родитель f8a46e34b8
Коммит aea542f7a2
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 11 добавлений и 1 удалений

Просмотреть файл

@ -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' });
@ -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);
}
@ -295,3 +300,7 @@ const defaultLaunchOptions: LaunchOptions = {
headless: true,
devtools: false,
};
const optionsThatAllowBrowserReuse: (keyof LaunchOptions)[] = [
'headless',
];

Просмотреть файл

@ -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);