Skip to content

Commit

Permalink
Fix WebDriver compat with Safari
Browse files Browse the repository at this point in the history
They've made a few breaking changes in the most recent version, so let's
support that plus the old protocol for now!

Closes rustwasm#983
  • Loading branch information
alexcrichton committed Oct 28, 2018
1 parent 1fa407d commit aa963db
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion crates/cli/src/bin/wasm-bindgen-test-runner/headless.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,15 +284,27 @@ impl Client {
Driver::Safari(_) => {
#[derive(Deserialize)]
struct Response {
// returned by `--legacy`
#[serde(rename = "sessionId")]
session_id: Option<String>,
// returned by the now-default `--w3c` mode
value: Option<Value>,
}
#[derive(Deserialize)]
struct Value {
#[serde(rename = "sessionId")]
session_id: String,
}
let request = json!({
// this is needed for the now `--legacy` mode
"desiredCapabilities": {
},
// this is needed for the now `--w3c` (default) mode
"capabilities": {
}
});
let x: Response = self.post("/session", &request)?;
Ok(x.session_id)
Ok(x.session_id.or(x.value.map(|v| v.session_id)).unwrap())
}
Driver::Chrome(_) => {
#[derive(Deserialize)]
Expand Down

0 comments on commit aa963db

Please sign in to comment.