rename browser to bidi and public var to _experimentalBidi

This commit is contained in:
Yury Semikhatsky 2024-09-04 10:43:31 -07:00
parent 3a0df6a945
commit 127a0bc66a
7 changed files with 31 additions and 64 deletions

View file

@ -26,7 +26,7 @@ import { Selectors, SelectorsOwner } from './selectors';
export class Playwright extends ChannelOwner<channels.PlaywrightChannel> {
readonly _android: Android;
readonly _electron: Electron;
readonly _experimentalBidiFirefox: BrowserType;
readonly _experimentalBidi: BrowserType;
readonly chromium: BrowserType;
readonly firefox: BrowserType;
readonly webkit: BrowserType;
@ -46,8 +46,8 @@ export class Playwright extends ChannelOwner<channels.PlaywrightChannel> {
this.webkit._playwright = this;
this._android = Android.from(initializer.android);
this._electron = Electron.from(initializer.electron);
this._experimentalBidiFirefox = BrowserType.from(initializer.bidi);
this._experimentalBidiFirefox._playwright = this;
this._experimentalBidi = BrowserType.from(initializer.bidi);
this._experimentalBidi._playwright = this;
this.devices = this._connection.localUtils()?.devices ?? {};
this.selectors = new Selectors();
this.errors = { TimeoutError };

View file

@ -30,7 +30,7 @@ import { kBrowserCloseMessageId } from './bidiConnection';
export class BidiFirefox extends BrowserType {
constructor(parent: SdkObject) {
super(parent, 'firefox');
super(parent, 'bidi');
this._useBidi = true;
}

View file

@ -71,11 +71,6 @@ const EXECUTABLE_PATHS = {
'mac': ['ffmpeg-mac'],
'win': ['ffmpeg-win64.exe'],
},
'bidi-firefox': {
'linux': ['firefox', 'firefox'],
'mac': ['firefox', 'Nightly.app', 'Contents', 'MacOS', 'firefox'],
'win': ['firefox', 'firefox.exe'],
},
};
type DownloadPaths = Record<HostPlatform, string | undefined>;
@ -269,34 +264,9 @@ const DOWNLOAD_PATHS: Record<BrowserName | InternalTool, DownloadPaths> = {
'mac14-arm64': 'builds/android/%s/android.zip',
'win64': 'builds/android/%s/android.zip',
},
'bidi-firefox': {
'<unknown>': undefined,
'ubuntu18.04-x64': undefined,
'ubuntu20.04-x64': 'builds/firefox/%s/firefox-ubuntu-20.04.zip',
'ubuntu22.04-x64': 'builds/firefox/%s/firefox-ubuntu-22.04.zip',
'ubuntu24.04-x64': 'builds/firefox/%s/firefox-ubuntu-24.04.zip',
'ubuntu18.04-arm64': undefined,
'ubuntu20.04-arm64': 'builds/firefox/%s/firefox-ubuntu-20.04-arm64.zip',
'ubuntu22.04-arm64': 'builds/firefox/%s/firefox-ubuntu-22.04-arm64.zip',
'ubuntu24.04-arm64': 'builds/firefox/%s/firefox-ubuntu-24.04-arm64.zip',
'debian11-x64': 'builds/firefox/%s/firefox-debian-11.zip',
'debian11-arm64': 'builds/firefox/%s/firefox-debian-11-arm64.zip',
'debian12-x64': 'builds/firefox/%s/firefox-debian-12.zip',
'debian12-arm64': 'builds/firefox/%s/firefox-debian-12-arm64.zip',
'mac10.13': 'builds/firefox/%s/firefox-mac.zip',
'mac10.14': 'builds/firefox/%s/firefox-mac.zip',
'mac10.15': 'builds/firefox/%s/firefox-mac.zip',
'mac11': 'builds/firefox/%s/firefox-mac.zip',
'mac11-arm64': 'builds/firefox/%s/firefox-mac-arm64.zip',
'mac12': 'builds/firefox/%s/firefox-mac.zip',
'mac12-arm64': 'builds/firefox/%s/firefox-mac-arm64.zip',
'mac13': 'builds/firefox/%s/firefox-mac.zip',
'mac13-arm64': 'builds/firefox/%s/firefox-mac-arm64.zip',
'mac14': 'builds/firefox/%s/firefox-mac.zip',
'mac14-arm64': 'builds/firefox/%s/firefox-mac-arm64.zip',
'win64': 'builds/firefox/%s/firefox-win64.zip',
},
// TODO(bidi): implement downloads.
'bidi': {
} as DownloadPaths,
};
export const registryDirectory = (() => {
@ -382,15 +352,15 @@ function readDescriptors(browsersJSON: BrowsersJSON) {
});
}
export type BrowserName = 'chromium' | 'firefox' | 'webkit';
type InternalTool = 'ffmpeg' | 'firefox-beta' | 'chromium-tip-of-tree' | 'android' | 'bidi-firefox';
type BidiFirefoxChannel = 'bidi-firefox-stable';
export type BrowserName = 'chromium' | 'firefox' | 'webkit' | 'bidi';
type InternalTool = 'ffmpeg' | 'firefox-beta' | 'chromium-tip-of-tree' | 'android';
type BidiChannel = 'bidi-firefox-stable';
type ChromiumChannel = 'chrome' | 'chrome-beta' | 'chrome-dev' | 'chrome-canary' | 'msedge' | 'msedge-beta' | 'msedge-dev' | 'msedge-canary';
const allDownloadable = ['chromium', 'firefox', 'webkit', 'ffmpeg', 'firefox-beta', 'chromium-tip-of-tree'];
export interface Executable {
type: 'browser' | 'tool' | 'channel';
name: BrowserName | InternalTool | ChromiumChannel | BidiFirefoxChannel;
name: BrowserName | InternalTool | ChromiumChannel | BidiChannel;
browserName: BrowserName | undefined;
installType: 'download-by-default' | 'download-on-demand' | 'install-script' | 'none';
directory: string | undefined;
@ -555,7 +525,7 @@ export class Registry {
'win32': `\\Microsoft\\Edge SxS\\Application\\msedge.exe`,
}));
this._executables.push(this._createBidiFirefoxChannel('bidi-firefox-stable', {
this._executables.push(this._createBidiChannel('bidi-firefox-stable', {
'linux': '/usr/bin/firefox',
'darwin': '/Applications/Firefox.app/Contents/MacOS/firefox',
'win32': '\\Mozilla Firefox\\firefox.exe',
@ -657,21 +627,18 @@ export class Registry {
_isHermeticInstallation: true,
});
const bidiFirefox = descriptors.find(d => d.name === 'firefox')!;
const bidiFirefoxExecutable = findExecutablePath(bidiFirefox.dir, 'firefox');
this._executables.push({
type: 'browser',
name: 'bidi-firefox',
browserName: 'firefox',
directory: bidiFirefox.dir,
executablePath: () => bidiFirefoxExecutable,
executablePathOrDie: (sdkLanguage: string) => executablePathOrDie('bidi-firefox', bidiFirefoxExecutable, bidiFirefox.installByDefault, sdkLanguage),
installType: bidiFirefox.installByDefault ? 'download-by-default' : 'download-on-demand',
_validateHostRequirements: (sdkLanguage: string) => this._validateHostRequirements(sdkLanguage, 'firefox', bidiFirefox.dir, ['firefox'], [], ['firefox']),
downloadURLs: this._downloadURLs(bidiFirefox),
browserVersion: bidiFirefox.browserVersion,
_install: () => this._downloadExecutable(bidiFirefox, bidiFirefoxExecutable),
_dependencyGroup: 'firefox',
name: 'bidi',
browserName: 'bidi',
directory: undefined,
executablePath: () => undefined,
executablePathOrDie: () => '',
installType: 'none',
_validateHostRequirements: () => Promise.resolve(),
downloadURLs: [],
_install: () => Promise.resolve(),
_dependencyGroup: 'tools',
_isHermeticInstallation: true,
});
}
@ -714,7 +681,7 @@ export class Registry {
};
}
private _createBidiFirefoxChannel(name: BidiFirefoxChannel, lookAt: Record<'linux' | 'darwin' | 'win32', string>, install?: () => Promise<void>): ExecutableImpl {
private _createBidiChannel(name: BidiChannel, lookAt: Record<'linux' | 'darwin' | 'win32', string>, install?: () => Promise<void>): ExecutableImpl {
const executablePath = (sdkLanguage: string, shouldThrow: boolean) => {
const suffix = lookAt[process.platform as 'linux' | 'darwin' | 'win32'];
if (!suffix) {
@ -741,7 +708,7 @@ export class Registry {
return {
type: 'channel',
name,
browserName: 'firefox',
browserName: 'bidi',
directory: undefined,
executablePath: (sdkLanguage: string) => executablePath(sdkLanguage, false),
executablePathOrDie: (sdkLanguage: string) => executablePath(sdkLanguage, true)!,

View file

@ -15135,7 +15135,7 @@ export type AndroidKey =
export const _electron: Electron;
export const _android: Android;
export const _experimentalBidiFirefox: BrowserType;
export const _experimentalBidi: BrowserType;
// This is required to not export everything by default. See https://github.com/Microsoft/TypeScript/issues/19545#issuecomment-340490459
export {};

View file

@ -83,15 +83,15 @@ const playwrightFixtures: Fixtures<TestFixtures, WorkerFixtures> = ({
options.channel = channel;
options.tracesDir = tracing().tracesDir();
for (const browserType of [playwright.chromium, playwright.firefox, playwright.webkit, playwright._experimentalBidiFirefox])
for (const browserType of [playwright.chromium, playwright.firefox, playwright.webkit, playwright._experimentalBidi])
(browserType as any)._defaultLaunchOptions = options;
await use(options);
for (const browserType of [playwright.chromium, playwright.firefox, playwright.webkit, playwright._experimentalBidiFirefox])
for (const browserType of [playwright.chromium, playwright.firefox, playwright.webkit, playwright._experimentalBidi])
(browserType as any)._defaultLaunchOptions = undefined;
}, { scope: 'worker', auto: true, box: true }],
browser: [async ({ playwright, browserName, _browserOptions, connectOptions, _reuseContext }, use, testInfo) => {
if (!['chromium', 'firefox', 'webkit', '_experimentalBidiFirefox'].includes(browserName))
if (!['chromium', 'firefox', 'webkit', '_experimentalBidi'].includes(browserName))
throw new Error(`Unexpected browserName "${browserName}", must be one of "chromium", "firefox" or "webkit"`);
if (connectOptions) {

View file

@ -22,7 +22,7 @@ import * as path from 'path';
import type { TestModeWorkerOptions } from '../config/testModeFixtures';
const getExecutablePath = () => {
return process.env.FFPATH;
return process.env.BIDIPATH;
};
const headed = process.argv.includes('--headed');
@ -59,7 +59,7 @@ const config: Config<PlaywrightWorkerOptions & PlaywrightTestOptions & TestModeW
projects: [],
};
const browserName: any = '_experimentalBidiFirefox';
const browserName: any = '_experimentalBidi';
const executablePath = getExecutablePath();
if (executablePath && !process.env.TEST_WORKER_INDEX)
console.error(`Using executable at ${executablePath}`);

View file

@ -377,7 +377,7 @@ export type AndroidKey =
export const _electron: Electron;
export const _android: Android;
export const _experimentalBidiFirefox: BrowserType;
export const _experimentalBidi: BrowserType;
// This is required to not export everything by default. See https://github.com/Microsoft/TypeScript/issues/19545#issuecomment-340490459
export {};