Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/playwright-client/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16291,7 +16291,6 @@ export type AndroidKey =
export const _electron: Electron;
export const _android: Android;
export const _bidiChromium: BrowserType;
export const _bidiFirefox: BrowserType;

// This is required to not export everything by default. See https://github.com/Microsoft/TypeScript/issues/19545#issuecomment-340490459
export {};
Expand Down
4 changes: 2 additions & 2 deletions packages/playwright-core/src/browserServerImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ import type { WebSocketEventEmitter } from './utilsBundle';
import type { Browser } from './server/browser';

export class BrowserServerLauncherImpl implements BrowserServerLauncher {
private _browserName: 'chromium' | 'firefox' | 'webkit' | '_bidiFirefox' | '_bidiChromium';
private _browserName: 'chromium' | 'firefox' | 'webkit' | '_bidiChromium';

constructor(browserName: 'chromium' | 'firefox' | 'webkit' | '_bidiFirefox' | '_bidiChromium') {
constructor(browserName: 'chromium' | 'firefox' | 'webkit' | '_bidiChromium') {
this._browserName = browserName;
}

Expand Down
5 changes: 1 addition & 4 deletions packages/playwright-core/src/client/playwright.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export class Playwright extends ChannelOwner<channels.PlaywrightChannel> {
readonly _android: Android;
readonly _electron: Electron;
readonly _bidiChromium: BrowserType;
readonly _bidiFirefox: BrowserType;
readonly chromium: BrowserType;
readonly firefox: BrowserType;
readonly webkit: BrowserType;
Expand Down Expand Up @@ -60,8 +59,6 @@ export class Playwright extends ChannelOwner<channels.PlaywrightChannel> {
this._electron._playwright = this;
this._bidiChromium = BrowserType.from(initializer._bidiChromium);
this._bidiChromium._playwright = this;
this._bidiFirefox = BrowserType.from(initializer._bidiFirefox);
this._bidiFirefox._playwright = this;
this.devices = this._connection.localUtils()?.devices ?? {};
this.selectors = new Selectors(this._connection._platform);
this.errors = { TimeoutError };
Expand All @@ -72,7 +69,7 @@ export class Playwright extends ChannelOwner<channels.PlaywrightChannel> {
}

private _browserTypes(): BrowserType[] {
return [this.chromium, this.firefox, this.webkit, this._bidiChromium, this._bidiFirefox];
return [this.chromium, this.firefox, this.webkit, this._bidiChromium];
}

_preLaunchedBrowser(): Browser {
Expand Down
1 change: 0 additions & 1 deletion packages/playwright-core/src/inProcessFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export function createInProcessPlaywright(): PlaywrightAPI {
playwrightAPI.webkit._serverLauncher = new BrowserServerLauncherImpl('webkit');
playwrightAPI._android._serverLauncher = new AndroidServerLauncherImpl();
playwrightAPI._bidiChromium._serverLauncher = new BrowserServerLauncherImpl('_bidiChromium');
playwrightAPI._bidiFirefox._serverLauncher = new BrowserServerLauncherImpl('_bidiFirefox');

// Switch to async dispatch after we got Playwright object.
dispatcherConnection.onmessage = message => setImmediate(() => clientConnection.dispatch(message));
Expand Down
1 change: 0 additions & 1 deletion packages/playwright-core/src/protocol/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,6 @@ scheme.PlaywrightInitializer = tObject({
firefox: tChannel(['BrowserType']),
webkit: tChannel(['BrowserType']),
_bidiChromium: tChannel(['BrowserType']),
_bidiFirefox: tChannel(['BrowserType']),
android: tChannel(['Android']),
electron: tChannel(['Electron']),
utils: tOptional(tChannel(['LocalUtils'])),
Expand Down
2 changes: 1 addition & 1 deletion packages/playwright-core/src/server/bidi/bidiFirefox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import type { RecentLogsCollector } from '../utils/debugLogger';

export class BidiFirefox extends BrowserType {
constructor(parent: SdkObject) {
super(parent, '_bidiFirefox');
super(parent, 'firefox');
}

override executablePath(): string {
Expand Down
6 changes: 3 additions & 3 deletions packages/playwright-core/src/server/browserType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export abstract class BrowserType extends SdkObject {
}
}

async _innerLaunchWithRetries(progress: Progress, options: types.LaunchOptions, persistent: types.BrowserContextOptions | undefined, protocolLogger: types.ProtocolLogger, userDataDir?: string): Promise<Browser> {
private async _innerLaunchWithRetries(progress: Progress, options: types.LaunchOptions, persistent: types.BrowserContextOptions | undefined, protocolLogger: types.ProtocolLogger, userDataDir?: string): Promise<Browser> {
try {
return await this._innerLaunch(progress, options, persistent, protocolLogger, userDataDir);
} catch (error) {
Expand All @@ -106,7 +106,7 @@ export abstract class BrowserType extends SdkObject {
}
}

async _innerLaunch(progress: Progress, options: types.LaunchOptions, persistent: types.BrowserContextOptions | undefined, protocolLogger: types.ProtocolLogger, maybeUserDataDir?: string): Promise<Browser> {
private async _innerLaunch(progress: Progress, options: types.LaunchOptions, persistent: types.BrowserContextOptions | undefined, protocolLogger: types.ProtocolLogger, maybeUserDataDir?: string): Promise<Browser> {
options.proxy = options.proxy ? normalizeProxySettings(options.proxy) : undefined;
const browserLogsCollector = new RecentLogsCollector();
const { browserProcess, userDataDir, artifactsDir, transport } = await this._launchProcess(progress, options, !!persistent, browserLogsCollector, maybeUserDataDir);
Expand Down Expand Up @@ -317,7 +317,7 @@ export abstract class BrowserType extends SdkObject {
}
}

_rewriteStartupLog(error: Error): Error {
private _rewriteStartupLog(error: Error): Error {
if (!isProtocolError(error))
return error;
return this.doRewriteStartupLog(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,12 @@ export class PlaywrightDispatcher extends Dispatcher<Playwright, channels.Playwr
const firefox = new BrowserTypeDispatcher(scope, playwright.firefox, denyLaunch);
const webkit = new BrowserTypeDispatcher(scope, playwright.webkit, denyLaunch);
const _bidiChromium = new BrowserTypeDispatcher(scope, playwright._bidiChromium, denyLaunch);
const _bidiFirefox = new BrowserTypeDispatcher(scope, playwright._bidiFirefox, denyLaunch);
const android = new AndroidDispatcher(scope, playwright.android);
const initializer: channels.PlaywrightInitializer = {
chromium,
firefox,
webkit,
_bidiChromium,
_bidiFirefox,
android,
electron: new ElectronDispatcher(scope, playwright.electron, denyLaunch),
utils: playwright.options.isServer ? undefined : new LocalUtilsDispatcher(scope, playwright),
Expand Down
22 changes: 20 additions & 2 deletions packages/playwright-core/src/server/firefox/firefox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,34 @@ import { wrapInASCIIBox } from '../utils/ascii';
import { BrowserType, kNoXServerRunningError } from '../browserType';
import { ManualPromise } from '../../utils/isomorphic/manualPromise';

import type { BrowserOptions } from '../browser';
import type { Browser, BrowserOptions } from '../browser';
import type { SdkObject } from '../instrumentation';
import type { ProtocolError } from '../protocolError';
import type { ConnectionTransport } from '../transport';
import type * as types from '../types';
import type { RecentLogsCollector } from '../utils/debugLogger';
import type { BrowserContext } from '../browserContext';
import type * as channels from '@protocol/channels';
import type { Progress } from '@protocol/progress';

export class Firefox extends BrowserType {
constructor(parent: SdkObject) {
private _bidiFirefox: BrowserType;

constructor(parent: SdkObject, bidiFirefox: BrowserType) {
super(parent, 'firefox');
this._bidiFirefox = bidiFirefox;
}

override launch(progress: Progress, options: types.LaunchOptions, protocolLogger?: types.ProtocolLogger): Promise<Browser> {
if (options.channel && options.channel.startsWith('moz-'))
return this._bidiFirefox.launch(progress, options, protocolLogger);
return super.launch(progress, options, protocolLogger);
}

override async launchPersistentContext(progress: Progress, userDataDir: string, options: channels.BrowserTypeLaunchPersistentContextOptions & { cdpPort?: number, internalIgnoreHTTPSErrors?: boolean, socksProxyPort?: number }): Promise<BrowserContext> {
if (options.channel?.startsWith('moz-'))
return this._bidiFirefox.launchPersistentContext(progress, userDataDir, options);
return super.launchPersistentContext(progress, userDataDir, options);
}

override connectToTransport(transport: ConnectionTransport, options: BrowserOptions): Promise<FFBrowser> {
Expand Down
4 changes: 1 addition & 3 deletions packages/playwright-core/src/server/playwright.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export class Playwright extends SdkObject {
readonly firefox: BrowserType;
readonly webkit: BrowserType;
readonly _bidiChromium: BrowserType;
readonly _bidiFirefox: BrowserType;
readonly options: PlaywrightOptions;
readonly debugController: DebugController;
private _allPages = new Set<Page>();
Expand All @@ -61,8 +60,7 @@ export class Playwright extends SdkObject {
}, null);
this.chromium = new Chromium(this);
this._bidiChromium = new BidiChromium(this);
this._bidiFirefox = new BidiFirefox(this);
this.firefox = new Firefox(this);
this.firefox = new Firefox(this, new BidiFirefox(this));
this.webkit = new WebKit(this);
this.electron = new Electron(this);
this.android = new Android(this, new AdbBackend());
Expand Down
8 changes: 3 additions & 5 deletions packages/playwright-core/src/server/registry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,6 @@ const DOWNLOAD_PATHS: Record<BrowserName | InternalTool, DownloadPaths> = {
'win64': 'builds/android/%s/android.zip',
},
// TODO(bidi): implement downloads.
'_bidiFirefox': {
} as DownloadPaths,
'_bidiChromium': {
} as DownloadPaths,
};
Expand Down Expand Up @@ -502,7 +500,7 @@ function readDescriptors(browsersJSON: BrowsersJSON): BrowsersJSONDescriptor[] {
});
}

export type BrowserName = 'chromium' | 'firefox' | 'webkit' | '_bidiFirefox' | '_bidiChromium';
export type BrowserName = 'chromium' | 'firefox' | 'webkit' | '_bidiChromium';
type InternalTool = 'ffmpeg' | 'winldd' | 'firefox-beta' | 'chromium-tip-of-tree' | 'chromium-headless-shell' | 'chromium-tip-of-tree-headless-shell' | 'android';
type BidiChannel = 'moz-firefox' | 'moz-firefox-beta' | 'moz-firefox-nightly' | 'bidi-chrome-canary' | 'bidi-chrome-stable' | 'bidi-chromium';
type ChromiumChannel = 'chrome' | 'chrome-beta' | 'chrome-dev' | 'chrome-canary' | 'msedge' | 'msedge-beta' | 'msedge-dev' | 'msedge-canary';
Expand Down Expand Up @@ -958,13 +956,13 @@ export class Registry {
return executablePath;
}
if (shouldThrow)
throw new Error(`Cannot find Firefox installation for channel '${name}' at the standard system paths.`);
throw new Error(`Cannot find Firefox installation for channel '${name}' at the standard system paths. ${`Tried paths:\n ${prefixes.map(p => path.join(p, suffix)).join('\n ')}`}`);
return undefined;
};
return {
type: 'channel',
name,
browserName: '_bidiFirefox',
browserName: 'firefox',
directory: undefined,
executablePath: (sdkLanguage: string) => executablePath(sdkLanguage, false),
executablePathOrDie: (sdkLanguage: string) => executablePath(sdkLanguage, true)!,
Expand Down
1 change: 0 additions & 1 deletion packages/playwright-core/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16291,7 +16291,6 @@ export type AndroidKey =
export const _electron: Electron;
export const _android: Android;
export const _bidiChromium: BrowserType;
export const _bidiFirefox: BrowserType;

// This is required to not export everything by default. See https://github.com/Microsoft/TypeScript/issues/19545#issuecomment-340490459
export {};
Expand Down
4 changes: 2 additions & 2 deletions packages/playwright/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ const playwrightFixtures: Fixtures<TestFixtures, WorkerFixtures> = ({
playwright._defaultLaunchOptions = undefined;
}, { scope: 'worker', auto: true, box: true }],

browser: [async ({ playwright, browserName, _browserOptions, connectOptions }, use, testInfo) => {
if (!['chromium', 'firefox', 'webkit', '_bidiChromium', '_bidiFirefox'].includes(browserName))
browser: [async ({ playwright, browserName, _browserOptions, connectOptions }, use) => {
if (!['chromium', 'firefox', 'webkit', '_bidiChromium'].includes(browserName))
throw new Error(`Unexpected browserName "${browserName}", must be one of "chromium", "firefox" or "webkit"`);

if (connectOptions) {
Expand Down
1 change: 0 additions & 1 deletion packages/protocol/src/channels.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,6 @@ export type PlaywrightInitializer = {
firefox: BrowserTypeChannel,
webkit: BrowserTypeChannel,
_bidiChromium: BrowserTypeChannel,
_bidiFirefox: BrowserTypeChannel,
android: AndroidChannel,
electron: ElectronChannel,
utils?: LocalUtilsChannel,
Expand Down
1 change: 0 additions & 1 deletion packages/protocol/src/protocol.yml
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,6 @@ Playwright:
firefox: BrowserType
webkit: BrowserType
_bidiChromium: BrowserType
_bidiFirefox: BrowserType
android: Android
electron: Electron
utils: LocalUtils?
Expand Down
6 changes: 3 additions & 3 deletions tests/bidi/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,18 @@ const config: Config<PlaywrightWorkerOptions & PlaywrightTestOptions & TestModeW
projects: [],
};

type BrowserName = '_bidiChromium' | '_bidiFirefox';
type BrowserName = '_bidiChromium' | 'firefox';

const getExecutablePath = (browserName: BrowserName) => {
if (browserName === '_bidiChromium')
return process.env.BIDI_CRPATH;
if (browserName === '_bidiFirefox')
if (browserName === 'firefox')
return process.env.BIDI_FFPATH;
};

const browserToChannels = {
'_bidiChromium': ['bidi-chromium', 'bidi-chrome-canary', 'bidi-chrome-stable'],
'_bidiFirefox': ['moz-firefox', 'moz-firefox-beta', 'moz-firefox-nightly'],
'firefox': ['moz-firefox', 'moz-firefox-beta', 'moz-firefox-nightly'],
};

for (const [key, channels] of Object.entries(browserToChannels)) {
Expand Down
6 changes: 3 additions & 3 deletions tests/config/browserTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ const test = baseTest.extend<BrowserTestTestFixtures, BrowserTestWorkerFixtures>
await run(playwright[browserName]);
}, { scope: 'worker' }],

allowsThirdParty: [async ({ browserName }, run) => {
if (browserName === 'firefox' || browserName as any === '_bidiFirefox')
allowsThirdParty: [async ({ browserName, channel }, run) => {
if (browserName === 'firefox' || channel.startsWith('moz-firefox'))
await run(true);
else
await run(false);
}, { scope: 'worker' }],

defaultSameSiteCookieValue: [async ({ browserName, platform, channel }, run) => {
if (browserName === 'chromium' || browserName as any === '_bidiChromium' || browserName as any === '_bidiFirefox')
if (browserName === 'chromium' || browserName as any === '_bidiChromium' || channel.startsWith('moz-firefox'))
await run('Lax');
else if (browserName === 'webkit' && (platform === 'linux' || channel === 'webkit-wsl'))
await run('Lax');
Expand Down
2 changes: 1 addition & 1 deletion tests/config/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function expectedSSLError(browserName: string, platform: string, channel:
else
return /Unacceptable TLS certificate|Operation was cancelled/;
}
if (browserName === '_bidiFirefox')
if (channel.startsWith('moz-firefox'))
return /MOZILLA_PKIX_ERROR_SELF_SIGNED_CERT/;
return /SSL_ERROR_UNKNOWN/;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/library/browsercontext-network-event.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ it('should fire events in proper order', async ({ context, server }) => {
]);
});

it('should not fire events for favicon or favicon redirects', async ({ context, page, server, browserName, headless }) => {
it.skip(headless && browserName !== 'firefox' && browserName as any !== '_bidiFirefox', 'headless browsers, except firefox, do not request favicons');
it('should not fire events for favicon or favicon redirects', async ({ context, page, server, browserName, headless, channel }) => {
it.skip(headless && browserName !== 'firefox' && !channel.startsWith('moz-firefox'), 'headless browsers, except firefox, do not request favicons');
it.skip(!headless && browserName === 'webkit', 'headed webkit does not have a favicon feature');
const favicon = `/no-cache/favicon.ico`;
const hashedFaviconUrl = `/favicon-hashed.ico`;
Expand Down
6 changes: 3 additions & 3 deletions tests/library/browsercontext-timezone-id.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ it('should work @smoke', async ({ browser, browserName }) => {
}
});

it('should throw for invalid timezone IDs when creating pages', async ({ browser, browserName }) => {
it('should throw for invalid timezone IDs when creating pages', async ({ browser, browserName, channel }) => {
for (const timezoneId of ['Foo/Bar', 'Baz/Qux']) {
if (browserName as any === '_bidiChromium' || browserName as any === '_bidiFirefox') {
if (browserName as any === '_bidiChromium' || channel.startsWith('moz-firefox')) {
const error = await browser.newContext({ timezoneId }).catch(e => e);
if (browserName as any === '_bidiChromium')
expect(error.message).toContain(`Invalid timezone "${timezoneId}"`);
else if (browserName as any === '_bidiFirefox')
else if (channel.startsWith('moz-firefox'))
expect(error.message).toContain(`Expected "timezone" to be a valid timezone ID (e.g., "Europe/Berlin") or a valid timezone offset (e.g., "+01:00"), got ${timezoneId}`);
} else {
let error = null;
Expand Down
4 changes: 2 additions & 2 deletions tests/library/favicon.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

import { contextTest as it } from '../config/browserTest';

it('should load svg favicon with prefer-color-scheme', async ({ page, server, browserName, headless, asset }) => {
it.skip(headless && browserName !== 'firefox' && browserName as any !== '_bidiFirefox', 'headless browsers, except firefox, do not request favicons');
it('should load svg favicon with prefer-color-scheme', async ({ page, server, browserName, headless, asset, channel }) => {
it.skip(headless && browserName !== 'firefox' && !channel.startsWith('moz-firefox'), 'headless browsers, except firefox, do not request favicons');
it.skip(!headless && browserName === 'webkit', 'headed webkit does not have a favicon feature');

// Browsers aggressively cache favicons, so force bust with the
Expand Down
4 changes: 2 additions & 2 deletions tests/library/har.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -698,8 +698,8 @@ it('should contain http2 for http2 requests', async ({ contextFactory }, testInf
server.close();
});

it('should filter favicon and favicon redirects', async ({ server, browserName, headless, asset, contextFactory }, testInfo) => {
it.skip(headless && browserName !== 'firefox' && browserName as any !== '_bidiFirefox', 'headless browsers, except firefox, do not request favicons');
it('should filter favicon and favicon redirects', async ({ server, browserName, headless, asset, contextFactory, channel }, testInfo) => {
it.skip(headless && browserName !== 'firefox' && !channel.startsWith('moz-firefox'), 'headless browsers, except firefox, do not request favicons');
it.skip(!headless && browserName === 'webkit', 'headed webkit does not have a favicon feature');

const { page, getLog } = await pageWithHar(contextFactory, testInfo);
Expand Down
4 changes: 2 additions & 2 deletions tests/library/page-close.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ test('should not throw UnhandledPromiseRejection when page closes', async ({ pag
]).catch(e => {});
});

test('interrupt request.response() and request.allHeaders() on page.close', async ({ page, server, browserName }) => {
test('interrupt request.response() and request.allHeaders() on page.close', async ({ page, server, browserName, channel }) => {
test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/27227' });
server.setRoute('/one-style.css', (req, res) => {
res.setHeader('Content-Type', 'text/css');
Expand All @@ -153,7 +153,7 @@ test('interrupt request.response() and request.allHeaders() on page.close', asyn
await page.close();
expect((await respPromise).message).toContain(kTargetClosedErrorMessage);
// All headers are the same as "provisional" headers in Firefox.
if (browserName === 'firefox' || browserName as any === '_bidiFirefox')
if (browserName === 'firefox' || channel.startsWith('moz-firefox'))
expect((await headersPromise)['user-agent']).toBeTruthy();
else
expect((await headersPromise).message).toContain(kTargetClosedErrorMessage);
Expand Down
4 changes: 2 additions & 2 deletions tests/page/page-basic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ it('page.frame should respect url', async function({ page, server }) {
expect(page.frame({ url: /empty/ }).url()).toBe(server.EMPTY_PAGE);
});

it('should have sane user agent', async ({ page, browserName, isElectron, isAndroid }) => {
it('should have sane user agent', async ({ page, browserName, isElectron, isAndroid, channel }) => {
it.skip(isAndroid);
it.skip(isElectron);

Expand All @@ -125,7 +125,7 @@ it('should have sane user agent', async ({ page, browserName, isElectron, isAndr
// Second part in parenthesis is platform - ignore it.

// Third part for Firefox is the last one and encodes engine and browser versions.
if (browserName === 'firefox' || browserName as any === '_bidiFirefox') {
if (browserName === 'firefox' || channel.startsWith('moz-firefox')) {
const [engine, browser] = part3.split(' ');
expect(engine.startsWith('Gecko')).toBe(true);
expect(browser.startsWith('Firefox')).toBe(true);
Expand Down
Loading
Loading