Bug 1387403 - Force quitting the browser if no session can be established. r=jgraham

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

--HG--
extra : rebase_source : 0da6529e2c09358c83760fc66c997db09665e304
This commit is contained in:
Henrik Skupin 2017-08-17 14:05:11 +02:00
Родитель 59a7d270fb
Коммит f7fd4a1cd9
2 изменённых файлов: 11 добавлений и 1 удалений

Просмотреть файл

@ -15,6 +15,7 @@ All notable changes to this program is documented in this file.
[`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

Просмотреть файл

@ -548,7 +548,16 @@ impl WebDriverHandler<GeckoExtensionRoute> for MarionetteHandler {
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")
}
},