tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

chromedriver.ts (1594B)


      1 /**
      2 * @license
      3 * Copyright 2023 Google Inc.
      4 * SPDX-License-Identifier: Apache-2.0
      5 */
      6 import path from 'node:path';
      7 
      8 import {BrowserPlatform} from './types.js';
      9 
     10 function folder(platform: BrowserPlatform): string {
     11  switch (platform) {
     12    case BrowserPlatform.LINUX_ARM:
     13    case BrowserPlatform.LINUX:
     14      return 'linux64';
     15    case BrowserPlatform.MAC_ARM:
     16      return 'mac-arm64';
     17    case BrowserPlatform.MAC:
     18      return 'mac-x64';
     19    case BrowserPlatform.WIN32:
     20      return 'win32';
     21    case BrowserPlatform.WIN64:
     22      return 'win64';
     23  }
     24 }
     25 
     26 export function resolveDownloadUrl(
     27  platform: BrowserPlatform,
     28  buildId: string,
     29  baseUrl = 'https://storage.googleapis.com/chrome-for-testing-public',
     30 ): string {
     31  return `${baseUrl}/${resolveDownloadPath(platform, buildId).join('/')}`;
     32 }
     33 
     34 export function resolveDownloadPath(
     35  platform: BrowserPlatform,
     36  buildId: string,
     37 ): string[] {
     38  return [buildId, folder(platform), `chromedriver-${folder(platform)}.zip`];
     39 }
     40 
     41 export function relativeExecutablePath(
     42  platform: BrowserPlatform,
     43  _buildId: string,
     44 ): string {
     45  switch (platform) {
     46    case BrowserPlatform.MAC:
     47    case BrowserPlatform.MAC_ARM:
     48      return path.join('chromedriver-' + folder(platform), 'chromedriver');
     49    case BrowserPlatform.LINUX_ARM:
     50    case BrowserPlatform.LINUX:
     51      return path.join('chromedriver-linux64', 'chromedriver');
     52    case BrowserPlatform.WIN32:
     53    case BrowserPlatform.WIN64:
     54      return path.join('chromedriver-' + folder(platform), 'chromedriver.exe');
     55  }
     56 }
     57 
     58 export {resolveBuildId, compareVersions} from './chrome.js';