(browserType as any)
This commit is contained in:
parent
8a22302e43
commit
a8795ce67f
|
|
@ -82,7 +82,7 @@ export class RemoteServer implements PlaywrightServer {
|
||||||
|
|
||||||
async _start(childProcess: CommonFixtures['childProcess'], browserType: BrowserType, channel: string, remoteServerOptions: RemoteServerOptions = {}) {
|
async _start(childProcess: CommonFixtures['childProcess'], browserType: BrowserType, channel: string, remoteServerOptions: RemoteServerOptions = {}) {
|
||||||
this._browserType = browserType;
|
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.
|
// Copy options to prevent a large JSON string when launching subprocess.
|
||||||
// Otherwise, we get `Error: spawn ENAMETOOLONG` on Windows.
|
// Otherwise, we get `Error: spawn ENAMETOOLONG` on Windows.
|
||||||
const launchOptions: Parameters<BrowserType['launchServer']>[0] = {
|
const launchOptions: Parameters<BrowserType['launchServer']>[0] = {
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ import type { BrowserContext, Page } from '@playwright/test';
|
||||||
const test = browserTest.extend<{ reusedContext: () => Promise<BrowserContext> }>({
|
const test = browserTest.extend<{ reusedContext: () => Promise<BrowserContext> }>({
|
||||||
reusedContext: async ({ browserType, browser }, use) => {
|
reusedContext: async ({ browserType, browser }, use) => {
|
||||||
await use(async () => {
|
await use(async () => {
|
||||||
const defaultContextOptions = (browserType as any)._defaultContextOptions;
|
const defaultContextOptions = (browserType as any)._playwright._defaultContextOptions;
|
||||||
const context = await (browser as any)._newContextForReuse(defaultContextOptions);
|
const context = await (browser as any)._newContextForReuse(defaultContextOptions);
|
||||||
return context;
|
return context;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ import { playwrightTest as test, expect } from '../config/browserTest';
|
||||||
test('browserType.executablePath should work', async ({ browserType, channel, mode }) => {
|
test('browserType.executablePath should work', async ({ browserType, channel, mode }) => {
|
||||||
test.skip(!!channel, 'We skip browser download when testing a channel');
|
test.skip(!!channel, 'We skip browser download when testing a channel');
|
||||||
test.skip(mode.startsWith('service'));
|
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();
|
const executablePath = browserType.executablePath();
|
||||||
expect(fs.existsSync(executablePath)).toBe(true);
|
expect(fs.existsSync(executablePath)).toBe(true);
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ const test = playwrightTest.extend<ExtraFixtures>({
|
||||||
await use(async (wsEndpoint, options = {}, redirectPortForTest): Promise<Browser> => {
|
await use(async (wsEndpoint, options = {}, redirectPortForTest): Promise<Browser> => {
|
||||||
(options as any).__testHookRedirectPortForwarding = redirectPortForTest;
|
(options as any).__testHookRedirectPortForwarding = redirectPortForTest;
|
||||||
options.headers = {
|
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,
|
...options.headers,
|
||||||
};
|
};
|
||||||
browser = await browserType.connect(wsEndpoint, options);
|
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('should ignore page.pause when headed', async ({ connect, startRemoteServer, browserType, channel }) => {
|
||||||
test.skip(channel === 'chromium-headless-shell', 'shell is never headed');
|
test.skip(channel === 'chromium-headless-shell', 'shell is never headed');
|
||||||
|
|
||||||
const headless = (browserType as any)._defaultLaunchOptions.headless;
|
const headless = (browserType as any)._playwright._defaultLaunchOptions.headless;
|
||||||
(browserType as any)._defaultLaunchOptions.headless = false;
|
(browserType as any)._playwright._defaultLaunchOptions.headless = false;
|
||||||
const remoteServer = await startRemoteServer(kind);
|
const remoteServer = await startRemoteServer(kind);
|
||||||
const browser = await connect(remoteServer.wsEndpoint());
|
const browser = await connect(remoteServer.wsEndpoint());
|
||||||
const browserContext = await browser.newContext();
|
const browserContext = await browser.newContext();
|
||||||
|
|
@ -182,7 +182,7 @@ for (const kind of ['launchServer', 'run-server'] as const) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
await page.pause({ __testHookKeepTestTimeout: true });
|
await page.pause({ __testHookKeepTestTimeout: true });
|
||||||
await browser.close();
|
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 }) => {
|
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({
|
const browser = await browserType.connect({
|
||||||
wsEndpoint: remoteServer.wsEndpoint(),
|
wsEndpoint: remoteServer.wsEndpoint(),
|
||||||
headers: {
|
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();
|
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) => {
|
test('should filter launch options', async ({ connect, startRemoteServer, server, browserType }, testInfo) => {
|
||||||
const tracesDir = testInfo.outputPath('traces');
|
const tracesDir = testInfo.outputPath('traces');
|
||||||
const oldTracesDir = (browserType as any)._defaultLaunchOptions.tracesDir;
|
const oldTracesDir = (browserType as any)._playwright._defaultLaunchOptions.tracesDir;
|
||||||
(browserType as any)._defaultLaunchOptions.tracesDir = tracesDir;
|
(browserType as any)._playwright._defaultLaunchOptions.tracesDir = tracesDir;
|
||||||
const remoteServer = await startRemoteServer(kind);
|
const remoteServer = await startRemoteServer(kind);
|
||||||
const browser = await connect(remoteServer.wsEndpoint());
|
const browser = await connect(remoteServer.wsEndpoint());
|
||||||
const page = await browser.newPage();
|
const page = await browser.newPage();
|
||||||
await page.goto(server.EMPTY_PAGE);
|
await page.goto(server.EMPTY_PAGE);
|
||||||
await browser.close();
|
await browser.close();
|
||||||
(browserType as any)._defaultLaunchOptions.tracesDir = oldTracesDir;
|
(browserType as any)._playwright._defaultLaunchOptions.tracesDir = oldTracesDir;
|
||||||
expect(fs.existsSync(tracesDir)).toBe(false);
|
expect(fs.existsSync(tracesDir)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ const test = baseTest.extend<Fixtures>({
|
||||||
await use(async () => {
|
await use(async () => {
|
||||||
const browser = await browserType.connect(wsEndpoint, {
|
const browser = await browserType.connect(wsEndpoint, {
|
||||||
headers: {
|
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',
|
'x-playwright-reuse-context': '1',
|
||||||
},
|
},
|
||||||
}) as BrowserWithReuse;
|
}) as BrowserWithReuse;
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@ it('should have passed URL when launching with ignoreDefaultArgs: true', async (
|
||||||
it.skip(mode !== 'default');
|
it.skip(mode !== 'default');
|
||||||
|
|
||||||
const userDataDir = await createUserDataDir();
|
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 = {
|
const options = {
|
||||||
args: browserName === 'firefox' ? [...args, '-new-tab', server.EMPTY_PAGE] : [...args, server.EMPTY_PAGE],
|
args: browserName === 'firefox' ? [...args, '-new-tab', server.EMPTY_PAGE] : [...args, server.EMPTY_PAGE],
|
||||||
ignoreDefaultArgs: true,
|
ignoreDefaultArgs: true,
|
||||||
|
|
|
||||||
|
|
@ -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 }) => {
|
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);
|
const response = await request.get(server.EMPTY_PAGE);
|
||||||
expect(response.ok()).toBeTruthy();
|
expect(response.ok()).toBeTruthy();
|
||||||
await request.dispose();
|
await request.dispose();
|
||||||
|
|
|
||||||
|
|
@ -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) => {
|
test('should survive browser.close with auto-created traces dir', async ({ browserType }, testInfo) => {
|
||||||
const oldTracesDir = (browserType as any)._defaultLaunchOptions.tracesDir;
|
const oldTracesDir = (browserType as any)._playwright._defaultLaunchOptions.tracesDir;
|
||||||
(browserType as any)._defaultLaunchOptions.tracesDir = undefined;
|
(browserType as any)._playwright._defaultLaunchOptions.tracesDir = undefined;
|
||||||
const browser = await browserType.launch();
|
const browser = await browserType.launch();
|
||||||
const page = await browser.newPage();
|
const page = await browser.newPage();
|
||||||
await page.context().tracing.start();
|
await page.context().tracing.start();
|
||||||
|
|
@ -394,7 +394,7 @@ test('should survive browser.close with auto-created traces dir', async ({ brows
|
||||||
]);
|
]);
|
||||||
|
|
||||||
done.value = true;
|
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 }) => {
|
test('should not stall on dialogs', async ({ page, context, server }) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue