chore: throw when using headless-shell with headed mode

This commit is contained in:
Max Schmitt 2024-10-25 13:29:31 +02:00
parent 9707e97867
commit e91fa5e6ff
2 changed files with 7 additions and 0 deletions

View file

@ -294,6 +294,8 @@ export class Chromium extends BrowserType {
throw new Error('Playwright manages remote debugging connection itself.');
if (args.find(arg => !arg.startsWith('-')))
throw new Error('Arguments can not specify page to be opened');
if (!options.headless && options.channel === 'chromium-headless-shell')
throw new Error('Cannot launch headed Chromium via headless-shell. Consider using normal Chromium instead.');
const chromeArguments = [...chromiumSwitches];
if (os.platform() === 'darwin') {

View file

@ -184,3 +184,8 @@ it('should not create pages automatically', async ({ browserType }) => {
await browser.close();
expect(targets.length).toBe(0);
});
it('should throw helpful error when launching chromium-headless-shell channel as headed', async ({ browserType, channel }) => {
it.skip(channel !== 'chromium-headless-shell');
await expect(browserType.launch({ channel: 'chromium-headless-shell', headless: false })).rejects.toThrow('Cannot launch headed Chromium via headless-shell. Consider using normal Chromium instead.');
});