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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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