Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
test: remove browserOptions (#9829)
Pavel Feldman16afb5064fd4
diff --git a/packages/playwright-core/src/client/browserType.ts b/packages/playwright-core/src/client/browserType.tsindex 187eb6276e..3e0bfda3a9 100644--- a/packages/playwright-core/src/client/browserType.ts+++ b/packages/playwright-core/src/client/browserType.ts@@ -88,6 +88,7 @@ export class BrowserType extends ChannelOwner<channels.BrowserTypeChannel, channasync launchServer(options: LaunchServerOptions = {}): Promise<api.BrowserServer> {if (!this._serverLauncher)throw new Error('Launching server is not supported');+ options = { ...this._defaultLaunchOptions, ...options };return this._serverLauncher.launchServer(options);}diff --git a/tests/beforeunload.spec.ts b/tests/beforeunload.spec.tsindex cf98a14995..bebe4ca3df 100644--- a/tests/beforeunload.spec.ts+++ b/tests/beforeunload.spec.ts@@ -17,8 +17,8 @@import { contextTest as it, expect } from './config/browserTest';-it('should close browser with beforeunload page', async ({ server, browserType, browserOptions }) => {- const browser = await browserType.launch(browserOptions);+it('should close browser with beforeunload page', async ({ server, browserType }) => {+ const browser = await browserType.launch();const page = await browser.newPage();await page.goto(server.PREFIX + '/beforeunload.html');// We have to interact with a page so that 'beforeunload' handlersdiff --git a/tests/browsercontext-add-cookies.spec.ts b/tests/browsercontext-add-cookies.spec.tsindex 117de82513..6e591a5840 100644--- a/tests/browsercontext-add-cookies.spec.ts+++ b/tests/browsercontext-add-cookies.spec.ts@@ -175,15 +175,15 @@ it('should isolate send cookie header', async ({ server, context, browser }) =>}});-playwrightTest('should isolate cookies between launches', async ({ browserType, server, browserOptions }) => {+playwrightTest('should isolate cookies between launches', async ({ browserType, server }) => {playwrightTest.slow();- const browser1 = await browserType.launch(browserOptions);+ const browser1 = await browserType.launch();const context1 = await browser1.newContext();await context1.addCookies([{ url: server.EMPTY_PAGE, name: 'cookie-in-context-1', value: 'value', expires: Date.now() / 1000 + 10000 }]);await browser1.close();- const browser2 = await browserType.launch(browserOptions);+ const browser2 = await browserType.launch();const context2 = await browser2.newContext();const cookies = await context2.cookies();expect(cookies.length).toBe(0);diff --git a/tests/browsercontext-base-url.spec.ts b/tests/browsercontext-base-url.spec.tsindex 639776442c..29e258b0d7 100644--- a/tests/browsercontext-base-url.spec.ts+++ b/tests/browsercontext-base-url.spec.ts@@ -34,10 +34,9 @@ it('should construct a new URL when a baseURL in browser.newPage is passed to paawait page.close();});-it('should construct a new URL when a baseURL in browserType.launchPersistentContext is passed to page.goto', async function({ browserType, server, createUserDataDir, browserOptions }) {+it('should construct a new URL when a baseURL in browserType.launchPersistentContext is passed to page.goto', async function({ browserType, server, createUserDataDir }) {const userDataDir = await createUserDataDir();const context = await browserType.launchPersistentContext(userDataDir, {- ...browserOptions,baseURL: server.PREFIX,});const page = await context.newPage();diff --git a/tests/browsercontext-fetch.spec.ts b/tests/browsercontext-fetch.spec.tsindex d89ef74f73..3f7527d1be 100644--- a/tests/browsercontext-fetch.spec.ts+++ b/tests/browsercontext-fetch.spec.ts@@ -336,13 +336,12 @@ it('should return raw headers', async ({ context, page, server }) => {expect(response.headers()['name-b']).toBe('v4');});-it('should work with context level proxy', async ({ browserOptions, browserType, contextOptions, server, proxyServer }) => {+it('should work with context level proxy', async ({ browserType, contextOptions, server, proxyServer }) => {server.setRoute('/target.html', async (req, res) => {res.end('<title>Served by the proxy</title>');});const browser = await browserType.launch({- ...browserOptions,proxy: { server: 'http://per-context' }});@@ -364,7 +363,7 @@ it('should work with context level proxy', async ({ browserOptions, browserType,}});-it('should pass proxy credentials', async ({ browserType, browserOptions, server, proxyServer }) => {+it('should pass proxy credentials', async ({ browserType, server, proxyServer }) => {proxyServer.forwardTo(server.PORT);let auth;proxyServer.setAuthHandler(req => {@@ -372,7 +371,6 @@ it('should pass proxy credentials', async ({ browserType, browserOptions, serverreturn !!auth;});const browser = await browserType.launch({- ...browserOptions,proxy: { server: `localhost:${proxyServer.PORT}`, username: 'user', password: 'secret' }});const context = await browser.newContext();diff --git a/tests/browsercontext-proxy.spec.ts b/tests/browsercontext-proxy.spec.tsindex 067d85e2b6..b22ffecaee 100644--- a/tests/browsercontext-proxy.spec.ts+++ b/tests/browsercontext-proxy.spec.ts@@ -32,13 +32,12 @@ it.beforeEach(({ server }) => {});});-it('should throw for missing global proxy on Chromium Windows', async ({ browserName, platform, browserType, browserOptions, server }) => {+it('should throw for missing global proxy on Chromium Windows', async ({ browserName, platform, browserType, server }) => {it.skip(browserName !== 'chromium' || platform !== 'win32');let browser;try {browser = await browserType.launch({- ...browserOptions,proxy: undefined,});const error = await browser.newContext({ proxy: { server: `localhost:${server.PORT}` } }).catch(e => e);@@ -48,7 +47,7 @@ it('should throw for missing global proxy on Chromium Windows', async ({ browser}});-it('should work when passing the proxy only on the context level', async ({ browserName, platform, browserType, browserOptions, contextOptions, server, proxyServer }) => {+it('should work when passing the proxy only on the context level', async ({ browserName, platform, browserType, contextOptions, server, proxyServer }) => {// Currently an upstream bug in the network stack of Chromium which leads that// the wrong proxy gets used in the BrowserContext.it.fixme(browserName === 'chromium' && platform === 'win32');@@ -57,7 +56,6 @@ it('should work when passing the proxy only on the context level', async ({ browlet browser;try {browser = await browserType.launch({- ...browserOptions,proxy: undefined,});const context = await browser.newContext({diff --git a/tests/browsertype-basic.spec.ts b/tests/browsertype-basic.spec.tsindex b0f4a83123..c29229c658 100644--- a/tests/browsertype-basic.spec.ts+++ b/tests/browsertype-basic.spec.ts@@ -18,9 +18,9 @@import fs from 'fs';import { playwrightTest as test, expect } from './config/browserTest';-test('browserType.executablePath should work', async ({ browserType, channel, browserOptions }) => {+test('browserType.executablePath should work', async ({ browserType, channel }) => {test.skip(!!channel, 'We skip browser download when testing a channel');- test.skip(!!browserOptions.executablePath, 'Skip with custom executable path');+ test.skip(!!(browserType as any)._defaultLaunchOptions.executablePath, 'Skip with custom executable path');const executablePath = browserType.executablePath();expect(fs.existsSync(executablePath)).toBe(true);diff --git a/tests/browsertype-launch-selenium.spec.ts b/tests/browsertype-launch-selenium.spec.tsindex 667d375431..d518d5b2f3 100644--- a/tests/browsertype-launch-selenium.spec.ts+++ b/tests/browsertype-launch-selenium.spec.ts@@ -37,7 +37,7 @@ test.skip(({ mode }) => mode !== 'default', 'Using test hooks');test.skip(() => !!process.env.INSIDE_DOCKER, 'Docker image does not have Java');test.slow();-test('selenium grid 3.141.59 standalone chromium', async ({ browserOptions, browserName, childProcess, waitForPort, browserType }, testInfo) => {+test('selenium grid 3.141.59 standalone chromium', async ({ browserName, childProcess, waitForPort, browserType }, testInfo) => {test.skip(browserName !== 'chromium');const port = testInfo.workerIndex + 15123;@@ -48,7 +48,7 @@ test('selenium grid 3.141.59 standalone chromium', async ({ browserOptions, browawait waitForPort(port);const __testHookSeleniumRemoteURL = `http://localhost:${port}/wd/hub`;- const browser = await browserType.launch({ ...browserOptions, __testHookSeleniumRemoteURL } as any);+ const browser = await browserType.launch({ __testHookSeleniumRemoteURL } as any);const page = await browser.newPage();await page.setContent('<title>Hello world</title><div>Get Started</div>');await page.click('text=Get Started');@@ -60,7 +60,7 @@ test('selenium grid 3.141.59 standalone chromium', async ({ browserOptions, browawait grid.waitForOutput('Removing session');});-test('selenium grid 4.0.0-rc-1 standalone chromium', async ({ browserOptions, browserName, childProcess, waitForPort, browserType }, testInfo) => {+test('selenium grid 4.0.0-rc-1 standalone chromium', async ({ browserName, childProcess, waitForPort, browserType }, testInfo) => {test.skip(browserName !== 'chromium');const port = testInfo.workerIndex + 15123;@@ -71,7 +71,7 @@ test('selenium grid 4.0.0-rc-1 standalone chromium', async ({ browserOptions, brawait waitForPort(port);const __testHookSeleniumRemoteURL = `http://localhost:${port}/wd/hub`;- const browser = await browserType.launch({ ...browserOptions, __testHookSeleniumRemoteURL } as any);+ const browser = await browserType.launch({ __testHookSeleniumRemoteURL } as any);const page = await browser.newPage();await page.setContent('<title>Hello world</title><div>Get Started</div>');await page.click('text=Get Started');@@ -83,7 +83,7 @@ test('selenium grid 4.0.0-rc-1 standalone chromium', async ({ browserOptions, brawait grid.waitForOutput('Deleted session');});-test('selenium grid 4.0.0-rc-1 standalone chromium broken driver', async ({ browserOptions, browserName, childProcess, waitForPort, browserType }, testInfo) => {+test('selenium grid 4.0.0-rc-1 standalone chromium broken driver', async ({ browserName, childProcess, waitForPort, browserType }, testInfo) => {test.skip(browserName !== 'chromium');const port = testInfo.workerIndex + 15123;@@ -94,7 +94,7 @@ test('selenium grid 4.0.0-rc-1 standalone chromium broken driver', async ({ browawait waitForPort(port);const __testHookSeleniumRemoteURL = `http://localhost:${port}/wd/hub`;- const error = await browserType.launch({ ...browserOptions, __testHookSeleniumRemoteURL } as any).catch(e => e);+ const error = await browserType.launch({ __testHookSeleniumRemoteURL } as any).catch(e => e);expect(error.message).toContain(`Error connecting to Selenium at http://localhost:${port}/wd/hub/: Could not start a new session`);expect(grid.output).not.toContain('Starting ChromeDriver');@@ -108,7 +108,7 @@ test('selenium grid 3.141.59 standalone non-chromium', async ({ browserName, broexpect(error.message).toContain('Connecting to SELENIUM_REMOTE_URL is only supported by Chromium');});-test('selenium grid 3.141.59 standalone chromium through driver', async ({ browserOptions, browserName, childProcess, waitForPort }, testInfo) => {+test('selenium grid 3.141.59 standalone chromium through driver', async ({ browserName, childProcess, waitForPort }, testInfo) => {test.skip(browserName !== 'chromium');const port = testInfo.workerIndex + 15123;@@ -121,7 +121,7 @@ test('selenium grid 3.141.59 standalone chromium through driver', async ({ browsconst { playwright: pw, stop } = await start({SELENIUM_REMOTE_URL: `http://localhost:${port}/wd/hub`,});- const browser = await pw.chromium.launch(browserOptions);+ const browser = await pw.chromium.launch();const page = await browser.newPage();await page.setContent('<title>Hello world</title><div>Get Started</div>');await page.click('text=Get Started');diff --git a/tests/browsertype-launch-server.spec.ts b/tests/browsertype-launch-server.spec.tsindex 30f41e79cd..f7c469ebbf 100644--- a/tests/browsertype-launch-server.spec.ts+++ b/tests/browsertype-launch-server.spec.ts@@ -20,49 +20,49 @@ import { playwrightTest as it, expect } from './config/browserTest';it.describe('launch server', () => {it.skip(({ mode }) => mode !== 'default');- it('should work', async ({ browserType, browserOptions }) => {- const browserServer = await browserType.launchServer(browserOptions);+ it('should work', async ({ browserType }) => {+ const browserServer = await browserType.launchServer();expect(browserServer.wsEndpoint()).not.toBe(null);await browserServer.close();});- it('should work with port', async ({ browserType, browserOptions }, testInfo) => {+ it('should work with port', async ({ browserType }, testInfo) => {const port = 8800 + testInfo.workerIndex;- const browserServer = await browserType.launchServer({ ...browserOptions, port });+ const browserServer = await browserType.launchServer({ port });expect(browserServer.wsEndpoint()).toContain(String(port));await browserServer.close();});- it('should work with wsPath', async ({ browserType, browserOptions }) => {+ it('should work with wsPath', async ({ browserType }) => {const wsPath = '/unguessable-token';- const browserServer = await browserType.launchServer({ ...browserOptions, wsPath });+ const browserServer = await browserType.launchServer({ wsPath });expect(browserServer.wsEndpoint()).toMatch(/:\d+\/unguessable-token$/);await browserServer.close();});- it('should work when wsPath is missing leading slash', async ({ browserType, browserOptions }) => {+ it('should work when wsPath is missing leading slash', async ({ browserType }) => {const wsPath = 'unguessable-token';- const browserServer = await browserType.launchServer({ ...browserOptions, wsPath });+ const browserServer = await browserType.launchServer({ wsPath });expect(browserServer.wsEndpoint()).toMatch(/:\d+\/unguessable-token$/);await browserServer.close();});- it('should default to random wsPath', async ({ browserType, browserOptions }) => {- const browserServer = await browserType.launchServer({ ...browserOptions });+ it('should default to random wsPath', async ({ browserType }) => {+ const browserServer = await browserType.launchServer();expect(browserServer.wsEndpoint()).toMatch(/:\d+\/[a-f\d]{32}$/);await browserServer.close();});- it('should provide an error when ws endpoint is incorrect', async ({ browserType, browserOptions }) => {- const browserServer = await browserType.launchServer(browserOptions);+ it('should provide an error when ws endpoint is incorrect', async ({ browserType }) => {+ const browserServer = await browserType.launchServer();const error = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() + '-foo' }).catch(e => e);await browserServer.close();expect(error.message).toContain('Unexpected server response: 400');});- it('should fire "close" event during kill', async ({ browserType, browserOptions }) => {+ it('should fire "close" event during kill', async ({ browserType }) => {const order = [];- const browserServer = await browserType.launchServer(browserOptions);+ const browserServer = await browserType.launchServer();const closedPromise = new Promise<void>(f => browserServer.on('close', () => {order.push('closed');f();@@ -74,14 +74,14 @@ it.describe('launch server', () => {expect(order).toEqual(['closed', 'killed']);});- it('should return child_process instance', async ({ browserType, browserOptions }) => {- const browserServer = await browserType.launchServer(browserOptions);+ it('should return child_process instance', async ({ browserType }) => {+ const browserServer = await browserType.launchServer();expect(browserServer.process().pid).toBeGreaterThan(0);await browserServer.close();});- it('should fire close event', async ({ browserType, browserOptions }) => {- const browserServer = await browserType.launchServer(browserOptions);+ it('should fire close event', async ({ browserType }) => {+ const browserServer = await browserType.launchServer();const [result] = await Promise.all([// @ts-expect-error The signal parameter is not documented.new Promise(f => browserServer.on('close', (exitCode, signal) => f({ exitCode, signal }))),@@ -91,7 +91,7 @@ it.describe('launch server', () => {expect(result['signal']).toBe(null);});- it('should log protocol', async ({ browserType, browserOptions }) => {+ it('should log protocol', async ({ browserType }) => {const logs: string[] = [];const logger = {isEnabled(name: string) {@@ -102,7 +102,7 @@ it.describe('launch server', () => {}};- const browserServer = await browserType.launchServer({ ...browserOptions, logger });+ const browserServer = await browserType.launchServer({ logger });await browserServer.close();expect(logs.some(log => log.startsWith('protocol:verbose:SEND ►'))).toBe(true);diff --git a/tests/browsertype-launch.spec.ts b/tests/browsertype-launch.spec.tsindex 3f48ace2b7..4b2d23b193 100644--- a/tests/browsertype-launch.spec.ts+++ b/tests/browsertype-launch.spec.ts@@ -17,8 +17,8 @@import { playwrightTest as it, expect } from './config/browserTest';-it('should reject all promises when browser is closed', async ({ browserType, browserOptions }) => {- const browser = await browserType.launch(browserOptions);+it('should reject all promises when browser is closed', async ({ browserType }) => {+ const browser = await browserType.launch();const page = await (await browser.newContext()).newPage();let error = null;const neverResolves = page.evaluate(() => new Promise(r => {})).catch(e => error = e);@@ -29,91 +29,84 @@ it('should reject all promises when browser is closed', async ({ browserType, brexpect(error.message).toContain(' closed');});-it('should throw if userDataDir option is passed', async ({ browserType, browserOptions }) => {+it('should throw if userDataDir option is passed', async ({ browserType }) => {let waitError = null;- const options = Object.assign({}, browserOptions, { userDataDir: 'random-path' });- await browserType.launch(options).catch(e => waitError = e);+ await browserType.launch({ userDataDir: 'random-path' } as any).catch(e => waitError = e);expect(waitError.message).toContain('userDataDir option is not supported in `browserType.launch`. Use `browserType.launchPersistentContext` instead');});-it('should throw if userDataDir is passed as an argument', async ({ browserType, browserOptions }) => {+it('should throw if userDataDir is passed as an argument', async ({ browserType }) => {let waitError = null;- const options = Object.assign({}, browserOptions, { args: ['--user-data-dir=random-path', '--profile=random-path'] });- await browserType.launch(options).catch(e => waitError = e);+ await browserType.launch({ args: ['--user-data-dir=random-path', '--profile=random-path'] } as any).catch(e => waitError = e);expect(waitError.message).toContain('Pass userDataDir parameter to `browserType.launchPersistentContext');});-it('should throw if port option is passed', async ({ browserType, browserOptions }) => {- const options = Object.assign({}, browserOptions, { port: 1234 });- const error = await browserType.launch(options).catch(e => e);+it('should throw if port option is passed', async ({ browserType }) => {+ const error = await browserType.launch({ port: 1234 } as any).catch(e => e);expect(error.message).toContain('Cannot specify a port without launching as a server.');});-it('should throw if port option is passed for persistent context', async ({ browserType, browserOptions }) => {- const options = Object.assign({}, browserOptions, { port: 1234 });- const error = await browserType.launchPersistentContext('foo', options).catch(e => e);+it('should throw if port option is passed for persistent context', async ({ browserType }) => {+ const error = await browserType.launchPersistentContext('foo', { port: 1234 } as any).catch(e => e);expect(error.message).toContain('Cannot specify a port without launching as a server.');});-it('should throw if page argument is passed', async ({ browserType, browserOptions, browserName }) => {+it('should throw if page argument is passed', async ({ browserType, browserName }) => {it.skip(browserName === 'firefox');let waitError = null;- const options = Object.assign({}, browserOptions, { args: ['http://example.com'] });- await browserType.launch(options).catch(e => waitError = e);+ await browserType.launch({ args: ['http://example.com'] }).catch(e => waitError = e);expect(waitError.message).toContain('can not specify page');});-it('should reject if launched browser fails immediately', async ({ browserType, browserOptions, asset }) => {- const options = Object.assign({}, browserOptions, { executablePath: asset('dummy_bad_browser_executable.js') });+it('should reject if launched browser fails immediately', async ({ browserType, asset }) => {let waitError = null;- await browserType.launch(options).catch(e => waitError = e);+ await browserType.launch({ executablePath: asset('dummy_bad_browser_executable.js') }).catch(e => waitError = e);expect(waitError.message).toContain('== logs ==');});-it('should reject if executable path is invalid', async ({ browserType, browserOptions }) => {+it('should reject if executable path is invalid', async ({ browserType }) => {let waitError = null;- const options = Object.assign({}, browserOptions, { executablePath: 'random-invalid-path' });- await browserType.launch(options).catch(e => waitError = e);+ await browserType.launch({ executablePath: 'random-invalid-path' }).catch(e => waitError = e);expect(waitError.message).toContain('Failed to launch');});-it('should handle timeout', async ({ browserType, browserOptions, mode }) => {+it('should handle timeout', async ({ browserType, mode }) => {it.skip(mode !== 'default');- const options = { ...browserOptions, timeout: 5000, __testHookBeforeCreateBrowser: () => new Promise(f => setTimeout(f, 6000)) };+ const options: any = { timeout: 5000, __testHookBeforeCreateBrowser: () => new Promise(f => setTimeout(f, 6000)) };const error = await browserType.launch(options).catch(e => e);expect(error.message).toContain(`browserType.launch: Timeout 5000ms exceeded.`);expect(error.message).toContain(`<launching>`);expect(error.message).toContain(`<launched> pid=`);});-it('should handle exception', async ({ browserType, browserOptions, mode }) => {+it('should handle exception', async ({ browserType, mode }) => {it.skip(mode !== 'default');const e = new Error('Dummy');- const options = { ...browserOptions, __testHookBeforeCreateBrowser: () => { throw e; }, timeout: 9000 };+ const options = { __testHookBeforeCreateBrowser: () => { throw e; }, timeout: 9000 };const error = await browserType.launch(options).catch(e => e);expect(error.message).toContain('Dummy');});-it('should report launch log', async ({ browserType, browserOptions, mode }) => {+it('should report launch log', async ({ browserType, mode }) => {it.skip(mode !== 'default');const e = new Error('Dummy');- const options = { ...browserOptions, __testHookBeforeCreateBrowser: () => { throw e; }, timeout: 9000 };+ const options = { __testHookBeforeCreateBrowser: () => { throw e; }, timeout: 9000 };const error = await browserType.launch(options).catch(e => e);expect(error.message).toContain('<launching>');});-it('should accept objects as options', async ({ browserType, browserOptions }) => {+it('should accept objects as options', async ({ browserType }) => {// @ts-expect-error process is not a real option.- const browser = await browserType.launch({ ...browserOptions, process });+ const browser = await browserType.launch({ process });await browser.close();});-it('should fire close event for all contexts', async ({ browserType, browserOptions }) => {- const browser = await browserType.launch(browserOptions);+it('should fire close event for all contexts', async ({ browserType }) => {+ const browser = await browserType.launch();const context = await browser.newContext();let closed = false;context.on('close', () => closed = true);@@ -121,8 +114,8 @@ it('should fire close event for all contexts', async ({ browserType, browserOptiexpect(closed).toBe(true);});-it('should be callable twice', async ({ browserType, browserOptions }) => {- const browser = await browserType.launch(browserOptions);+it('should be callable twice', async ({ browserType }) => {+ const browser = await browserType.launch();await Promise.all([browser.close(),browser.close(),diff --git a/tests/channels.spec.ts b/tests/channels.spec.tsindex 0293e164db..aabda95c79 100644--- a/tests/channels.spec.ts+++ b/tests/channels.spec.ts@@ -26,8 +26,8 @@ it.use({}});-it('should scope context handles', async ({ browserType, browserOptions, server }) => {- const browser = await browserType.launch(browserOptions);+it('should scope context handles', async ({ browserType, server }) => {+ const browser = await browserType.launch();const GOLDEN_PRECONDITION = {_guid: '',objects: [@@ -75,10 +75,10 @@ it('should scope context handles', async ({ browserType, browserOptions, serverawait browser.close();});-it('should scope CDPSession handles', async ({ browserType, browserOptions, browserName }) => {+it('should scope CDPSession handles', async ({ browserType, browserName }) => {it.skip(browserName !== 'chromium');- const browser = await browserType.launch(browserOptions);+ const browser = await browserType.launch();const GOLDEN_PRECONDITION = {_guid: '',objects: [@@ -119,7 +119,7 @@ it('should scope CDPSession handles', async ({ browserType, browserOptions, browawait browser.close();});-it('should scope browser handles', async ({ browserType, browserOptions }) => {+it('should scope browser handles', async ({ browserType }) => {const GOLDEN_PRECONDITION = {_guid: '',objects: [@@ -134,7 +134,7 @@ it('should scope browser handles', async ({ browserType, browserOptions }) => {};await expectScopeState(browserType, GOLDEN_PRECONDITION);- const browser = await browserType.launch(browserOptions);+ const browser = await browserType.launch();await browser.newContext();await expectScopeState(browserType, {_guid: '',@@ -161,13 +161,13 @@ it('should scope browser handles', async ({ browserType, browserOptions }) => {await expectScopeState(browserType, GOLDEN_PRECONDITION);});-it('should work with the domain module', async ({ browserType, browserOptions, server, browserName }) => {+it('should work with the domain module', async ({ browserType, server, browserName }) => {const local = domain.create();local.run(() => { });let err;local.on('error', e => err = e);- const browser = await browserType.launch(browserOptions);+ const browser = await browserType.launch();const page = await browser.newPage();expect(await page.evaluate(() => 1 + 1)).toBe(2);diff --git a/tests/chromium/chromium.spec.ts b/tests/chromium/chromium.spec.tsindex 38d3de592c..21a547ecb4 100644--- a/tests/chromium/chromium.spec.ts+++ b/tests/chromium/chromium.spec.ts@@ -78,8 +78,8 @@ test('Page.route should work with intervention headers', async ({ server, page }expect(serverRequest.headers.intervention).toContain('feature/5718547946799104');});-playwrightTest('should close service worker together with the context', async ({ browserType, browserOptions, server }) => {- const browser = await browserType.launch(browserOptions);+playwrightTest('should close service worker together with the context', async ({ browserType, server }) => {+ const browser = await browserType.launch();const context = await browser.newContext();const page = await context.newPage();const [worker] = await Promise.all([@@ -94,10 +94,9 @@ playwrightTest('should close service worker together with the context', async ({await browser.close();});-playwrightTest('should connect to an existing cdp session', async ({ browserType, browserOptions }, testInfo) => {+playwrightTest('should connect to an existing cdp session', async ({ browserType }, testInfo) => {const port = 9339 + testInfo.workerIndex;const browserServer = await browserType.launch({- ...browserOptions,args: ['--remote-debugging-port=' + port]});try {@@ -112,10 +111,9 @@ playwrightTest('should connect to an existing cdp session', async ({ browserType}});-playwrightTest('should connect to an existing cdp session twice', async ({ browserType, browserOptions, server }, testInfo) => {+playwrightTest('should connect to an existing cdp session twice', async ({ browserType, server }, testInfo) => {const port = 9339 + testInfo.workerIndex;const browserServer = await browserType.launch({- ...browserOptions,args: ['--remote-debugging-port=' + port]});try {@@ -147,10 +145,9 @@ playwrightTest('should connect to an existing cdp session twice', async ({ brows}});-playwrightTest('should connect to existing page with iframe and navigate', async ({ browserType, browserOptions, server }, testInfo) => {+playwrightTest('should connect to existing page with iframe and navigate', async ({ browserType, server }, testInfo) => {const port = 9339 + testInfo.workerIndex;const browserServer = await browserType.launch({- ...browserOptions,args: ['--remote-debugging-port=' + port]});try {@@ -169,10 +166,9 @@ playwrightTest('should connect to existing page with iframe and navigate', async}});-playwrightTest('should connect to existing service workers', async ({ browserType, browserOptions, server }, testInfo) => {+playwrightTest('should connect to existing service workers', async ({ browserType, server }, testInfo) => {const port = 9339 + testInfo.workerIndex;const browserServer = await browserType.launch({- ...browserOptions,args: ['--remote-debugging-port=' + port]});try {@@ -199,10 +195,9 @@ playwrightTest('should connect to existing service workers', async ({ browserTyp}});-playwrightTest('should connect over a ws endpoint', async ({ browserType, browserOptions, server }, testInfo) => {+playwrightTest('should connect over a ws endpoint', async ({ browserType, server }, testInfo) => {const port = 9339 + testInfo.workerIndex;const browserServer = await browserType.launch({- ...browserOptions,args: ['--remote-debugging-port=' + port]});try {@@ -232,7 +227,7 @@ playwrightTest('should connect over a ws endpoint', async ({ browserType, browse}});-playwrightTest('should send extra headers with connect request', async ({ browserType, browserOptions, server }, testInfo) => {+playwrightTest('should send extra headers with connect request', async ({ browserType, server }, testInfo) => {{const [request] = await Promise.all([server.waitForWebSocketConnectionRequest(),@@ -265,7 +260,7 @@ playwrightTest('should send extra headers with connect request', async ({ browse}});-playwrightTest('should send default User-Agent header with connect request', async ({ browserType, browserOptions, server }, testInfo) => {+playwrightTest('should send default User-Agent header with connect request', async ({ browserType, server }, testInfo) => {{const [request] = await Promise.all([server.waitForWebSocketConnectionRequest(),@@ -282,10 +277,9 @@ playwrightTest('should send default User-Agent header with connect request', asy}});-playwrightTest('should report all pages in an existing browser', async ({ browserType, browserOptions }, testInfo) => {+playwrightTest('should report all pages in an existing browser', async ({ browserType }, testInfo) => {const port = 9339 + testInfo.workerIndex;const browserServer = await browserType.launch({- ...browserOptions,args: ['--remote-debugging-port=' + port]});try {@@ -309,11 +303,10 @@ playwrightTest('should report all pages in an existing browser', async ({ browse}});-playwrightTest('should connect via https', async ({ browserType, browserOptions, httpsServer, mode }, testInfo) => {+playwrightTest('should connect via https', async ({ browserType, httpsServer, mode }, testInfo) => {test.skip(mode !== 'default'); // Out of process transport does not allow us to set env vars dynamically.const port = 9339 + testInfo.workerIndex;const browserServer = await browserType.launch({- ...browserOptions,args: ['--remote-debugging-port=' + port]});const json = await new Promise<string>((resolve, reject) => {@@ -344,10 +337,9 @@ playwrightTest('should connect via https', async ({ browserType, browserOptions,}});-playwrightTest('should return valid browser from context.browser()', async ({ browserType, browserOptions }, testInfo) => {+playwrightTest('should return valid browser from context.browser()', async ({ browserType }, testInfo) => {const port = 9339 + testInfo.workerIndex;const browserServer = await browserType.launch({- ...browserOptions,args: ['--remote-debugging-port=' + port]});try {@@ -390,10 +382,9 @@ test('should report an expected error when the endpoint URL JSON webSocketDebugg})).rejects.toThrowError('browserType.connectOverCDP: Invalid URL');});-playwrightTest('should connect to an existing cdp session when passed as a first argument', async ({ browserType, browserOptions }, testInfo) => {+playwrightTest('should connect to an existing cdp session when passed as a first argument', async ({ browserType }, testInfo) => {const port = 9339 + testInfo.workerIndex;const browserServer = await browserType.launch({- ...browserOptions,args: ['--remote-debugging-port=' + port]});try {diff --git a/tests/chromium/launcher.spec.ts b/tests/chromium/launcher.spec.tsindex c5444cc0ad..00a9ee7302 100644--- a/tests/chromium/launcher.spec.ts+++ b/tests/chromium/launcher.spec.ts@@ -16,25 +16,25 @@import { playwrightTest as it, expect } from '../config/browserTest';-it('should throw with remote-debugging-pipe argument', async ({ browserType, browserOptions, mode }) => {+it('should throw with remote-debugging-pipe argument', async ({ browserType, mode }) => {it.skip(mode !== 'default');- const options = Object.assign({}, browserOptions);+ const options: any = {};options.args = ['--remote-debugging-pipe'].concat(options.args || []);const error = await browserType.launchServer(options).catch(e => e);expect(error.message).toContain('Playwright manages remote debugging connection itself');});-it('should not throw with remote-debugging-port argument', async ({ browserType, browserOptions, mode }) => {+it('should not throw with remote-debugging-port argument', async ({ browserType, mode }) => {it.skip(mode !== 'default');- const options = Object.assign({}, browserOptions);+ const options: any = {};options.args = ['--remote-debugging-port=0'].concat(options.args || []);const browser = await browserType.launchServer(options);await browser.close();});-it('should open devtools when "devtools: true" option is given', async ({ browserType, browserOptions, mode, platform, channel }) => {+it('should open devtools when "devtools: true" option is given', async ({ browserType, mode, platform, channel }) => {it.skip(mode !== 'default' || platform === 'win32' || !!channel);let devtoolsCallback;@@ -43,7 +43,7 @@ it('should open devtools when "devtools: true" option is given', async ({ browseif (parsed.method === 'getPreferences')devtoolsCallback();};- const browser = await browserType.launch({ ...browserOptions, headless: false, devtools: true, __testHookForDevTools } as any);+ const browser = await browserType.launch({ headless: false, devtools: true, __testHookForDevTools } as any);const context = await browser.newContext();await Promise.all([devtoolsPromise,@@ -52,10 +52,10 @@ it('should open devtools when "devtools: true" option is given', async ({ browseawait browser.close();});-it('should return background pages', async ({ browserType, browserOptions, createUserDataDir, asset }) => {+it('should return background pages', async ({ browserType, createUserDataDir, asset }) => {const userDataDir = await createUserDataDir();const extensionPath = asset('simple-extension');- const extensionOptions = { ...browserOptions,+ const extensionOptions = {headless: false,args: [`--disable-extensions-except=${extensionPath}`,@@ -75,10 +75,10 @@ it('should return background pages', async ({ browserType, browserOptions, createxpect(context.backgroundPages().length).toBe(0);});-it('should return background pages when recording video', async ({ browserType, browserOptions, createUserDataDir, asset }, testInfo) => {+it('should return background pages when recording video', async ({ browserType, createUserDataDir, asset }, testInfo) => {const userDataDir = await createUserDataDir();const extensionPath = asset('simple-extension');- const extensionOptions = { ...browserOptions,+ const extensionOptions = {headless: false,args: [`--disable-extensions-except=${extensionPath}`,@@ -99,8 +99,8 @@ it('should return background pages when recording video', async ({ browserType,await context.close();});-it('should not create pages automatically', async ({ browserType, browserOptions }) => {- const browser = await browserType.launch(browserOptions);+it('should not create pages automatically', async ({ browserType }) => {+ const browser = await browserType.launch();const browserSession = await browser.newBrowserCDPSession();const targets = [];browserSession.on('Target.targetCreated', async ({ targetInfo }) => {diff --git a/tests/chromium/oopif.spec.ts b/tests/chromium/oopif.spec.tsindex 86974d6291..4fefe2849d 100644--- a/tests/chromium/oopif.spec.ts+++ b/tests/chromium/oopif.spec.ts@@ -231,10 +231,10 @@ it('should click a button when it overlays oopif', async function({ page, browseexpect(await page.evaluate(() => window['BUTTON_CLICKED'])).toBe(true);});-it('should report google.com frame with headed', async ({ browserType, browserOptions, server }) => {+it('should report google.com frame with headed', async ({ browserType, server }) => {// @see https://github.com/GoogleChrome/puppeteer/issues/2548// https://google.com is isolated by default in Chromium embedder.- const browser = await browserType.launch({ ...browserOptions, headless: false });+ const browser = await browserType.launch({ headless: false });const page = await browser.newPage();await page.goto(server.EMPTY_PAGE);await page.route('**/*', route => {diff --git a/tests/config/browserTest.ts b/tests/config/browserTest.tsindex 2397634727..cb0800c6d7 100644--- a/tests/config/browserTest.ts+++ b/tests/config/browserTest.ts@@ -33,7 +33,6 @@ export type PlaywrightWorkerFixtures = {_browserType: BrowserType;_browserOptions: LaunchOptions;browserType: BrowserType;- browserOptions: LaunchOptions;browser: Browser;browserVersion: string;_reuseBrowserContext: ReuseBrowserContextStorage;@@ -72,7 +71,6 @@ export const playwrightFixtures: Fixtures<PlaywrightTestOptions & PlaywrightTestlaunchOptions: [ {}, { scope: 'worker' } ],browserType: [async ({ _browserType }, use) => use(_browserType), { scope: 'worker' } ],- browserOptions: [async ({ _browserOptions }, use) => use(_browserOptions), { scope: 'worker' } ],browser: [browserWorkerFixture, { scope: 'worker' } ],browserVersion: [async ({ browser }, run) => {@@ -97,13 +95,13 @@ export const playwrightFixtures: Fixtures<PlaywrightTestOptions & PlaywrightTestawait removeFolders(dirs);},- launchPersistent: async ({ createUserDataDir, browserType, browserOptions }, run) => {+ launchPersistent: async ({ createUserDataDir, browserType }, run) => {let persistentContext: BrowserContext | undefined;await run(async options => {if (persistentContext)throw new Error('can only launch one persitent context');const userDataDir = await createUserDataDir();- persistentContext = await browserType.launchPersistentContext(userDataDir, { ...browserOptions, ...options });+ persistentContext = await browserType.launchPersistentContext(userDataDir, { ...options });const page = persistentContext.pages()[0];return { context: persistentContext, page };});@@ -111,13 +109,13 @@ export const playwrightFixtures: Fixtures<PlaywrightTestOptions & PlaywrightTestawait persistentContext.close();},- startRemoteServer: async ({ childProcess, browserType, browserOptions }, run) => {+ startRemoteServer: async ({ childProcess, browserType }, run) => {let remoteServer: RemoteServer | undefined;await run(async options => {if (remoteServer)throw new Error('can only start one remote server');remoteServer = new RemoteServer();- await remoteServer._start(childProcess, browserType, browserOptions, options);+ await remoteServer._start(childProcess, browserType, options);return remoteServer;});if (remoteServer)diff --git a/tests/config/remoteServer.ts b/tests/config/remoteServer.tsindex 7773e187dd..6890151db0 100644--- a/tests/config/remoteServer.ts+++ b/tests/config/remoteServer.ts@@ -34,11 +34,12 @@ export class RemoteServer {_browser: Browser;_wsEndpoint: string;- async _start(childProcess: CommonFixtures['childProcess'], browserType: BrowserType, browserOptions: LaunchOptions, remoteServerOptions: RemoteServerOptions = {}) {+ async _start(childProcess: CommonFixtures['childProcess'], browserType: BrowserType, remoteServerOptions: RemoteServerOptions = {}) {this._output = new Map();this._outputCallback = new Map();this._browserType = browserType;+ const browserOptions = (browserType as any)._defaultLaunchOptions;// Copy options to prevent a large JSON string when launching subprocess.// Otherwise, we get `Error: spawn ENAMETOOLONG` on Windows.const launchOptions: LaunchOptions = {diff --git a/tests/defaultbrowsercontext-2.spec.ts b/tests/defaultbrowsercontext-2.spec.tsindex a33dc11b40..1b7e63c510 100644--- a/tests/defaultbrowsercontext-2.spec.ts+++ b/tests/defaultbrowsercontext-2.spec.ts@@ -88,51 +88,51 @@ it('should support extraHTTPHeaders option', async ({ server, launchPersistent }expect(request.headers['foo']).toBe('bar');});-it('should accept userDataDir', async ({ createUserDataDir, browserType, browserOptions }) => {+it('should accept userDataDir', async ({ createUserDataDir, browserType }) => {const userDataDir = await createUserDataDir();- const context = await browserType.launchPersistentContext(userDataDir, browserOptions);+ const context = await browserType.launchPersistentContext(userDataDir);expect(fs.readdirSync(userDataDir).length).toBeGreaterThan(0);await context.close();expect(fs.readdirSync(userDataDir).length).toBeGreaterThan(0);});-it('should restore state from userDataDir', async ({ browserType, browserOptions, server, createUserDataDir }) => {+it('should restore state from userDataDir', async ({ browserType, server, createUserDataDir }) => {it.slow();const userDataDir = await createUserDataDir();- const browserContext = await browserType.launchPersistentContext(userDataDir, browserOptions);+ const browserContext = await browserType.launchPersistentContext(userDataDir);const page = await browserContext.newPage();await page.goto(server.EMPTY_PAGE);await page.evaluate(() => localStorage.hey = 'hello');await browserContext.close();- const browserContext2 = await browserType.launchPersistentContext(userDataDir, browserOptions);+ const browserContext2 = await browserType.launchPersistentContext(userDataDir);const page2 = await browserContext2.newPage();await page2.goto(server.EMPTY_PAGE);expect(await page2.evaluate(() => localStorage.hey)).toBe('hello');await browserContext2.close();const userDataDir2 = await createUserDataDir();- const browserContext3 = await browserType.launchPersistentContext(userDataDir2, browserOptions);+ const browserContext3 = await browserType.launchPersistentContext(userDataDir2);const page3 = await browserContext3.newPage();await page3.goto(server.EMPTY_PAGE);expect(await page3.evaluate(() => localStorage.hey)).not.toBe('hello');await browserContext3.close();});-it('should create userDataDir if it does not exist', async ({ createUserDataDir, browserType, browserOptions }) => {+it('should create userDataDir if it does not exist', async ({ createUserDataDir, browserType }) => {const userDataDir = path.join(await createUserDataDir(), 'nonexisting');- const context = await browserType.launchPersistentContext(userDataDir, browserOptions);+ const context = await browserType.launchPersistentContext(userDataDir);await context.close();expect(fs.readdirSync(userDataDir).length).toBeGreaterThan(0);});-it('should restore cookies from userDataDir', async ({ browserType, browserOptions, server, createUserDataDir, platform, channel }) => {+it('should restore cookies from userDataDir', async ({ browserType, server, createUserDataDir, platform, channel }) => {it.fixme(platform === 'win32' && channel === 'chrome');it.slow();const userDataDir = await createUserDataDir();- const browserContext = await browserType.launchPersistentContext(userDataDir, browserOptions);+ const browserContext = await browserType.launchPersistentContext(userDataDir);const page = await browserContext.newPage();await page.goto(server.EMPTY_PAGE);const documentCookie = await page.evaluate(() => {@@ -142,14 +142,14 @@ it('should restore cookies from userDataDir', async ({ browserType, browserOptioexpect(documentCookie).toBe('doSomethingOnlyOnce=true');await browserContext.close();- const browserContext2 = await browserType.launchPersistentContext(userDataDir, browserOptions);+ const browserContext2 = await browserType.launchPersistentContext(userDataDir);const page2 = await browserContext2.newPage();await page2.goto(server.EMPTY_PAGE);expect(await page2.evaluate(() => document.cookie)).toBe('doSomethingOnlyOnce=true');await browserContext2.close();const userDataDir2 = await createUserDataDir();- const browserContext3 = await browserType.launchPersistentContext(userDataDir2, browserOptions);+ const browserContext3 = await browserType.launchPersistentContext(userDataDir2);const page3 = await browserContext3.newPage();await page3.goto(server.EMPTY_PAGE);expect(await page3.evaluate(() => document.cookie)).not.toBe('doSomethingOnlyOnce=true');@@ -162,21 +162,20 @@ it('should have default URL when launching browser', async ({ launchPersistent }expect(urls).toEqual(['about:blank']);});-it('should throw if page argument is passed', async ({ browserType, browserOptions, server, createUserDataDir, browserName }) => {+it('should throw if page argument is passed', async ({ browserType, server, createUserDataDir, browserName }) => {it.skip(browserName === 'firefox');- const options = { ...browserOptions, args: [server.EMPTY_PAGE] };+ const options = { args: [server.EMPTY_PAGE] };const error = await browserType.launchPersistentContext(await createUserDataDir(), options).catch(e => e);expect(error.message).toContain('can not specify page');});-it('should have passed URL when launching with ignoreDefaultArgs: true', async ({ browserType, browserOptions, server, createUserDataDir, toImpl, mode, browserName }) => {+it('should have passed URL when launching with ignoreDefaultArgs: true', async ({ browserType, server, createUserDataDir, toImpl, mode, browserName }) => {it.skip(mode !== 'default');const userDataDir = await createUserDataDir();- const args = toImpl(browserType)._defaultArgs(browserOptions, 'persistent', userDataDir, 0).filter(a => a !== 'about:blank');+ const args = toImpl(browserType)._defaultArgs((browserType as any)._defaultLaunchOptions, 'persistent', userDataDir, 0).filter(a => a !== 'about:blank');const options = {- ...browserOptions,args: browserName === 'firefox' ? [...args, '-new-tab', server.EMPTY_PAGE] : [...args, server.EMPTY_PAGE],ignoreDefaultArgs: true,};@@ -189,19 +188,19 @@ it('should have passed URL when launching with ignoreDefaultArgs: true', async (await browserContext.close();});-it('should handle timeout', async ({ browserType, browserOptions, createUserDataDir, mode }) => {+it('should handle timeout', async ({ browserType,createUserDataDir, mode }) => {it.skip(mode !== 'default');- const options = { ...browserOptions, timeout: 5000, __testHookBeforeCreateBrowser: () => new Promise(f => setTimeout(f, 6000)) };+ const options: any = { timeout: 5000, __testHookBeforeCreateBrowser: () => new Promise(f => setTimeout(f, 6000)) };const error = await browserType.launchPersistentContext(await createUserDataDir(), options).catch(e => e);expect(error.message).toContain(`browserType.launchPersistentContext: Timeout 5000ms exceeded.`);});-it('should handle exception', async ({ browserType, browserOptions, createUserDataDir, mode }) => {+it('should handle exception', async ({ browserType,createUserDataDir, mode }) => {it.skip(mode !== 'default');const e = new Error('Dummy');- const options = { ...browserOptions, __testHookBeforeCreateBrowser: () => { throw e; } };+ const options: any = { __testHookBeforeCreateBrowser: () => { throw e; } };const error = await browserType.launchPersistentContext(await createUserDataDir(), options).catch(e => e);expect(error.message).toContain('Dummy');});@@ -244,10 +243,10 @@ it('should respect selectors', async ({ playwright, launchPersistent }) => {expect(await page.innerHTML('defaultContextCSS=div')).toBe('hello');});-it('should connect to a browser with the default page', async ({ browserType, browserOptions, createUserDataDir, mode }) => {+it('should connect to a browser with the default page', async ({ browserType,createUserDataDir, mode }) => {it.skip(mode !== 'default');- const options = { ...browserOptions, __testHookOnConnectToBrowser: () => new Promise(f => setTimeout(f, 3000)) };+ const options: any = { __testHookOnConnectToBrowser: () => new Promise(f => setTimeout(f, 3000)) };const context = await browserType.launchPersistentContext(await createUserDataDir(), options);expect(context.pages().length).toBe(1);await context.close();diff --git a/tests/download.spec.ts b/tests/download.spec.tsindex ffc803d51e..f8e7abaa10 100644--- a/tests/download.spec.ts+++ b/tests/download.spec.ts@@ -387,8 +387,8 @@ it.describe('download event', () => {expect(fs.existsSync(path2)).toBeFalsy();});- it('should delete downloads on browser gone', async ({ server, browserType, browserOptions }) => {- const browser = await browserType.launch(browserOptions);+ it('should delete downloads on browser gone', async ({ server, browserType }) => {+ const browser = await browserType.launch();const page = await browser.newPage({ acceptDownloads: true });await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);const [ download1 ] = await Promise.all([@@ -465,7 +465,7 @@ it.describe('download event', () => {]).toContain(saveError.message);});- it('should throw if browser dies', async ({ server, browserType, browserName, browserOptions, platform }, testInfo) => {+ it('should throw if browser dies', async ({ server, browserType, browserName, platform }, testInfo) => {it.skip(browserName === 'webkit' && platform === 'linux', 'WebKit on linux does not convert to the download immediately upon receiving headers');server.setRoute('/downloadStall', (req, res) => {res.setHeader('Content-Type', 'application/octet-stream');@@ -475,7 +475,7 @@ it.describe('download event', () => {res.write(`Hello world`);});- const browser = await browserType.launch(browserOptions);+ const browser = await browserType.launch();const page = await browser.newPage({ acceptDownloads: true });await page.setContent(`<a href="${server.PREFIX}/downloadStall">click me</a>`);const [download] = await Promise.all([diff --git a/tests/downloads-path.spec.ts b/tests/downloads-path.spec.tsindex 7c31e38837..240d72c843 100644--- a/tests/downloads-path.spec.ts+++ b/tests/downloads-path.spec.ts@@ -29,8 +29,8 @@ it.describe('downloads path', () => {});});- it('should keep downloadsPath folder', async ({ browserType, browserOptions, server }, testInfo) => {- const downloadsBrowser = await browserType.launch({ ...browserOptions, downloadsPath: testInfo.outputPath('') });+ it('should keep downloadsPath folder', async ({ browserType, server }, testInfo) => {+ const downloadsBrowser = await browserType.launch({ downloadsPath: testInfo.outputPath('') });const page = await downloadsBrowser.newPage();await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);const [ download ] = await Promise.all([@@ -45,8 +45,8 @@ it.describe('downloads path', () => {expect(fs.existsSync(testInfo.outputPath(''))).toBeTruthy();});- it('should delete downloads when context closes', async ({ browserType, browserOptions, server }, testInfo) => {- const downloadsBrowser = await browserType.launch({ ...browserOptions, downloadsPath: testInfo.outputPath('') });+ it('should delete downloads when context closes', async ({ browserType, server }, testInfo) => {+ const downloadsBrowser = await browserType.launch({ downloadsPath: testInfo.outputPath('') });const page = await downloadsBrowser.newPage({ acceptDownloads: true });await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);const [ download ] = await Promise.all([@@ -60,8 +60,8 @@ it.describe('downloads path', () => {await downloadsBrowser.close();});- it('should report downloads in downloadsPath folder', async ({ browserType, browserOptions, server }, testInfo) => {- const downloadsBrowser = await browserType.launch({ ...browserOptions, downloadsPath: testInfo.outputPath('') });+ it('should report downloads in downloadsPath folder', async ({ browserType, server }, testInfo) => {+ const downloadsBrowser = await browserType.launch({ downloadsPath: testInfo.outputPath('') });const page = await downloadsBrowser.newPage({ acceptDownloads: true });await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);const [ download ] = await Promise.all([@@ -74,8 +74,8 @@ it.describe('downloads path', () => {await downloadsBrowser.close();});- it('should report downloads in downloadsPath folder with a relative path', async ({ browserType, browserOptions, server }, testInfo) => {- const downloadsBrowser = await browserType.launch({ ...browserOptions, downloadsPath: path.relative(process.cwd(), testInfo.outputPath('')) });+ it('should report downloads in downloadsPath folder with a relative path', async ({ browserType, server }, testInfo) => {+ const downloadsBrowser = await browserType.launch({ downloadsPath: path.relative(process.cwd(), testInfo.outputPath('')) });const page = await downloadsBrowser.newPage({ acceptDownloads: true });await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);const [ download ] = await Promise.all([diff --git a/tests/firefox/launcher.spec.ts b/tests/firefox/launcher.spec.tsindex 1c9317f249..b37aaeae63 100644--- a/tests/firefox/launcher.spec.ts+++ b/tests/firefox/launcher.spec.ts@@ -16,9 +16,8 @@import { playwrightTest as it, expect } from '../config/browserTest';-it('should pass firefox user preferences', async ({ browserType, browserOptions, browserName }) => {+it('should pass firefox user preferences', async ({ browserType }) => {const browser = await browserType.launch({- ...browserOptions,firefoxUserPrefs: {'network.proxy.type': 1,'network.proxy.http': '127.0.0.1',diff --git a/tests/headful.spec.ts b/tests/headful.spec.tsindex a1570f770a..16649c7b80 100644--- a/tests/headful.spec.ts+++ b/tests/headful.spec.ts@@ -16,17 +16,17 @@import { playwrightTest as it, expect } from './config/browserTest';-it('should have default url when launching browser', async ({ browserType, browserOptions, createUserDataDir }) => {- const browserContext = await browserType.launchPersistentContext(await createUserDataDir(), { ...browserOptions, headless: false });+it('should have default url when launching browser', async ({ browserType, createUserDataDir }) => {+ const browserContext = await browserType.launchPersistentContext(await createUserDataDir(), { headless: false });const urls = browserContext.pages().map(page => page.url());expect(urls).toEqual(['about:blank']);await browserContext.close();});-it('should close browser with beforeunload page', async ({ browserType, browserOptions, server, createUserDataDir }) => {+it('should close browser with beforeunload page', async ({ browserType, server, createUserDataDir }) => {it.slow();- const browserContext = await browserType.launchPersistentContext(await createUserDataDir(), { ...browserOptions, headless: false });+ const browserContext = await browserType.launchPersistentContext(await createUserDataDir(), { headless: false });const page = await browserContext.newPage();await page.goto(server.PREFIX + '/beforeunload.html');// We have to interact with a page so that 'beforeunload' handlers@@ -35,8 +35,8 @@ it('should close browser with beforeunload page', async ({ browserType, browserOawait browserContext.close();});-it('should not crash when creating second context', async ({ browserType, browserOptions }) => {- const browser = await browserType.launch({ ...browserOptions, headless: false });+it('should not crash when creating second context', async ({ browserType }) => {+ const browser = await browserType.launch({ headless: false });{const browserContext = await browser.newContext();await browserContext.newPage();@@ -50,8 +50,8 @@ it('should not crash when creating second context', async ({ browserType, browseawait browser.close();});-it('should click background tab', async ({ browserType, browserOptions, server }) => {- const browser = await browserType.launch({ ...browserOptions, headless: false });+it('should click background tab', async ({ browserType, server }) => {+ const browser = await browserType.launch({ headless: false });const page = await browser.newPage();await page.setContent(`<button>Hello</button><a target=_blank href="${server.EMPTY_PAGE}">empty.html</a>`);await page.click('a');@@ -59,16 +59,16 @@ it('should click background tab', async ({ browserType, browserOptions, server }await browser.close();});-it('should close browser after context menu was triggered', async ({ browserType, browserOptions, server }) => {- const browser = await browserType.launch({ ...browserOptions, headless: false });+it('should close browser after context menu was triggered', async ({ browserType, server }) => {+ const browser = await browserType.launch({ headless: false });const page = await browser.newPage();await page.goto(server.PREFIX + '/grid.html');await page.click('body', { button: 'right' });await browser.close();});-it('should(not) block third party cookies', async ({ browserType, browserOptions, server, browserName }) => {- const browser = await browserType.launch({ ...browserOptions, headless: false });+it('should(not) block third party cookies', async ({ browserType, server, browserName }) => {+ const browser = await browserType.launch({ headless: false });const page = await browser.newPage();await page.goto(server.EMPTY_PAGE);await page.evaluate(src => {@@ -107,9 +107,9 @@ it('should(not) block third party cookies', async ({ browserType, browserOptionsawait browser.close();});-it('should not block third party SameSite=None cookies', async ({ browserOptions, httpsServer, browserName, browserType }) => {+it('should not block third party SameSite=None cookies', async ({ httpsServer, browserName, browserType }) => {it.skip(browserName === 'webkit', 'No third party cookies in WebKit');- const browser = await browserType.launch({ ...browserOptions, headless: false });+ const browser = await browserType.launch({ headless: false });const page = await browser.newPage({ignoreHTTPSErrors: true,});@@ -143,11 +143,11 @@ it('should not block third party SameSite=None cookies', async ({ browserOptionsexpect(await cookie).toBe('a=b');});-it('should not override viewport size when passed null', async function({ browserType, browserOptions, server, browserName }) {+it('should not override viewport size when passed null', async function({ browserType, server, browserName }) {it.fixme(browserName === 'webkit');// Our WebKit embedder does not respect window features.- const browser = await browserType.launch({ ...browserOptions, headless: false });+ const browser = await browserType.launch({ headless: false });const context = await browser.newContext({ viewport: null });const page = await context.newPage();await page.goto(server.EMPTY_PAGE);@@ -164,8 +164,8 @@ it('should not override viewport size when passed null', async function({ browseawait browser.close();});-it('Page.bringToFront should work', async ({ browserType, browserOptions }) => {- const browser = await browserType.launch({ ...browserOptions, headless: false });+it('Page.bringToFront should work', async ({ browserType }) => {+ const browser = await browserType.launch({ headless: false });const page1 = await browser.newPage();await page1.setContent('Page1');const page2 = await browser.newPage();@@ -183,7 +183,7 @@ it('Page.bringToFront should work', async ({ browserType, browserOptions }) => {await browser.close();});-it.skip('should click in OOPIF', async ({ browserName, browserType, browserOptions, createUserDataDir, server }) => {+it.skip('should click in OOPIF', async ({ browserName, browserType, createUserDataDir, server }) => {it.fixme(browserName === 'chromium');server.setRoute('/empty.html', (req, res) => {res.writeHead(200, { 'Content-Type': 'text/html' });@@ -195,7 +195,7 @@ it.skip('should click in OOPIF', async ({ browserName, browserType, browserOptio<script>console.log('frame loaded')</script>`);});- const context = await browserType.launchPersistentContext(await createUserDataDir(), { ...browserOptions, headless: false });+ const context = await browserType.launchPersistentContext(await createUserDataDir(), { headless: false });const [page] = context.pages();const consoleLog: string[] = [];page.on('console', m => consoleLog.push(m.text()));@@ -204,7 +204,7 @@ it.skip('should click in OOPIF', async ({ browserName, browserType, browserOptioexpect(consoleLog).toContain('ok');});-it.skip('should click bottom row w/ infobar in OOPIF', async ({ browserType, browserOptions, createUserDataDir, server }) => {+it.skip('should click bottom row w/ infobar in OOPIF', async ({ browserType, createUserDataDir, server }) => {server.setRoute('/empty.html', (req, res) => {res.writeHead(200, { 'Content-Type': 'text/html' });res.end(`@@ -226,7 +226,7 @@ it.skip('should click bottom row w/ infobar in OOPIF', async ({ browserType, bro<button id="button" onclick="console.log('ok')">Submit</button>`);});- const browserContext = await browserType.launchPersistentContext(await createUserDataDir(), { ...browserOptions, headless: false });+ const browserContext = await browserType.launchPersistentContext(await createUserDataDir(), { headless: false });const [page] = browserContext.pages();await page.goto(server.EMPTY_PAGE);// Chrome bug! Investigate what's happening in the oopif router.diff --git a/tests/launcher.spec.ts b/tests/launcher.spec.tsindex fa367ba7b3..fea0854664 100644--- a/tests/launcher.spec.ts+++ b/tests/launcher.spec.ts@@ -26,16 +26,16 @@ it('should have a devices object', async ({ playwright }) => {expect(playwright.devices['iPhone 6'].defaultBrowserType).toBe('webkit');});-it('should kill browser process on timeout after close', async ({ browserType, browserOptions, mode }) => {+it('should kill browser process on timeout after close', async ({ browserType, mode }) => {it.skip(mode !== 'default', 'Test passes server hooks via options');- const launchOptions = { ...browserOptions };+ const launchOptions: any = {};let stalled = false;- (launchOptions as any).__testHookGracefullyClose = () => {+ launchOptions.__testHookGracefullyClose = () => {stalled = true;return new Promise(() => {});};- (launchOptions as any).__testHookBrowserCloseTimeout = 1_000;+ launchOptions.__testHookBrowserCloseTimeout = 1_000;const browser = await browserType.launch(launchOptions);await browser.close();expect(stalled).toBeTruthy();diff --git a/tests/logger.spec.ts b/tests/logger.spec.tsindex b26c69959e..2b4c7218c1 100644--- a/tests/logger.spec.ts+++ b/tests/logger.spec.ts@@ -16,9 +16,9 @@import { playwrightTest as it, expect } from './config/browserTest';-it('should log', async ({ browserType, browserOptions }) => {+it('should log', async ({ browserType }) => {const log = [];- const browser = await browserType.launch({ ...browserOptions, logger: {+ const browser = await browserType.launch({ logger: {log: (name, severity, message) => log.push({ name, severity, message }),isEnabled: (name, severity) => severity !== 'verbose'} });@@ -30,9 +30,9 @@ it('should log', async ({ browserType, browserOptions }) => {expect(log.filter(item => item.message.includes('browserType.launch succeeded')).length > 0).toBeTruthy();});-it('should log context-level', async ({ browserType, browserOptions }) => {+it('should log context-level', async ({ browserType }) => {const log = [];- const browser = await browserType.launch(browserOptions);+ const browser = await browserType.launch();const context = await browser.newContext({logger: {log: (name, severity, message) => log.push({ name, severity, message }),diff --git a/tests/port-forwarding-server.spec.ts b/tests/port-forwarding-server.spec.tsindex fac850c0d3..5b346bff20 100644--- a/tests/port-forwarding-server.spec.ts+++ b/tests/port-forwarding-server.spec.ts@@ -61,7 +61,7 @@ class OutOfProcessPlaywrightServer {}const it = contextTest.extend<{ pageFactory: (redirectPortForTest?: number) => Promise<Page> }>({- pageFactory: async ({ browserName, browserOptions }, run, testInfo) => {+ pageFactory: async ({ browserName, browserType }, run, testInfo) => {const playwrightServers: OutOfProcessPlaywrightServer[] = [];await run(async (redirectPortForTest?: number): Promise<Page> => {const server = new OutOfProcessPlaywrightServer(0, 3200 + testInfo.workerIndex);@@ -71,7 +71,7 @@ const it = contextTest.extend<{ pageFactory: (redirectPortForTest?: number) => P});const playwright = service.playwright();playwright._enablePortForwarding(redirectPortForTest);- const browser = await playwright[browserName].launch(browserOptions);+ const browser = await playwright[browserName].launch((browserType as any)._defaultLaunchOptions);return await browser.newPage();});for (const playwrightServer of playwrightServers)diff --git a/tests/proxy.spec.ts b/tests/proxy.spec.tsindex e45a52632c..ccb8690005 100644--- a/tests/proxy.spec.ts+++ b/tests/proxy.spec.ts@@ -20,21 +20,19 @@ import net from 'net';it.skip(({ mode }) => mode === 'service');-it('should throw for bad server value', async ({ browserType, browserOptions }) => {+it('should throw for bad server value', async ({ browserType }) => {const error = await browserType.launch({- ...browserOptions,// @ts-expect-error server must be a stringproxy: { server: 123 }}).catch(e => e);expect(error.message).toContain('proxy.server: expected string, got number');});-it('should use proxy', async ({ browserType, browserOptions, server }) => {+it('should use proxy', async ({ browserType, server }) => {server.setRoute('/target.html', async (req, res) => {res.end('<html><title>Served by the proxy</title></html>');});const browser = await browserType.launch({- ...browserOptions,proxy: { server: `localhost:${server.PORT}` }});const page = await browser.newPage();@@ -43,12 +41,11 @@ it('should use proxy', async ({ browserType, browserOptions, server }) => {await browser.close();});-it('should use proxy for second page', async ({ browserType, browserOptions, server }) => {+it('should use proxy for second page', async ({ browserType, server }) => {server.setRoute('/target.html', async (req, res) => {res.end('<html><title>Served by the proxy</title></html>');});const browser = await browserType.launch({- ...browserOptions,proxy: { server: `localhost:${server.PORT}` }});@@ -63,12 +60,11 @@ it('should use proxy for second page', async ({ browserType, browserOptions, serawait browser.close();});-it('should work with IP:PORT notion', async ({ browserType, browserOptions, server }) => {+it('should work with IP:PORT notion', async ({ browserType, server }) => {server.setRoute('/target.html', async (req, res) => {res.end('<html><title>Served by the proxy</title></html>');});const browser = await browserType.launch({- ...browserOptions,proxy: { server: `127.0.0.1:${server.PORT}` }});const page = await browser.newPage();@@ -77,7 +73,7 @@ it('should work with IP:PORT notion', async ({ browserType, browserOptions, servawait browser.close();});-it('should authenticate', async ({ browserType, browserOptions, server }) => {+it('should authenticate', async ({ browserType, server }) => {server.setRoute('/target.html', async (req, res) => {const auth = req.headers['proxy-authorization'];if (!auth) {@@ -90,7 +86,6 @@ it('should authenticate', async ({ browserType, browserOptions, server }) => {}});const browser = await browserType.launch({- ...browserOptions,proxy: { server: `localhost:${server.PORT}`, username: 'user', password: 'secret' }});const page = await browser.newPage();@@ -99,7 +94,7 @@ it('should authenticate', async ({ browserType, browserOptions, server }) => {await browser.close();});-it('should exclude patterns', async ({ browserType, browserOptions, server, browserName, headless }) => {+it('should exclude patterns', async ({ browserType, server, browserName, headless }) => {it.fixme(browserName === 'chromium' && !headless, 'Chromium headed crashes with CHECK(!in_frame_tree_) in RenderFrameImpl::OnDeleteFrame.');server.setRoute('/target.html', async (req, res) => {@@ -110,7 +105,6 @@ it('should exclude patterns', async ({ browserType, browserOptions, server, brow//// @see https://gist.github.com/CollinChaffin/24f6c9652efb3d6d5ef2f5502720ef00const browser = await browserType.launch({- ...browserOptions,proxy: { server: `localhost:${server.PORT}`, bypass: '1.non.existent.domain.for.the.test, 2.non.existent.domain.for.the.test, .another.test' }});@@ -141,9 +135,8 @@ it('should exclude patterns', async ({ browserType, browserOptions, server, browawait browser.close();});-it('should use socks proxy', async ({ browserType, browserOptions, socksPort }) => {+it('should use socks proxy', async ({ browserType, socksPort }) => {const browser = await browserType.launch({- ...browserOptions,proxy: { server: `socks5://localhost:${socksPort}` }});const page = await browser.newPage();@@ -152,9 +145,8 @@ it('should use socks proxy', async ({ browserType, browserOptions, socksPort })await browser.close();});-it('should use socks proxy in second page', async ({ browserType, browserOptions, socksPort }) => {+it('should use socks proxy in second page', async ({ browserType, socksPort }) => {const browser = await browserType.launch({- ...browserOptions,proxy: { server: `socks5://localhost:${socksPort}` }});@@ -169,15 +161,14 @@ it('should use socks proxy in second page', async ({ browserType, browserOptionsawait browser.close();});-it('does launch without a port', async ({ browserType, browserOptions }) => {+it('does launch without a port', async ({ browserType }) => {const browser = await browserType.launch({- ...browserOptions,proxy: { server: 'http://localhost' }});await browser.close();});-it('should use proxy with emulated user agent', async ({ browserType, browserOptions }) => {+it('should use proxy with emulated user agent', async ({ browserType }) => {it.fixme(true, 'Non-emulated user agent is used in proxy CONNECT');let requestText = '';@@ -191,7 +182,6 @@ it('should use proxy with emulated user agent', async ({ browserType, browserOptawait new Promise<void>(f => server.listen(0, f));const browser = await browserType.launch({- ...browserOptions,proxy: { server: `http://127.0.0.1:${(server.address() as any).port}` }});@@ -231,11 +221,10 @@ async function setupSocksForwardingServer(port: number, forwardPort: number){};}-it('should use SOCKS proxy for websocket requests', async ({ browserName, platform, browserType, browserOptions, server }, testInfo) => {+it('should use SOCKS proxy for websocket requests', async ({ browserName, platform, browserType, server }, testInfo) => {it.fixme(browserName === 'webkit' && platform !== 'linux');const { proxyServerAddr, closeProxyServer } = await setupSocksForwardingServer(testInfo.workerIndex + 2048 + 2, server.PORT);const browser = await browserType.launch({- ...browserOptions,proxy: {server: proxyServerAddr,}diff --git a/tests/video.spec.ts b/tests/video.spec.tsindex eb9492db46..d6f34d6b7f 100644--- a/tests/video.spec.ts+++ b/tests/video.spec.ts@@ -552,9 +552,9 @@ it.describe('screencast', () => {expect(videoPlayer.videoHeight).toBe(666);});- it('should throw on browser close', async ({ browserType, browserOptions, contextOptions }, testInfo) => {+ it('should throw on browser close', async ({ browserType, contextOptions }, testInfo) => {const size = { width: 320, height: 240 };- const browser = await browserType.launch(browserOptions);+ const browser = await browserType.launch();const context = await browser.newContext({...contextOptions,recordVideo: {@@ -573,9 +573,9 @@ it.describe('screencast', () => {expect(saveResult.message).toContain('browser has been closed');});- it('should throw if browser dies', async ({ browserType, browserOptions, contextOptions }, testInfo) => {+ it('should throw if browser dies', async ({ browserType, contextOptions }, testInfo) => {const size = { width: 320, height: 240 };- const browser = await browserType.launch(browserOptions);+ const browser = await browserType.launch();const context = await browser.newContext({...contextOptions,@@ -595,9 +595,9 @@ it.describe('screencast', () => {expect(saveResult.message).toContain('rowser has been closed');});- it('should wait for video to finish if page was closed', async ({ browserType, browserOptions, contextOptions }, testInfo) => {+ it('should wait for video to finish if page was closed', async ({ browserType, contextOptions }, testInfo) => {const size = { width: 320, height: 240 };- const browser = await browserType.launch(browserOptions);+ const browser = await browserType.launch();const videoDir = testInfo.outputPath('');const context = await browser.newContext({