mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
feat: support Chrome channels for ChromeDriver (#10158)
This commit is contained in:
parent
c815ba45a3
commit
e313b054e6
@ -101,12 +101,14 @@ export async function resolveBuildId(
|
||||
case Browser.CHROMEDRIVER:
|
||||
switch (tag as BrowserTag) {
|
||||
case BrowserTag.LATEST:
|
||||
return await chromedriver.resolveBuildId('latest');
|
||||
case BrowserTag.BETA:
|
||||
case BrowserTag.CANARY:
|
||||
return await chromedriver.resolveBuildId(ChromeReleaseChannel.CANARY);
|
||||
case BrowserTag.BETA:
|
||||
return await chromedriver.resolveBuildId(ChromeReleaseChannel.BETA);
|
||||
case BrowserTag.DEV:
|
||||
return await chromedriver.resolveBuildId(ChromeReleaseChannel.DEV);
|
||||
case BrowserTag.STABLE:
|
||||
throw new Error(`${tag} is not support for ${browser}`);
|
||||
return await chromedriver.resolveBuildId(ChromeReleaseChannel.STABLE);
|
||||
}
|
||||
case Browser.CHROMIUM:
|
||||
switch (tag as BrowserTag) {
|
||||
|
@ -13,29 +13,30 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import path from 'path';
|
||||
|
||||
import {getText} from '../httpUtil.js';
|
||||
import {getLastKnownGoodReleaseForChannel} from './chrome.js';
|
||||
import {BrowserPlatform, ChromeReleaseChannel} from './types.js';
|
||||
|
||||
import {BrowserPlatform} from './types.js';
|
||||
|
||||
function archive(platform: BrowserPlatform): string {
|
||||
function folder(platform: BrowserPlatform): string {
|
||||
switch (platform) {
|
||||
case BrowserPlatform.LINUX:
|
||||
return 'chromedriver_linux64';
|
||||
return 'linux64';
|
||||
case BrowserPlatform.MAC_ARM:
|
||||
return 'chromedriver_mac_arm64';
|
||||
return 'mac-arm64';
|
||||
case BrowserPlatform.MAC:
|
||||
return 'chromedriver_mac64';
|
||||
return 'mac-x64';
|
||||
case BrowserPlatform.WIN32:
|
||||
return 'win32';
|
||||
case BrowserPlatform.WIN64:
|
||||
return 'chromedriver_win32';
|
||||
return 'win64';
|
||||
}
|
||||
}
|
||||
|
||||
export function resolveDownloadUrl(
|
||||
platform: BrowserPlatform,
|
||||
buildId: string,
|
||||
baseUrl = 'https://chromedriver.storage.googleapis.com'
|
||||
baseUrl = 'https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing'
|
||||
): string {
|
||||
return `${baseUrl}/${resolveDownloadPath(platform, buildId).join('/')}`;
|
||||
}
|
||||
@ -44,7 +45,7 @@ export function resolveDownloadPath(
|
||||
platform: BrowserPlatform,
|
||||
buildId: string
|
||||
): string[] {
|
||||
return [buildId, `${archive(platform)}.zip`];
|
||||
return [buildId, folder(platform), `chromedriver-${folder(platform)}.zip`];
|
||||
}
|
||||
|
||||
export function relativeExecutablePath(
|
||||
@ -54,17 +55,16 @@ export function relativeExecutablePath(
|
||||
switch (platform) {
|
||||
case BrowserPlatform.MAC:
|
||||
case BrowserPlatform.MAC_ARM:
|
||||
return path.join('chromedriver-' + folder(platform), 'chromedriver');
|
||||
case BrowserPlatform.LINUX:
|
||||
return 'chromedriver';
|
||||
return path.join('chromedriver-linux64', 'chromedriver');
|
||||
case BrowserPlatform.WIN32:
|
||||
case BrowserPlatform.WIN64:
|
||||
return 'chromedriver.exe';
|
||||
return path.join('chromedriver-' + folder(platform), 'chromedriver.exe');
|
||||
}
|
||||
}
|
||||
export async function resolveBuildId(
|
||||
_channel: 'latest' = 'latest'
|
||||
channel: ChromeReleaseChannel
|
||||
): Promise<string> {
|
||||
return await getText(
|
||||
new URL(`https://chromedriver.storage.googleapis.com/LATEST_RELEASE`)
|
||||
);
|
||||
return (await getLastKnownGoodReleaseForChannel(channel)).version;
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
import assert from 'assert';
|
||||
import path from 'path';
|
||||
|
||||
import {BrowserPlatform} from '../../../lib/cjs/browser-data/browser-data.js';
|
||||
import {
|
||||
@ -25,47 +26,47 @@ import {
|
||||
describe('ChromeDriver', () => {
|
||||
it('should resolve download URLs', () => {
|
||||
assert.strictEqual(
|
||||
resolveDownloadUrl(BrowserPlatform.LINUX, '112.0.5615.49'),
|
||||
'https://chromedriver.storage.googleapis.com/112.0.5615.49/chromedriver_linux64.zip'
|
||||
resolveDownloadUrl(BrowserPlatform.LINUX, '115.0.5763.0'),
|
||||
'https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/115.0.5763.0/linux64/chromedriver-linux64.zip'
|
||||
);
|
||||
assert.strictEqual(
|
||||
resolveDownloadUrl(BrowserPlatform.MAC, '112.0.5615.49'),
|
||||
'https://chromedriver.storage.googleapis.com/112.0.5615.49/chromedriver_mac64.zip'
|
||||
resolveDownloadUrl(BrowserPlatform.MAC, '115.0.5763.0'),
|
||||
'https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/115.0.5763.0/mac-x64/chromedriver-mac-x64.zip'
|
||||
);
|
||||
assert.strictEqual(
|
||||
resolveDownloadUrl(BrowserPlatform.MAC_ARM, '112.0.5615.49'),
|
||||
'https://chromedriver.storage.googleapis.com/112.0.5615.49/chromedriver_mac_arm64.zip'
|
||||
resolveDownloadUrl(BrowserPlatform.MAC_ARM, '115.0.5763.0'),
|
||||
'https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/115.0.5763.0/mac-arm64/chromedriver-mac-arm64.zip'
|
||||
);
|
||||
assert.strictEqual(
|
||||
resolveDownloadUrl(BrowserPlatform.WIN32, '112.0.5615.49'),
|
||||
'https://chromedriver.storage.googleapis.com/112.0.5615.49/chromedriver_win32.zip'
|
||||
resolveDownloadUrl(BrowserPlatform.WIN32, '115.0.5763.0'),
|
||||
'https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/115.0.5763.0/win32/chromedriver-win32.zip'
|
||||
);
|
||||
assert.strictEqual(
|
||||
resolveDownloadUrl(BrowserPlatform.WIN64, '112.0.5615.49'),
|
||||
'https://chromedriver.storage.googleapis.com/112.0.5615.49/chromedriver_win32.zip'
|
||||
resolveDownloadUrl(BrowserPlatform.WIN64, '115.0.5763.0'),
|
||||
'https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/115.0.5763.0/win64/chromedriver-win64.zip'
|
||||
);
|
||||
});
|
||||
|
||||
it('should resolve executable paths', () => {
|
||||
assert.strictEqual(
|
||||
relativeExecutablePath(BrowserPlatform.LINUX, '12372323'),
|
||||
'chromedriver'
|
||||
path.join('chromedriver-linux64', 'chromedriver')
|
||||
);
|
||||
assert.strictEqual(
|
||||
relativeExecutablePath(BrowserPlatform.MAC, '12372323'),
|
||||
'chromedriver'
|
||||
path.join('chromedriver-mac-x64/', 'chromedriver')
|
||||
);
|
||||
assert.strictEqual(
|
||||
relativeExecutablePath(BrowserPlatform.MAC_ARM, '12372323'),
|
||||
'chromedriver'
|
||||
path.join('chromedriver-mac-arm64', 'chromedriver')
|
||||
);
|
||||
assert.strictEqual(
|
||||
relativeExecutablePath(BrowserPlatform.WIN32, '12372323'),
|
||||
'chromedriver.exe'
|
||||
path.join('chromedriver-win32', 'chromedriver.exe')
|
||||
);
|
||||
assert.strictEqual(
|
||||
relativeExecutablePath(BrowserPlatform.WIN64, '12372323'),
|
||||
'chromedriver.exe'
|
||||
path.join('chromedriver-win64', 'chromedriver.exe')
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -64,6 +64,7 @@ describe('ChromeDriver CLI', function () {
|
||||
tmpDir,
|
||||
'chromedriver',
|
||||
`linux-${testChromeDriverBuildId}`,
|
||||
'chromedriver-linux64',
|
||||
'chromedriver'
|
||||
)
|
||||
)
|
||||
@ -81,6 +82,7 @@ describe('ChromeDriver CLI', function () {
|
||||
tmpDir,
|
||||
'chromedriver',
|
||||
`linux-${testChromeDriverBuildId}`,
|
||||
'chromedriver-linux64',
|
||||
'chromedriver'
|
||||
)
|
||||
)
|
||||
|
@ -19,4 +19,4 @@ export const testChromiumBuildId = '1083080';
|
||||
// TODO: We can add a Cron job to auto-update on change.
|
||||
// Firefox keeps only `latest` version of Nightly builds.
|
||||
export const testFirefoxBuildId = '115.0a1';
|
||||
export const testChromeDriverBuildId = '112.0.5615.49';
|
||||
export const testChromeDriverBuildId = '115.0.5763.0';
|
||||
|
Loading…
Reference in New Issue
Block a user