geckodriver: marionette: use session not created errors when failing to start browser

WebDriver doesn't distinguish between the geckodriver and Marionette
implementations when making a call to New Session.  When failing to
start a session, we should return session not created errors.

Source-Repo: https://github.com/mozilla/geckodriver
Source-Revision: a9e496a15d79a21e054bbc8d861bf2a8d608051f

committer: jgraham <james@hoppipolla.co.uk>

--HG--
extra : rebase_source : 120fdb7c8306a213c051f3df6b327f49154d9153
This commit is contained in:
Andreas Tolfsen 2016-11-23 07:35:36 +00:00
parent 70c0123149
commit 32df7e6e78

View File

@ -350,7 +350,7 @@ impl MarionetteHandler {
fn start_browser(&mut self, port: u16, mut options: FirefoxOptions) -> WebDriverResult<()> {
let binary = try!(self.binary_path(&mut options)
.ok_or(WebDriverError::new(ErrorStatus::UnknownError,
.ok_or(WebDriverError::new(ErrorStatus::SessionNotCreated,
"Expected browser binary location, but unable to find \
binary in default location, no \
'moz:firefoxOptions.binary' capability provided, and \
@ -359,7 +359,7 @@ impl MarionetteHandler {
let custom_profile = options.profile.is_some();
let mut runner = try!(FirefoxRunner::new(&binary, options.profile.take())
.map_err(|e| WebDriverError::new(ErrorStatus::UnknownError,
.map_err(|e| WebDriverError::new(ErrorStatus::SessionNotCreated,
e.description().to_owned())));
if let Some(args) = options.args.take() {
runner.args().extend(args);
@ -367,14 +367,14 @@ impl MarionetteHandler {
try!(self.set_prefs(port, &mut runner.profile, custom_profile, options.prefs)
.map_err(|e| {
WebDriverError::new(ErrorStatus::UnknownError,
WebDriverError::new(ErrorStatus::SessionNotCreated,
format!("Failed to set preferences: {}", e))
}));
info!("Starting browser {}", binary.display());
try!(runner.start()
.map_err(|e| {
WebDriverError::new(ErrorStatus::UnknownError,
WebDriverError::new(ErrorStatus::SessionNotCreated,
format!("Failed to start browser {}: {}",
binary.display(), e))
}));