Skip to content

Commit 8cba32f

Browse files
authored
Merge pull request #1325 from Myriad-Dreamin/new-chromdriver-endpoint
Use new chromdriver endpoint
2 parents 77b8ced + 49c1e93 commit 8cba32f

File tree

1 file changed

+35
-7
lines changed

1 file changed

+35
-7
lines changed

src/test/webdriver/chromedriver.rs

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::target;
55
use anyhow::{bail, Context, Result};
66
use binary_install::Cache;
77
use chrono::DateTime;
8+
use std::collections::HashMap;
89
use std::path::PathBuf;
910

1011
// Keep it up to date with each `wasm-pack` release.
@@ -28,7 +29,9 @@ pub fn install_chromedriver(cache: &Cache, installation_allowed: bool) -> Result
2829
let target = if target::LINUX && target::x86_64 {
2930
"linux64"
3031
} else if target::MACOS && target::x86_64 {
31-
"mac64"
32+
"mac-x64"
33+
} else if target::MACOS && target::aarch64 {
34+
"mac-arm64"
3235
} else if target::WINDOWS {
3336
"win32"
3437
} else {
@@ -116,19 +119,44 @@ fn should_load_chromedriver_version_from_stamp(json: &serde_json::Value) -> bool
116119
}
117120
}
118121

122+
/// Channel information from the chromedriver version endpoint.
123+
#[derive(Deserialize)]
124+
struct ChannelInfo {
125+
version: String,
126+
}
127+
128+
/// The response from the chromedriver version endpoint.
129+
#[derive(Deserialize)]
130+
struct GoodLatestVersions {
131+
channels: HashMap<String, ChannelInfo>,
132+
}
133+
134+
/// Retrieve the latest version of chromedriver from the json endpoints.
135+
/// See: <https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints>
119136
fn fetch_chromedriver_version() -> Result<String> {
120-
let version = ureq::get("https://chromedriver.storage.googleapis.com/LATEST_RELEASE")
121-
.call()
122-
.context("fetching of chromedriver's LATEST_RELEASE failed")?
123-
.into_string()
124-
.context("converting chromedriver version response to string failed")?;
137+
let info: GoodLatestVersions = ureq::get(
138+
"https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json",
139+
)
140+
.call()
141+
.context("fetching of chromedriver's LATEST_RELEASE failed")?
142+
.into_json()
143+
.context("converting chromedriver version response to GoodLatestVersions failed")?;
144+
145+
let version = info
146+
.channels
147+
.get("Stable")
148+
.ok_or_else(|| anyhow::anyhow!("no Stable channel found in chromedriver version response"))?
149+
.version
150+
.clone();
151+
152+
println!("chromedriver version: {}", version);
125153

126154
Ok(version)
127155
}
128156

129157
fn assemble_chromedriver_url(chromedriver_version: &str, target: &str) -> String {
130158
format!(
131-
"https://chromedriver.storage.googleapis.com/{version}/chromedriver_{target}.zip",
159+
"https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/{version}/{target}/chromedriver-{target}.zip",
132160
version = chromedriver_version,
133161
target = target,
134162
)

0 commit comments

Comments
 (0)