diff --git a/src/server/chromium.ts b/src/server/chromium.ts index 7f6f0423bbcc2..e74dc6b7868dd 100644 --- a/src/server/chromium.ts +++ b/src/server/chromium.ts @@ -197,11 +197,13 @@ export class Chromium implements BrowserType { '--mute-audio' ); } - if (launchType !== 'persistent') - chromeArguments.push('--no-startup-window'); chromeArguments.push(...args); - if (args.every(arg => arg.startsWith('-'))) - chromeArguments.push('about:blank'); + if (launchType === 'persistent') { + if (args.every(arg => arg.startsWith('-'))) + chromeArguments.push('about:blank'); + } else { + chromeArguments.push('--no-startup-window'); + } return chromeArguments; } diff --git a/test/chromium/launcher.spec.js b/test/chromium/launcher.spec.js index bc75ec5dabc10..0137b1210b481 100644 --- a/test/chromium/launcher.spec.js +++ b/test/chromium/launcher.spec.js @@ -120,4 +120,20 @@ module.exports.describe = function({testRunner, expect, defaultBrowserOptions, p await rmAsync(downloadsFolder); }); }); + + describe('BrowserContext', function() { + it('should not create pages automatically', async function() { + const browser = await playwright.launch(); + const browserSession = await browser.createBrowserSession(); + const targets = []; + browserSession.on('Target.targetCreated', async ({targetInfo}) => { + if (targetInfo.type !== 'browser') + targets.push(targetInfo); + }); + await browserSession.send('Target.setDiscoverTargets', { discover: true }); + await browser.newContext(); + await browser.close(); + expect(targets.length).toBe(0); + }); + }); };