Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: validate Ubuntu version if launching firefox #3156

Merged
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
4 changes: 2 additions & 2 deletions src/server/browserType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import * as types from '../types';
import { TimeoutSettings } from '../timeoutSettings';
import { WebSocketServer } from './webSocketServer';
import { LoggerSink } from '../loggerSink';
import { validateDependencies } from './validateDependencies';
import { validateHostRequirements } from './validateDependencies';

type FirefoxPrefsOptions = { firefoxUserPrefs?: { [key: string]: string | number | boolean } };
type LaunchOptions = types.LaunchOptions & { logger?: LoggerSink };
Expand Down Expand Up @@ -193,7 +193,7 @@ export abstract class BrowserTypeBase implements BrowserType {

if (!executablePath) {
// We can only validate dependencies for bundled browsers.
await validateDependencies(this._browserPath, this._browserDescriptor);
await validateHostRequirements(this._browserPath, this._browserDescriptor);
}

// Note: it is important to define these variables before launchProcess, so that we don't get
Expand Down
9 changes: 8 additions & 1 deletion src/server/validateDependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ const checkExecutable = (filePath: string) => accessAsync(filePath, fs.constants
const statAsync = util.promisify(fs.stat.bind(fs));
const readdirAsync = util.promisify(fs.readdir.bind(fs));

export async function validateDependencies(browserPath: string, browser: BrowserDescriptor) {
export async function validateHostRequirements(browserPath: string, browser: BrowserDescriptor) {
const ubuntuVersion = await getUbuntuVersion();
if (browser.name === 'firefox' && ubuntuVersion === '16.04')
throw new Error(`Cannot launch firefox on Ubuntu 16.04! Minimum required Ubuntu version for Firefox browser is 18.04`);
await validateDependencies(browserPath, browser);
}

async function validateDependencies(browserPath: string, browser: BrowserDescriptor) {
// We currently only support Linux.
if (os.platform() !== 'linux')
return;
Expand Down