chore: throw when using headless-shell with headed mode (#33292)

This commit is contained in:
Max Schmitt 2024-10-28 22:33:21 +01:00 committed by GitHub
parent 19e863191c
commit 5c0fdfed50
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 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 with `chromium-headless-shell` channel. Consider using regular Chromium instead.');
const chromeArguments = [...chromiumSwitches];
if (os.platform() === 'darwin') {

View File

@ -184,3 +184,10 @@ 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 with `chromium-headless-shell` channel. Consider using regular Chromium instead.'
);
});