chromedriver.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /**
  2. * Copyright 2023 Google Inc. All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. import path from 'path';
  17. import { getLastKnownGoodReleaseForChannel } from './chrome.js';
  18. import { BrowserPlatform } from './types.js';
  19. function folder(platform) {
  20. switch (platform) {
  21. case BrowserPlatform.LINUX:
  22. return 'linux64';
  23. case BrowserPlatform.MAC_ARM:
  24. return 'mac-arm64';
  25. case BrowserPlatform.MAC:
  26. return 'mac-x64';
  27. case BrowserPlatform.WIN32:
  28. return 'win32';
  29. case BrowserPlatform.WIN64:
  30. return 'win64';
  31. }
  32. }
  33. export function resolveDownloadUrl(platform, buildId, baseUrl = 'https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing') {
  34. return `${baseUrl}/${resolveDownloadPath(platform, buildId).join('/')}`;
  35. }
  36. export function resolveDownloadPath(platform, buildId) {
  37. return [buildId, folder(platform), `chromedriver-${folder(platform)}.zip`];
  38. }
  39. export function relativeExecutablePath(platform, _buildId) {
  40. switch (platform) {
  41. case BrowserPlatform.MAC:
  42. case BrowserPlatform.MAC_ARM:
  43. return path.join('chromedriver-' + folder(platform), 'chromedriver');
  44. case BrowserPlatform.LINUX:
  45. return path.join('chromedriver-linux64', 'chromedriver');
  46. case BrowserPlatform.WIN32:
  47. case BrowserPlatform.WIN64:
  48. return path.join('chromedriver-' + folder(platform), 'chromedriver.exe');
  49. }
  50. }
  51. export async function resolveBuildId(channel) {
  52. return (await getLastKnownGoodReleaseForChannel(channel)).version;
  53. }
  54. //# sourceMappingURL=chromedriver.js.map