Skip to content

Commit

Permalink
fix: reuse browser instance when restarting disconnected browser
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtajina committed Dec 3, 2013
1 parent 80637cd commit 1f1a8eb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,20 @@ var start = function(injector, config, launcher, globalEmitter, preprocess, file

socket.on('register', function(info) {
var newBrowser;
var isRestart;

if (info.id) {
newBrowser = capturedBrowsers.getById(info.id);
newBrowser = capturedBrowsers.getById(info.id) || singleRunBrowsers.getById(info.id);
}

if (newBrowser) {
isRestart = newBrowser.state === Browser.STATE_DISCONNECTED;
newBrowser.reconnect(socket);

// We are restarting a previously disconnected browser.
if (isRestart && config.singleRun) {
newBrowser.execute(config.client);
}
} else {
newBrowser = injector.createChild([{
id: ['value', info.id || null],
Expand Down

0 comments on commit 1f1a8eb

Please sign in to comment.