Skip to content

Commit

Permalink
Legacy Firefox driver: Explicitly closing last window before quiting …
Browse files Browse the repository at this point in the history
…session. Fixes #2100
  • Loading branch information
barancev committed Dec 3, 2017
1 parent 036b959 commit 38d6934
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions javascript/firefox-driver/js/firefoxDriver.js
Expand Up @@ -151,6 +151,14 @@ FirefoxDriver.prototype.close = function(respond) {
allWindows.getNext();
}

// Here we go!
try {
var browser = respond.session.getBrowser();
browser.contentWindow.close();
} catch (e) {
goog.log.warning(FirefoxDriver.LOG_, 'Error closing window', e);
}

// If we're on a Mac we may close all the windows but not quit, so
// ensure that we do actually quit. For Windows, if we don't quit,
// Firefox will crash. So, whatever the case may be, if that's the last
Expand All @@ -160,22 +168,14 @@ FirefoxDriver.prototype.close = function(respond) {

// Use an nsITimer to give the response time to go out.
var event = function(timer) {
appService.quit(forceQuit);
appService.quit(forceQuit);
};

FirefoxDriver.nstimer = new fxdriver.Timer();
FirefoxDriver.nstimer.setTimeout(event, 500);
return; // The client should catch the fact that the socket suddenly closes
}

// Here we go!
try {
var browser = respond.session.getBrowser();
browser.contentWindow.close();
} catch (e) {
goog.log.warning(FirefoxDriver.LOG_, 'Error closing window', e);
}

// Send the response so the client doesn't get a connection refused socket
// error.
respond.send();
Expand Down

0 comments on commit 38d6934

Please sign in to comment.