Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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?.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'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (browserName === 'firefox' || channel?.startsWith('moz-firefox'))
if (browserName === '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
4 changes: 2 additions & 2 deletions tests/config/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export async function verifyViewport(page: Page, width: number, height: number)
expect(await page.evaluate('window.innerHeight')).toBe(height);
}

export function expectedSSLError(browserName: string, platform: string, channel: string): RegExp {
export function expectedSSLError(browserName: string, platform: string, channel: string | undefined): RegExp {
if (browserName === 'chromium')
return /net::(ERR_CERT_AUTHORITY_INVALID|ERR_CERT_INVALID)/;
if (browserName === 'webkit') {
Expand All @@ -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');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it.skip(headless && browserName !== 'firefox' && !channel?.startsWith('moz-firefox'), 'headless browsers, except firefox, do not request favicons');
it.skip(headless && browserName !== '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
11 changes: 0 additions & 11 deletions tests/library/channels.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ it('should scope context handles', async ({ browserType, server, expectScopeStat
{ _guid: 'browser-type', objects: [] },
{ _guid: 'browser-type', objects: [] },
{ _guid: 'browser-type', objects: [] },
{ _guid: 'browser-type', objects: [] },
{ _guid: 'browser-type', objects: [
{ _guid: 'browser', objects: [] }
] },
Expand All @@ -69,7 +68,6 @@ it('should scope context handles', async ({ browserType, server, expectScopeStat
{ _guid: 'browser-type', objects: [] },
{ _guid: 'browser-type', objects: [] },
{ _guid: 'browser-type', objects: [] },
{ _guid: 'browser-type', objects: [] },
{ _guid: 'browser-type', objects: [
{ _guid: 'browser', objects: [
{ _guid: 'browser-context', objects: [
Expand Down Expand Up @@ -106,7 +104,6 @@ it('should scope CDPSession handles', async ({ browserType, browserName, expectS
{ _guid: 'browser-type', objects: [] },
{ _guid: 'browser-type', objects: [] },
{ _guid: 'browser-type', objects: [] },
{ _guid: 'browser-type', objects: [] },
{ _guid: 'browser-type', objects: [
{ _guid: 'browser', objects: [] }
] },
Expand All @@ -125,7 +122,6 @@ it('should scope CDPSession handles', async ({ browserType, browserName, expectS
{ _guid: 'browser-type', objects: [] },
{ _guid: 'browser-type', objects: [] },
{ _guid: 'browser-type', objects: [] },
{ _guid: 'browser-type', objects: [] },
{ _guid: 'browser-type', objects: [
{ _guid: 'browser', objects: [
{ _guid: 'cdp-session', objects: [] },
Expand All @@ -152,7 +148,6 @@ it('should scope browser handles', async ({ browserType, expectScopeState }) =>
{ _guid: 'browser-type', objects: [] },
{ _guid: 'browser-type', objects: [] },
{ _guid: 'browser-type', objects: [] },
{ _guid: 'browser-type', objects: [] },
{ _guid: 'electron', objects: [] },
{ _guid: 'localUtils', objects: [] },
{ _guid: 'Playwright', objects: [] },
Expand All @@ -169,7 +164,6 @@ it('should scope browser handles', async ({ browserType, expectScopeState }) =>
{ _guid: 'browser-type', objects: [] },
{ _guid: 'browser-type', objects: [] },
{ _guid: 'browser-type', objects: [] },
{ _guid: 'browser-type', objects: [] },
{ _guid: 'browser-type', objects: [
{
_guid: 'browser', objects: [
Expand Down Expand Up @@ -206,7 +200,6 @@ it('should not generate dispatchers for subresources w/o listeners', async ({ pa
{ _guid: 'browser-type', objects: [] },
{ _guid: 'browser-type', objects: [] },
{ _guid: 'browser-type', objects: [] },
{ _guid: 'browser-type', objects: [] },
{ _guid: 'browser-type', objects: [
{
_guid: 'browser', objects: [
Expand Down Expand Up @@ -289,10 +282,6 @@ it('exposeFunction should not leak', async ({ page, expectScopeState, server })
'_guid': 'browser-type',
'objects': [],
},
{
'_guid': 'browser-type',
'objects': [],
},
{
'_guid': 'browser-type',
'objects': [
Expand Down
Loading
Loading