mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
feat: allow downloading Firefox channels other than nightly (#12051)
Co-authored-by: Nikolay Vitkov <nvitkov@chromium.org>
This commit is contained in:
parent
ef7a9eac16
commit
e4cc2f9ee9
@ -222,7 +222,31 @@ export class CLI {
|
|||||||
);
|
);
|
||||||
yargs.example(
|
yargs.example(
|
||||||
'$0 install firefox',
|
'$0 install firefox',
|
||||||
'Install the latest available build of the Firefox browser.'
|
'Install the latest nightly available build of the Firefox browser.'
|
||||||
|
);
|
||||||
|
yargs.example(
|
||||||
|
'$0 install firefox@stable',
|
||||||
|
'Install the latest stable build of the Firefox browser.'
|
||||||
|
);
|
||||||
|
yargs.example(
|
||||||
|
'$0 install firefox@beta',
|
||||||
|
'Install the latest beta build of the Firefox browser.'
|
||||||
|
);
|
||||||
|
yargs.example(
|
||||||
|
'$0 install firefox@devedition',
|
||||||
|
'Install the latest devedition build of the Firefox browser.'
|
||||||
|
);
|
||||||
|
yargs.example(
|
||||||
|
'$0 install firefox@esr',
|
||||||
|
'Install the latest ESR build of the Firefox browser.'
|
||||||
|
);
|
||||||
|
yargs.example(
|
||||||
|
'$0 install firefox@nightly',
|
||||||
|
'Install the latest nightly build of the Firefox browser.'
|
||||||
|
);
|
||||||
|
yargs.example(
|
||||||
|
'$0 install firefox@stable_111.0.1',
|
||||||
|
'Install a specific version of the Firefox browser.'
|
||||||
);
|
);
|
||||||
yargs.example(
|
yargs.example(
|
||||||
'$0 install firefox --platform mac',
|
'$0 install firefox --platform mac',
|
||||||
@ -395,7 +419,7 @@ export function makeProgressCallback(
|
|||||||
return (downloadedBytes: number, totalBytes: number) => {
|
return (downloadedBytes: number, totalBytes: number) => {
|
||||||
if (!progressBar) {
|
if (!progressBar) {
|
||||||
progressBar = new ProgressBar(
|
progressBar = new ProgressBar(
|
||||||
`Downloading ${browser} r${buildId} - ${toMegabytes(
|
`Downloading ${browser} ${buildId} - ${toMegabytes(
|
||||||
totalBytes
|
totalBytes
|
||||||
)} [:bar] :percent :etas `,
|
)} [:bar] :percent :etas `,
|
||||||
{
|
{
|
||||||
|
@ -54,28 +54,36 @@ export const versionComparators = {
|
|||||||
export {Browser, BrowserPlatform, ChromeReleaseChannel};
|
export {Browser, BrowserPlatform, ChromeReleaseChannel};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @internal
|
||||||
*/
|
*/
|
||||||
export async function resolveBuildId(
|
async function resolveBuildIdForBrowserTag(
|
||||||
browser: Browser,
|
browser: Browser,
|
||||||
platform: BrowserPlatform,
|
platform: BrowserPlatform,
|
||||||
tag: string
|
tag: BrowserTag
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
switch (browser) {
|
switch (browser) {
|
||||||
case Browser.FIREFOX:
|
case Browser.FIREFOX:
|
||||||
switch (tag as BrowserTag) {
|
switch (tag) {
|
||||||
case BrowserTag.LATEST:
|
case BrowserTag.LATEST:
|
||||||
return await firefox.resolveBuildId('FIREFOX_NIGHTLY');
|
return await firefox.resolveBuildId(firefox.FirefoxChannel.NIGHTLY);
|
||||||
case BrowserTag.BETA:
|
case BrowserTag.BETA:
|
||||||
|
return await firefox.resolveBuildId(firefox.FirefoxChannel.BETA);
|
||||||
|
case BrowserTag.NIGHTLY:
|
||||||
|
return await firefox.resolveBuildId(firefox.FirefoxChannel.NIGHTLY);
|
||||||
|
case BrowserTag.DEVEDITION:
|
||||||
|
return await firefox.resolveBuildId(
|
||||||
|
firefox.FirefoxChannel.DEVEDITION
|
||||||
|
);
|
||||||
|
case BrowserTag.STABLE:
|
||||||
|
return await firefox.resolveBuildId(firefox.FirefoxChannel.STABLE);
|
||||||
|
case BrowserTag.ESR:
|
||||||
|
return await firefox.resolveBuildId(firefox.FirefoxChannel.ESR);
|
||||||
case BrowserTag.CANARY:
|
case BrowserTag.CANARY:
|
||||||
case BrowserTag.DEV:
|
case BrowserTag.DEV:
|
||||||
case BrowserTag.STABLE:
|
throw new Error(`${tag.toUpperCase()} is not available for Firefox`);
|
||||||
throw new Error(
|
|
||||||
`${tag} is not supported for ${browser}. Use 'latest' instead.`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
case Browser.CHROME: {
|
case Browser.CHROME: {
|
||||||
switch (tag as BrowserTag) {
|
switch (tag) {
|
||||||
case BrowserTag.LATEST:
|
case BrowserTag.LATEST:
|
||||||
return await chrome.resolveBuildId(ChromeReleaseChannel.CANARY);
|
return await chrome.resolveBuildId(ChromeReleaseChannel.CANARY);
|
||||||
case BrowserTag.BETA:
|
case BrowserTag.BETA:
|
||||||
@ -86,14 +94,12 @@ export async function resolveBuildId(
|
|||||||
return await chrome.resolveBuildId(ChromeReleaseChannel.DEV);
|
return await chrome.resolveBuildId(ChromeReleaseChannel.DEV);
|
||||||
case BrowserTag.STABLE:
|
case BrowserTag.STABLE:
|
||||||
return await chrome.resolveBuildId(ChromeReleaseChannel.STABLE);
|
return await chrome.resolveBuildId(ChromeReleaseChannel.STABLE);
|
||||||
default:
|
case BrowserTag.NIGHTLY:
|
||||||
const result = await chrome.resolveBuildId(tag);
|
case BrowserTag.DEVEDITION:
|
||||||
if (result) {
|
case BrowserTag.ESR:
|
||||||
return result;
|
throw new Error(`${tag.toUpperCase()} is not available for Chrome`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
case Browser.CHROMEDRIVER: {
|
case Browser.CHROMEDRIVER: {
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case BrowserTag.LATEST:
|
case BrowserTag.LATEST:
|
||||||
@ -105,14 +111,14 @@ export async function resolveBuildId(
|
|||||||
return await chromedriver.resolveBuildId(ChromeReleaseChannel.DEV);
|
return await chromedriver.resolveBuildId(ChromeReleaseChannel.DEV);
|
||||||
case BrowserTag.STABLE:
|
case BrowserTag.STABLE:
|
||||||
return await chromedriver.resolveBuildId(ChromeReleaseChannel.STABLE);
|
return await chromedriver.resolveBuildId(ChromeReleaseChannel.STABLE);
|
||||||
default:
|
case BrowserTag.NIGHTLY:
|
||||||
const result = await chromedriver.resolveBuildId(tag);
|
case BrowserTag.DEVEDITION:
|
||||||
if (result) {
|
case BrowserTag.ESR:
|
||||||
return result;
|
throw new Error(
|
||||||
|
`${tag.toUpperCase()} is not available for ChromeDriver`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
case Browser.CHROMEHEADLESSSHELL: {
|
case Browser.CHROMEHEADLESSSHELL: {
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case BrowserTag.LATEST:
|
case BrowserTag.LATEST:
|
||||||
@ -132,29 +138,68 @@ export async function resolveBuildId(
|
|||||||
return await chromeHeadlessShell.resolveBuildId(
|
return await chromeHeadlessShell.resolveBuildId(
|
||||||
ChromeReleaseChannel.STABLE
|
ChromeReleaseChannel.STABLE
|
||||||
);
|
);
|
||||||
default:
|
case BrowserTag.NIGHTLY:
|
||||||
const result = await chromeHeadlessShell.resolveBuildId(tag);
|
case BrowserTag.DEVEDITION:
|
||||||
if (result) {
|
case BrowserTag.ESR:
|
||||||
return result;
|
throw new Error(`${tag} is not available for chrome-headless-shell`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
case Browser.CHROMIUM:
|
case Browser.CHROMIUM:
|
||||||
switch (tag as BrowserTag) {
|
switch (tag) {
|
||||||
case BrowserTag.LATEST:
|
case BrowserTag.LATEST:
|
||||||
return await chromium.resolveBuildId(platform);
|
return await chromium.resolveBuildId(platform);
|
||||||
case BrowserTag.BETA:
|
case BrowserTag.NIGHTLY:
|
||||||
case BrowserTag.CANARY:
|
case BrowserTag.CANARY:
|
||||||
case BrowserTag.DEV:
|
case BrowserTag.DEV:
|
||||||
|
case BrowserTag.DEVEDITION:
|
||||||
|
case BrowserTag.BETA:
|
||||||
case BrowserTag.STABLE:
|
case BrowserTag.STABLE:
|
||||||
|
case BrowserTag.ESR:
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`${tag} is not supported for ${browser}. Use 'latest' instead.`
|
`${tag} is not supported for Chromium. Use 'latest' instead.`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// We assume the tag is the buildId if it didn't match any keywords.
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
export async function resolveBuildId(
|
||||||
|
browser: Browser,
|
||||||
|
platform: BrowserPlatform,
|
||||||
|
tag: string
|
||||||
|
): Promise<string> {
|
||||||
|
const browserTag = tag as BrowserTag;
|
||||||
|
if (Object.values(BrowserTag).includes(browserTag)) {
|
||||||
|
return await resolveBuildIdForBrowserTag(browser, platform, browserTag);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (browser) {
|
||||||
|
case Browser.FIREFOX:
|
||||||
return tag;
|
return tag;
|
||||||
|
case Browser.CHROME:
|
||||||
|
const chromeResult = await chrome.resolveBuildId(tag);
|
||||||
|
if (chromeResult) {
|
||||||
|
return chromeResult;
|
||||||
|
}
|
||||||
|
return tag;
|
||||||
|
case Browser.CHROMEDRIVER:
|
||||||
|
const chromeDriverResult = await chromedriver.resolveBuildId(tag);
|
||||||
|
if (chromeDriverResult) {
|
||||||
|
return chromeDriverResult;
|
||||||
|
}
|
||||||
|
return tag;
|
||||||
|
case Browser.CHROMEHEADLESSSHELL:
|
||||||
|
const chromeHeadlessShellResult =
|
||||||
|
await chromeHeadlessShell.resolveBuildId(tag);
|
||||||
|
if (chromeHeadlessShellResult) {
|
||||||
|
return chromeHeadlessShellResult;
|
||||||
|
}
|
||||||
|
return tag;
|
||||||
|
case Browser.CHROMIUM:
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,7 +11,7 @@ import {getJSON} from '../httpUtil.js';
|
|||||||
|
|
||||||
import {BrowserPlatform, type ProfileOptions} from './types.js';
|
import {BrowserPlatform, type ProfileOptions} from './types.js';
|
||||||
|
|
||||||
function archive(platform: BrowserPlatform, buildId: string): string {
|
function archiveNightly(platform: BrowserPlatform, buildId: string): string {
|
||||||
switch (platform) {
|
switch (platform) {
|
||||||
case BrowserPlatform.LINUX:
|
case BrowserPlatform.LINUX:
|
||||||
return `firefox-${buildId}.en-US.${platform}-x86_64.tar.bz2`;
|
return `firefox-${buildId}.en-US.${platform}-x86_64.tar.bz2`;
|
||||||
@ -24,48 +24,146 @@ function archive(platform: BrowserPlatform, buildId: string): string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function archive(platform: BrowserPlatform, buildId: string): string {
|
||||||
|
switch (platform) {
|
||||||
|
case BrowserPlatform.LINUX:
|
||||||
|
return `firefox-${buildId}.tar.bz2`;
|
||||||
|
case BrowserPlatform.MAC_ARM:
|
||||||
|
case BrowserPlatform.MAC:
|
||||||
|
return `Firefox ${buildId}.dmg`;
|
||||||
|
case BrowserPlatform.WIN32:
|
||||||
|
case BrowserPlatform.WIN64:
|
||||||
|
return `Firefox Setup ${buildId}.exe`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function platformName(platform: BrowserPlatform): string {
|
||||||
|
switch (platform) {
|
||||||
|
case BrowserPlatform.LINUX:
|
||||||
|
return `linux-x86_64`;
|
||||||
|
case BrowserPlatform.MAC_ARM:
|
||||||
|
case BrowserPlatform.MAC:
|
||||||
|
return `mac`;
|
||||||
|
case BrowserPlatform.WIN32:
|
||||||
|
case BrowserPlatform.WIN64:
|
||||||
|
return platform;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseBuildId(buildId: string): [FirefoxChannel, string] {
|
||||||
|
for (const value of Object.values(FirefoxChannel)) {
|
||||||
|
if (buildId.startsWith(value + '_')) {
|
||||||
|
buildId = buildId.substring(value.length + 1);
|
||||||
|
return [value, buildId];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Older versions do not have channel as the prefix.«
|
||||||
|
return [FirefoxChannel.NIGHTLY, buildId];
|
||||||
|
}
|
||||||
|
|
||||||
export function resolveDownloadUrl(
|
export function resolveDownloadUrl(
|
||||||
platform: BrowserPlatform,
|
platform: BrowserPlatform,
|
||||||
buildId: string,
|
buildId: string,
|
||||||
baseUrl = 'https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central'
|
baseUrl?: string
|
||||||
): string {
|
): string {
|
||||||
return `${baseUrl}/${resolveDownloadPath(platform, buildId).join('/')}`;
|
const [channel, resolvedBuildId] = parseBuildId(buildId);
|
||||||
|
switch (channel) {
|
||||||
|
case FirefoxChannel.NIGHTLY:
|
||||||
|
baseUrl ??=
|
||||||
|
'https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central';
|
||||||
|
break;
|
||||||
|
case FirefoxChannel.DEVEDITION:
|
||||||
|
baseUrl ??= 'https://archive.mozilla.org/pub/devedition/releases';
|
||||||
|
break;
|
||||||
|
case FirefoxChannel.BETA:
|
||||||
|
case FirefoxChannel.STABLE:
|
||||||
|
case FirefoxChannel.ESR:
|
||||||
|
baseUrl ??= 'https://archive.mozilla.org/pub/firefox/releases';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
switch (channel) {
|
||||||
|
case FirefoxChannel.NIGHTLY:
|
||||||
|
return `${baseUrl}/${resolveDownloadPath(platform, resolvedBuildId).join('/')}`;
|
||||||
|
case FirefoxChannel.DEVEDITION:
|
||||||
|
case FirefoxChannel.BETA:
|
||||||
|
case FirefoxChannel.STABLE:
|
||||||
|
case FirefoxChannel.ESR:
|
||||||
|
return `${baseUrl}/${resolvedBuildId}/${platformName(platform)}/en-US/${archive(platform, resolvedBuildId)}`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function resolveDownloadPath(
|
export function resolveDownloadPath(
|
||||||
platform: BrowserPlatform,
|
platform: BrowserPlatform,
|
||||||
buildId: string
|
buildId: string
|
||||||
): string[] {
|
): string[] {
|
||||||
return [archive(platform, buildId)];
|
return [archiveNightly(platform, buildId)];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function relativeExecutablePath(
|
export function relativeExecutablePath(
|
||||||
platform: BrowserPlatform,
|
platform: BrowserPlatform,
|
||||||
_buildId: string
|
buildId: string
|
||||||
): string {
|
): string {
|
||||||
|
const [channel] = parseBuildId(buildId);
|
||||||
|
switch (channel) {
|
||||||
|
case FirefoxChannel.NIGHTLY:
|
||||||
switch (platform) {
|
switch (platform) {
|
||||||
case BrowserPlatform.MAC_ARM:
|
case BrowserPlatform.MAC_ARM:
|
||||||
case BrowserPlatform.MAC:
|
case BrowserPlatform.MAC:
|
||||||
return path.join('Firefox Nightly.app', 'Contents', 'MacOS', 'firefox');
|
return path.join(
|
||||||
|
'Firefox Nightly.app',
|
||||||
|
'Contents',
|
||||||
|
'MacOS',
|
||||||
|
'firefox'
|
||||||
|
);
|
||||||
case BrowserPlatform.LINUX:
|
case BrowserPlatform.LINUX:
|
||||||
return path.join('firefox', 'firefox');
|
return path.join('firefox', 'firefox');
|
||||||
case BrowserPlatform.WIN32:
|
case BrowserPlatform.WIN32:
|
||||||
case BrowserPlatform.WIN64:
|
case BrowserPlatform.WIN64:
|
||||||
return path.join('firefox', 'firefox.exe');
|
return path.join('firefox', 'firefox.exe');
|
||||||
}
|
}
|
||||||
|
case FirefoxChannel.BETA:
|
||||||
|
case FirefoxChannel.DEVEDITION:
|
||||||
|
case FirefoxChannel.ESR:
|
||||||
|
case FirefoxChannel.STABLE:
|
||||||
|
switch (platform) {
|
||||||
|
case BrowserPlatform.MAC_ARM:
|
||||||
|
case BrowserPlatform.MAC:
|
||||||
|
return path.join('Firefox.app', 'Contents', 'MacOS', 'firefox');
|
||||||
|
case BrowserPlatform.LINUX:
|
||||||
|
return path.join('firefox', 'firefox');
|
||||||
|
case BrowserPlatform.WIN32:
|
||||||
|
case BrowserPlatform.WIN64:
|
||||||
|
return path.join('core', 'firefox.exe');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum FirefoxChannel {
|
||||||
|
STABLE = 'stable',
|
||||||
|
ESR = 'esr',
|
||||||
|
DEVEDITION = 'devedition',
|
||||||
|
BETA = 'beta',
|
||||||
|
NIGHTLY = 'nightly',
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function resolveBuildId(
|
export async function resolveBuildId(
|
||||||
channel: 'FIREFOX_NIGHTLY' = 'FIREFOX_NIGHTLY'
|
channel: FirefoxChannel = FirefoxChannel.NIGHTLY
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
|
const channelToVersionKey = {
|
||||||
|
[FirefoxChannel.ESR]: 'FIREFOX_ESR',
|
||||||
|
[FirefoxChannel.STABLE]: 'LATEST_FIREFOX_VERSION',
|
||||||
|
[FirefoxChannel.DEVEDITION]: 'FIREFOX_DEVEDITION',
|
||||||
|
[FirefoxChannel.BETA]: 'FIREFOX_DEVEDITION',
|
||||||
|
[FirefoxChannel.NIGHTLY]: 'FIREFOX_NIGHTLY',
|
||||||
|
};
|
||||||
const versions = (await getJSON(
|
const versions = (await getJSON(
|
||||||
new URL('https://product-details.mozilla.org/1.0/firefox_versions.json')
|
new URL('https://product-details.mozilla.org/1.0/firefox_versions.json')
|
||||||
)) as Record<string, string>;
|
)) as Record<string, string>;
|
||||||
const version = versions[channel];
|
const version = versions[channelToVersionKey[channel]];
|
||||||
if (!version) {
|
if (!version) {
|
||||||
throw new Error(`Channel ${channel} is not found.`);
|
throw new Error(`Channel ${channel} is not found.`);
|
||||||
}
|
}
|
||||||
return version;
|
return channel + '_' + version;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createProfile(options: ProfileOptions): Promise<void> {
|
export async function createProfile(options: ProfileOptions): Promise<void> {
|
||||||
|
@ -36,9 +36,12 @@ export enum BrowserPlatform {
|
|||||||
*/
|
*/
|
||||||
export enum BrowserTag {
|
export enum BrowserTag {
|
||||||
CANARY = 'canary',
|
CANARY = 'canary',
|
||||||
|
NIGHTLY = 'nightly',
|
||||||
BETA = 'beta',
|
BETA = 'beta',
|
||||||
DEV = 'dev',
|
DEV = 'dev',
|
||||||
|
DEVEDITION = 'devedition',
|
||||||
STABLE = 'stable',
|
STABLE = 'stable',
|
||||||
|
ESR = 'esr',
|
||||||
LATEST = 'latest',
|
LATEST = 'latest',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {exec as execChildProcess} from 'child_process';
|
import {exec as execChildProcess, spawnSync} from 'child_process';
|
||||||
import {createReadStream} from 'fs';
|
import {createReadStream} from 'fs';
|
||||||
import {mkdir, readdir} from 'fs/promises';
|
import {mkdir, readdir} from 'fs/promises';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
@ -30,6 +30,18 @@ export async function unpackArchive(
|
|||||||
} else if (archivePath.endsWith('.dmg')) {
|
} else if (archivePath.endsWith('.dmg')) {
|
||||||
await mkdir(folderPath);
|
await mkdir(folderPath);
|
||||||
await installDMG(archivePath, folderPath);
|
await installDMG(archivePath, folderPath);
|
||||||
|
} else if (archivePath.endsWith('.exe')) {
|
||||||
|
// Firefox on Windows.
|
||||||
|
const result = spawnSync(archivePath, [`/ExtractDir=${folderPath}`], {
|
||||||
|
env: {
|
||||||
|
__compat_layer: 'RunAsInvoker',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (result.status !== 0) {
|
||||||
|
throw new Error(
|
||||||
|
`Failed to extract ${archivePath} to ${folderPath}: ${result.output}`
|
||||||
|
);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`Unsupported archive format: ${archivePath}`);
|
throw new Error(`Unsupported archive format: ${archivePath}`);
|
||||||
}
|
}
|
||||||
|
@ -138,6 +138,7 @@ describe('Chrome install', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('falls back to the chrome-for-testing dashboard URLs if URL is not available', async function () {
|
it('falls back to the chrome-for-testing dashboard URLs if URL is not available', async function () {
|
||||||
|
this.timeout(60000);
|
||||||
const expectedOutputPath = path.join(
|
const expectedOutputPath = path.join(
|
||||||
tmpDir,
|
tmpDir,
|
||||||
'chrome',
|
'chrome',
|
||||||
|
@ -18,7 +18,7 @@ import {
|
|||||||
} from '../../../lib/cjs/browser-data/firefox.js';
|
} from '../../../lib/cjs/browser-data/firefox.js';
|
||||||
|
|
||||||
describe('Firefox', () => {
|
describe('Firefox', () => {
|
||||||
it('should resolve download URLs', () => {
|
it('should resolve download URLs for Nightly', () => {
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
resolveDownloadUrl(BrowserPlatform.LINUX, '111.0a1'),
|
resolveDownloadUrl(BrowserPlatform.LINUX, '111.0a1'),
|
||||||
'https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central/firefox-111.0a1.en-US.linux-x86_64.tar.bz2'
|
'https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central/firefox-111.0a1.en-US.linux-x86_64.tar.bz2'
|
||||||
@ -41,6 +41,75 @@ describe('Firefox', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should resolve download URLs for beta', () => {
|
||||||
|
assert.strictEqual(
|
||||||
|
resolveDownloadUrl(BrowserPlatform.LINUX, 'beta_115.0b8'),
|
||||||
|
'https://archive.mozilla.org/pub/firefox/releases/115.0b8/linux-x86_64/en-US/firefox-115.0b8.tar.bz2'
|
||||||
|
);
|
||||||
|
assert.strictEqual(
|
||||||
|
resolveDownloadUrl(BrowserPlatform.MAC, 'beta_115.0b8'),
|
||||||
|
'https://archive.mozilla.org/pub/firefox/releases/115.0b8/mac/en-US/Firefox 115.0b8.dmg'
|
||||||
|
);
|
||||||
|
assert.strictEqual(
|
||||||
|
resolveDownloadUrl(BrowserPlatform.MAC_ARM, 'beta_115.0b8'),
|
||||||
|
'https://archive.mozilla.org/pub/firefox/releases/115.0b8/mac/en-US/Firefox 115.0b8.dmg'
|
||||||
|
);
|
||||||
|
assert.strictEqual(
|
||||||
|
resolveDownloadUrl(BrowserPlatform.WIN32, 'beta_115.0b8'),
|
||||||
|
'https://archive.mozilla.org/pub/firefox/releases/115.0b8/win32/en-US/Firefox Setup 115.0b8.exe'
|
||||||
|
);
|
||||||
|
assert.strictEqual(
|
||||||
|
resolveDownloadUrl(BrowserPlatform.WIN64, 'beta_115.0b8'),
|
||||||
|
'https://archive.mozilla.org/pub/firefox/releases/115.0b8/win64/en-US/Firefox Setup 115.0b8.exe'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should resolve download URLs for stable', () => {
|
||||||
|
assert.strictEqual(
|
||||||
|
resolveDownloadUrl(BrowserPlatform.LINUX, 'stable_111.0.1'),
|
||||||
|
'https://archive.mozilla.org/pub/firefox/releases/111.0.1/linux-x86_64/en-US/firefox-111.0.1.tar.bz2'
|
||||||
|
);
|
||||||
|
assert.strictEqual(
|
||||||
|
resolveDownloadUrl(BrowserPlatform.MAC, 'stable_111.0.1'),
|
||||||
|
'https://archive.mozilla.org/pub/firefox/releases/111.0.1/mac/en-US/Firefox 111.0.1.dmg'
|
||||||
|
);
|
||||||
|
assert.strictEqual(
|
||||||
|
resolveDownloadUrl(BrowserPlatform.MAC_ARM, 'stable_111.0.1'),
|
||||||
|
'https://archive.mozilla.org/pub/firefox/releases/111.0.1/mac/en-US/Firefox 111.0.1.dmg'
|
||||||
|
);
|
||||||
|
assert.strictEqual(
|
||||||
|
resolveDownloadUrl(BrowserPlatform.WIN32, 'stable_111.0.1'),
|
||||||
|
'https://archive.mozilla.org/pub/firefox/releases/111.0.1/win32/en-US/Firefox Setup 111.0.1.exe'
|
||||||
|
);
|
||||||
|
assert.strictEqual(
|
||||||
|
resolveDownloadUrl(BrowserPlatform.WIN64, 'stable_111.0.1'),
|
||||||
|
'https://archive.mozilla.org/pub/firefox/releases/111.0.1/win64/en-US/Firefox Setup 111.0.1.exe'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should resolve download URLs for devedition', () => {
|
||||||
|
assert.strictEqual(
|
||||||
|
resolveDownloadUrl(BrowserPlatform.LINUX, 'devedition_115.0b8'),
|
||||||
|
'https://archive.mozilla.org/pub/devedition/releases/115.0b8/linux-x86_64/en-US/firefox-115.0b8.tar.bz2'
|
||||||
|
);
|
||||||
|
assert.strictEqual(
|
||||||
|
resolveDownloadUrl(BrowserPlatform.MAC, 'devedition_115.0b8'),
|
||||||
|
'https://archive.mozilla.org/pub/devedition/releases/115.0b8/mac/en-US/Firefox 115.0b8.dmg'
|
||||||
|
);
|
||||||
|
assert.strictEqual(
|
||||||
|
resolveDownloadUrl(BrowserPlatform.MAC_ARM, 'devedition_115.0b8'),
|
||||||
|
'https://archive.mozilla.org/pub/devedition/releases/115.0b8/mac/en-US/Firefox 115.0b8.dmg'
|
||||||
|
);
|
||||||
|
assert.strictEqual(
|
||||||
|
resolveDownloadUrl(BrowserPlatform.WIN32, 'devedition_115.0b8'),
|
||||||
|
'https://archive.mozilla.org/pub/devedition/releases/115.0b8/win32/en-US/Firefox Setup 115.0b8.exe'
|
||||||
|
);
|
||||||
|
assert.strictEqual(
|
||||||
|
resolveDownloadUrl(BrowserPlatform.WIN64, 'devedition_115.0b8'),
|
||||||
|
'https://archive.mozilla.org/pub/devedition/releases/115.0b8/win64/en-US/Firefox Setup 115.0b8.exe'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('should resolve executable paths', () => {
|
it('should resolve executable paths', () => {
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
relativeExecutablePath(BrowserPlatform.LINUX, '111.0a1'),
|
relativeExecutablePath(BrowserPlatform.LINUX, '111.0a1'),
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import assert from 'assert';
|
import assert from 'assert';
|
||||||
|
import {spawnSync} from 'child_process';
|
||||||
|
import {existsSync} from 'fs';
|
||||||
import {readdir} from 'fs/promises';
|
import {readdir} from 'fs/promises';
|
||||||
import {platform} from 'os';
|
import {platform} from 'os';
|
||||||
import {join} from 'path';
|
import {join} from 'path';
|
||||||
@ -49,3 +51,36 @@ import {readAsset} from './util.js';
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
describe('Firefox download', () => {
|
||||||
|
configureSandbox({
|
||||||
|
dependencies: ['@puppeteer/browsers', 'puppeteer-core', 'puppeteer'],
|
||||||
|
env: cwd => {
|
||||||
|
return {
|
||||||
|
PUPPETEER_CACHE_DIR: join(cwd, '.cache', 'puppeteer'),
|
||||||
|
PUPPETEER_SKIP_DOWNLOAD: 'true',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
it('can download Firefox stable', async function () {
|
||||||
|
assert.ok(!existsSync(join(this.sandbox, '.cache', 'puppeteer')));
|
||||||
|
const result = spawnSync(
|
||||||
|
'npx',
|
||||||
|
['puppeteer', 'browsers', 'install', 'firefox@stable'],
|
||||||
|
{
|
||||||
|
// npx is not found without the shell flag on Windows.
|
||||||
|
shell: process.platform === 'win32',
|
||||||
|
cwd: this.sandbox,
|
||||||
|
env: {
|
||||||
|
...process.env,
|
||||||
|
PUPPETEER_CACHE_DIR: join(this.sandbox, '.cache', 'puppeteer'),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
assert.strictEqual(result.status, 0);
|
||||||
|
const files = await readdir(join(this.sandbox, '.cache', 'puppeteer'));
|
||||||
|
assert.equal(files.length, 1);
|
||||||
|
assert.equal(files[0], 'firefox');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user