Bug 1387403 - Force quitting the browser if no session can be established.
In case the NewSession command fails due to errors returned
by Marionette, the browser has to be killed. This is necessary
because DeleteSession always requires an existent session, and
would fail in closing the browser. So the process would continue
to be alive.
MozReview-Commit-ID: 1llX4lPNYjN
--- a/testing/geckodriver/CHANGES.md
+++ b/testing/geckodriver/CHANGES.md
@@ -10,16 +10,17 @@ All notable changes to this program is d
[`FullscreenWindow`]: https://docs.rs/webdriver/0.29.0/webdriver/command/enum.WebDriverCommand.html#variant.FullscreenWindow
[`GetWindowRect`]: https://docs.rs/webdriver/0.29.0/webdriver/command/enum.WebDriverCommand.html#variant.GetWindowRect
[`MaximizeWindow`]: https://docs.rs/webdriver/0.29.0/webdriver/command/enum.WebDriverCommand.html#variant.MaximizeWindow
[`MinimizeWindow`]: https://docs.rs/webdriver/0.29.0/webdriver/command/enum.WebDriverCommand.html#variant.MinimizeWindow
[`SetWindowRect`]: https://docs.rs/webdriver/0.29.0/webdriver/command/enum.WebDriverCommand.html#variant.SetWindowRect
### Changed
+- To make sure no browser process is left behind when the [`New Session` command](https://docs.rs/webdriver/0.27.0/webdriver/command/enum.WebDriverCommand.html#variant.NewSession) fails, the process is closed immediately now.
- The `proxyType` `noproxy` has been replaced with `direct` in accordance with recent WebDriver specification changes
- `/moz/addon/install` command accepts an `addon` parameter, in lieu of `path`, containing an addon as a Base64 string
## 0.18.0 (2017-07-10)
### Changed
- [`RectResponse`](https://docs.rs/webdriver/0.27.0/webdriver/response/struct.RectResponse.html) permits returning floats for `width` and `height` fields
- New type [`CookieResponse`](https://docs.rs/webdriver/0.27.0/webdriver/response/struct.CookieResponse.html) for the [`GetNamedCookie` command](https://docs.rs/webdriver/0.27.0/webdriver/command/enum.WebDriverCommand.html#variant.GetNamedCookie) returns a single cookie, as opposed to an array of a single cookie
--- a/testing/geckodriver/src/marionette.rs
+++ b/testing/geckodriver/src/marionette.rs
@@ -543,17 +543,26 @@ impl WebDriverHandler<GeckoExtensionRout
resolved_capabilities = Some(try!(
self.create_connection(&msg.session_id, &capabilities)));
}
}
match self.connection.lock() {
Ok(ref mut connection) => {
match connection.as_mut() {
- Some(conn) => conn.send_command(resolved_capabilities, &msg),
+ Some(conn) => {
+ conn.send_command(resolved_capabilities, &msg)
+ .map_err(|mut err| {
+ // Shutdown the browser if no session can
+ // be established due to errors.
+ if let NewSession(_) = msg.command {
+ err.delete_session=true;
+ }
+ err})
+ },
None => panic!("Connection missing")
}
},
Err(_) => {
Err(WebDriverError::new(
ErrorStatus::UnknownError,
"Failed to aquire Marionette connection"))
}