From f7fd4a1cd955775afb884c751197b4f7171c6fed Mon Sep 17 00:00:00 2001 From: Henrik Skupin Date: Thu, 17 Aug 2017 14:05:11 +0200 Subject: [PATCH] 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 --- testing/geckodriver/CHANGES.md | 1 + testing/geckodriver/src/marionette.rs | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/testing/geckodriver/CHANGES.md b/testing/geckodriver/CHANGES.md index 86fbf5e01cf7..6d71ebd2c354 100644 --- a/testing/geckodriver/CHANGES.md +++ b/testing/geckodriver/CHANGES.md @@ -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 diff --git a/testing/geckodriver/src/marionette.rs b/testing/geckodriver/src/marionette.rs index 369f9800fa38..55bae1440456 100644 --- a/testing/geckodriver/src/marionette.rs +++ b/testing/geckodriver/src/marionette.rs @@ -548,7 +548,16 @@ impl WebDriverHandler 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") } },