From a8795ce67f2c86b102be2f21450d76225b3ed803 Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Thu, 6 Feb 2025 10:49:36 +0100 Subject: [PATCH] (browserType as any) --- tests/config/remoteServer.ts | 2 +- tests/library/browsercontext-reuse.spec.ts | 2 +- tests/library/browsertype-basic.spec.ts | 2 +- tests/library/browsertype-connect.spec.ts | 16 ++++++++-------- tests/library/debug-controller.spec.ts | 2 +- tests/library/defaultbrowsercontext-2.spec.ts | 2 +- tests/library/global-fetch.spec.ts | 2 +- tests/library/tracing.spec.ts | 6 +++--- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/config/remoteServer.ts b/tests/config/remoteServer.ts index 94c476ed80..ba6df56cb8 100644 --- a/tests/config/remoteServer.ts +++ b/tests/config/remoteServer.ts @@ -82,7 +82,7 @@ export class RemoteServer implements PlaywrightServer { async _start(childProcess: CommonFixtures['childProcess'], browserType: BrowserType, channel: string, remoteServerOptions: RemoteServerOptions = {}) { this._browserType = browserType; - const browserOptions = (browserType as any)._defaultLaunchOptions; + const browserOptions = (browserType as any).plawright._defaultLaunchOptions; // Copy options to prevent a large JSON string when launching subprocess. // Otherwise, we get `Error: spawn ENAMETOOLONG` on Windows. const launchOptions: Parameters[0] = { diff --git a/tests/library/browsercontext-reuse.spec.ts b/tests/library/browsercontext-reuse.spec.ts index 2d65d472b3..801c92c753 100644 --- a/tests/library/browsercontext-reuse.spec.ts +++ b/tests/library/browsercontext-reuse.spec.ts @@ -20,7 +20,7 @@ import type { BrowserContext, Page } from '@playwright/test'; const test = browserTest.extend<{ reusedContext: () => Promise }>({ reusedContext: async ({ browserType, browser }, use) => { await use(async () => { - const defaultContextOptions = (browserType as any)._defaultContextOptions; + const defaultContextOptions = (browserType as any)._playwright._defaultContextOptions; const context = await (browser as any)._newContextForReuse(defaultContextOptions); return context; }); diff --git a/tests/library/browsertype-basic.spec.ts b/tests/library/browsertype-basic.spec.ts index 83be2cb87d..b0bc16f328 100644 --- a/tests/library/browsertype-basic.spec.ts +++ b/tests/library/browsertype-basic.spec.ts @@ -21,7 +21,7 @@ import { playwrightTest as test, expect } from '../config/browserTest'; test('browserType.executablePath should work', async ({ browserType, channel, mode }) => { test.skip(!!channel, 'We skip browser download when testing a channel'); test.skip(mode.startsWith('service')); - test.skip(!!(browserType as any)._defaultLaunchOptions.executablePath, 'Skip with custom executable path'); + test.skip(!!(browserType as any)._playwright._defaultLaunchOptions.executablePath, 'Skip with custom executable path'); const executablePath = browserType.executablePath(); expect(fs.existsSync(executablePath)).toBe(true); diff --git a/tests/library/browsertype-connect.spec.ts b/tests/library/browsertype-connect.spec.ts index 9c81581de5..8a136e7418 100644 --- a/tests/library/browsertype-connect.spec.ts +++ b/tests/library/browsertype-connect.spec.ts @@ -40,7 +40,7 @@ const test = playwrightTest.extend({ await use(async (wsEndpoint, options = {}, redirectPortForTest): Promise => { (options as any).__testHookRedirectPortForwarding = redirectPortForTest; options.headers = { - 'x-playwright-launch-options': JSON.stringify((browserType as any)._defaultLaunchOptions || {}), + 'x-playwright-launch-options': JSON.stringify((browserType as any)._playwright._defaultLaunchOptions || {}), ...options.headers, }; browser = await browserType.connect(wsEndpoint, options); @@ -173,8 +173,8 @@ for (const kind of ['launchServer', 'run-server'] as const) { test('should ignore page.pause when headed', async ({ connect, startRemoteServer, browserType, channel }) => { test.skip(channel === 'chromium-headless-shell', 'shell is never headed'); - const headless = (browserType as any)._defaultLaunchOptions.headless; - (browserType as any)._defaultLaunchOptions.headless = false; + const headless = (browserType as any)._playwright._defaultLaunchOptions.headless; + (browserType as any)._playwright._defaultLaunchOptions.headless = false; const remoteServer = await startRemoteServer(kind); const browser = await connect(remoteServer.wsEndpoint()); const browserContext = await browser.newContext(); @@ -182,7 +182,7 @@ for (const kind of ['launchServer', 'run-server'] as const) { // @ts-ignore await page.pause({ __testHookKeepTestTimeout: true }); await browser.close(); - (browserType as any)._defaultLaunchOptions.headless = headless; + (browserType as any)._playwright._defaultLaunchOptions.headless = headless; }); test('should be able to visit ipv6 through localhost', async ({ connect, startRemoteServer, ipV6ServerPort }) => { @@ -599,7 +599,7 @@ for (const kind of ['launchServer', 'run-server'] as const) { const browser = await browserType.connect({ wsEndpoint: remoteServer.wsEndpoint(), headers: { - 'x-playwright-launch-options': JSON.stringify((browserType as any)._defaultLaunchOptions || {}), + 'x-playwright-launch-options': JSON.stringify((browserType as any)._playwright._defaultLaunchOptions || {}), }, }); const page = await browser.newPage(); @@ -630,14 +630,14 @@ for (const kind of ['launchServer', 'run-server'] as const) { test('should filter launch options', async ({ connect, startRemoteServer, server, browserType }, testInfo) => { const tracesDir = testInfo.outputPath('traces'); - const oldTracesDir = (browserType as any)._defaultLaunchOptions.tracesDir; - (browserType as any)._defaultLaunchOptions.tracesDir = tracesDir; + const oldTracesDir = (browserType as any)._playwright._defaultLaunchOptions.tracesDir; + (browserType as any)._playwright._defaultLaunchOptions.tracesDir = tracesDir; const remoteServer = await startRemoteServer(kind); const browser = await connect(remoteServer.wsEndpoint()); const page = await browser.newPage(); await page.goto(server.EMPTY_PAGE); await browser.close(); - (browserType as any)._defaultLaunchOptions.tracesDir = oldTracesDir; + (browserType as any)._playwright._defaultLaunchOptions.tracesDir = oldTracesDir; expect(fs.existsSync(tracesDir)).toBe(false); }); diff --git a/tests/library/debug-controller.spec.ts b/tests/library/debug-controller.spec.ts index b71cae12a5..b8163296f7 100644 --- a/tests/library/debug-controller.spec.ts +++ b/tests/library/debug-controller.spec.ts @@ -51,7 +51,7 @@ const test = baseTest.extend({ await use(async () => { const browser = await browserType.connect(wsEndpoint, { headers: { - 'x-playwright-launch-options': JSON.stringify((browserType as any)._defaultLaunchOptions), + 'x-playwright-launch-options': JSON.stringify((browserType as any)._playwright._defaultLaunchOptions), 'x-playwright-reuse-context': '1', }, }) as BrowserWithReuse; diff --git a/tests/library/defaultbrowsercontext-2.spec.ts b/tests/library/defaultbrowsercontext-2.spec.ts index af244f6e78..e16dc6b0ba 100644 --- a/tests/library/defaultbrowsercontext-2.spec.ts +++ b/tests/library/defaultbrowsercontext-2.spec.ts @@ -150,7 +150,7 @@ it('should have passed URL when launching with ignoreDefaultArgs: true', async ( it.skip(mode !== 'default'); const userDataDir = await createUserDataDir(); - const args = toImpl(browserType).defaultArgs((browserType as any)._defaultLaunchOptions, 'persistent', userDataDir, 0).filter(a => a !== 'about:blank'); + const args = toImpl(browserType).defaultArgs((browserType as any)._playwright._defaultLaunchOptions, 'persistent', userDataDir, 0).filter(a => a !== 'about:blank'); const options = { args: browserName === 'firefox' ? [...args, '-new-tab', server.EMPTY_PAGE] : [...args, server.EMPTY_PAGE], ignoreDefaultArgs: true, diff --git a/tests/library/global-fetch.spec.ts b/tests/library/global-fetch.spec.ts index 52d48c765c..2e146874c1 100644 --- a/tests/library/global-fetch.spec.ts +++ b/tests/library/global-fetch.spec.ts @@ -255,7 +255,7 @@ it('should set playwright as user-agent', async ({ playwright, server, isWindows }); it('should be able to construct with context options', async ({ playwright, browserType, server }) => { - const request = await playwright.request.newContext((browserType as any)._defaultContextOptions); + const request = await playwright.request.newContext((browserType as any)._playwright._defaultContextOptions); const response = await request.get(server.EMPTY_PAGE); expect(response.ok()).toBeTruthy(); await request.dispose(); diff --git a/tests/library/tracing.spec.ts b/tests/library/tracing.spec.ts index dfd4fc168d..2c2244edf6 100644 --- a/tests/library/tracing.spec.ts +++ b/tests/library/tracing.spec.ts @@ -368,8 +368,8 @@ test('should not crash when browser closes mid-trace', async ({ browserType, ser }); test('should survive browser.close with auto-created traces dir', async ({ browserType }, testInfo) => { - const oldTracesDir = (browserType as any)._defaultLaunchOptions.tracesDir; - (browserType as any)._defaultLaunchOptions.tracesDir = undefined; + const oldTracesDir = (browserType as any)._playwright._defaultLaunchOptions.tracesDir; + (browserType as any)._playwright._defaultLaunchOptions.tracesDir = undefined; const browser = await browserType.launch(); const page = await browser.newPage(); await page.context().tracing.start(); @@ -394,7 +394,7 @@ test('should survive browser.close with auto-created traces dir', async ({ brows ]); done.value = true; - (browserType as any)._defaultLaunchOptions.tracesDir = oldTracesDir; + (browserType as any)._playwright._defaultLaunchOptions.tracesDir = oldTracesDir; }); test('should not stall on dialogs', async ({ page, context, server }) => {