Skip to content

Commit 38d6934

Browse files
committed
Legacy Firefox driver: Explicitly closing last window before quiting session. Fixes #2100
1 parent 036b959 commit 38d6934

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

javascript/firefox-driver/js/firefoxDriver.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,14 @@ FirefoxDriver.prototype.close = function(respond) {
151151
allWindows.getNext();
152152
}
153153

154+
// Here we go!
155+
try {
156+
var browser = respond.session.getBrowser();
157+
browser.contentWindow.close();
158+
} catch (e) {
159+
goog.log.warning(FirefoxDriver.LOG_, 'Error closing window', e);
160+
}
161+
154162
// If we're on a Mac we may close all the windows but not quit, so
155163
// ensure that we do actually quit. For Windows, if we don't quit,
156164
// Firefox will crash. So, whatever the case may be, if that's the last
@@ -160,22 +168,14 @@ FirefoxDriver.prototype.close = function(respond) {
160168

161169
// Use an nsITimer to give the response time to go out.
162170
var event = function(timer) {
163-
appService.quit(forceQuit);
171+
appService.quit(forceQuit);
164172
};
165173

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

171-
// Here we go!
172-
try {
173-
var browser = respond.session.getBrowser();
174-
browser.contentWindow.close();
175-
} catch (e) {
176-
goog.log.warning(FirefoxDriver.LOG_, 'Error closing window', e);
177-
}
178-
179179
// Send the response so the client doesn't get a connection refused socket
180180
// error.
181181
respond.send();

0 commit comments

Comments
 (0)