diff --git a/src/test/webdriver/chromedriver.rs b/src/test/webdriver/chromedriver.rs index 95689b4b..f58f2428 100644 --- a/src/test/webdriver/chromedriver.rs +++ b/src/test/webdriver/chromedriver.rs @@ -5,6 +5,7 @@ use crate::target; use anyhow::{bail, Context, Result}; use binary_install::Cache; use chrono::DateTime; +use std::collections::HashMap; use std::path::PathBuf; // Keep it up to date with each `wasm-pack` release. @@ -28,7 +29,9 @@ pub fn install_chromedriver(cache: &Cache, installation_allowed: bool) -> Result let target = if target::LINUX && target::x86_64 { "linux64" } else if target::MACOS && target::x86_64 { - "mac64" + "mac-x64" + } else if target::MACOS && target::aarch64 { + "mac-arm64" } else if target::WINDOWS { "win32" } else { @@ -116,19 +119,44 @@ fn should_load_chromedriver_version_from_stamp(json: &serde_json::Value) -> bool } } +/// Channel information from the chromedriver version endpoint. +#[derive(Deserialize)] +struct ChannelInfo { + version: String, +} + +/// The response from the chromedriver version endpoint. +#[derive(Deserialize)] +struct GoodLatestVersions { + channels: HashMap, +} + +/// Retrieve the latest version of chromedriver from the json endpoints. +/// See: fn fetch_chromedriver_version() -> Result { - let version = ureq::get("https://chromedriver.storage.googleapis.com/LATEST_RELEASE") - .call() - .context("fetching of chromedriver's LATEST_RELEASE failed")? - .into_string() - .context("converting chromedriver version response to string failed")?; + let info: GoodLatestVersions = ureq::get( + "https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json", + ) + .call() + .context("fetching of chromedriver's LATEST_RELEASE failed")? + .into_json() + .context("converting chromedriver version response to GoodLatestVersions failed")?; + + let version = info + .channels + .get("Stable") + .ok_or_else(|| anyhow::anyhow!("no Stable channel found in chromedriver version response"))? + .version + .clone(); + + println!("chromedriver version: {}", version); Ok(version) } fn assemble_chromedriver_url(chromedriver_version: &str, target: &str) -> String { format!( - "https://chromedriver.storage.googleapis.com/{version}/chromedriver_{target}.zip", + "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/{version}/{target}/chromedriver-{target}.zip", version = chromedriver_version, target = target, )