Skip to content

Commit

Permalink
Fix headless test runner on macOS High Sierra
Browse files Browse the repository at this point in the history
  • Loading branch information
LegNeato committed Feb 27, 2019
1 parent 74a39ce commit e80b0cc
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions crates/cli/src/bin/wasm-bindgen-test-runner/headless.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,18 +281,20 @@ impl Client {
Ok(x.value.session_id)
}
Driver::Safari(_) => {
#[derive(Deserialize)]
#[derive(Clone, Deserialize)]
struct Response {
// returned by `--legacy`
// returned by `--legacy` or by default on High Sierra and lower.
#[serde(rename = "sessionId")]
session_id: Option<String>,
// returned by the now-default `--w3c` mode
value: Option<Value>,
}
#[derive(Deserialize)]
#[derive(Clone, Deserialize)]
struct Value {
// This needs to be optional because both `--legacy` and High Sierra do not
// include a session id in the value entry.
#[serde(rename = "sessionId")]
session_id: String,
session_id: Option<String>,
}
let request = json!({
// this is needed for the now `--legacy` mode
Expand All @@ -303,7 +305,10 @@ impl Client {
}
});
let x: Response = self.post("/session", &request)?;
Ok(x.session_id.or(x.value.map(|v| v.session_id)).unwrap())
Ok(x.clone()
.session_id
.or_else(|| x.value.map(|v| v.session_id.unwrap()))
.unwrap())
}
Driver::Chrome(_) => {
#[derive(Deserialize)]
Expand Down

0 comments on commit e80b0cc

Please sign in to comment.