Skip to content

Commit

Permalink
fix(server): complete acknowledgment
Browse files Browse the repository at this point in the history
  • Loading branch information
bazilio91 committed Aug 28, 2014
1 parent 6ef74f2 commit f4144b0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
12 changes: 4 additions & 8 deletions client/karma.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,14 @@ var Karma = function(socket, iframe, opener, navigator, location) {
// give the browser some time to breath, there could be a page reload, but because a bunch of
// tests could run in the same event loop, we wouldn't notice.
setTimeout(function() {
socket.emit('complete', result || {});
clearContext();
}, 0);

// Redirect to the return_url, however we need to give the browser some time,
// so that all the messages are sent.
// TODO(vojta): can we rather get notification from socket.io?
socket.emit('complete', result || {}, function() {
if (returnUrl) {
setTimeout(function() {
location.href = returnUrl;
}, (currentTransport === 'websocket' || currentTransport === 'flashsocket') ? 0 : 3000);
location.href = returnUrl;
}
}, 0);
});
};

this.info = function(info) {
Expand Down
4 changes: 4 additions & 0 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ var start = function(injector, config, launcher, globalEmitter, preprocess, file

var replySocketEvents = events.bufferEvents(socket, EVENTS_TO_REPLY);

socket.on('complete', function(data, ack) {
ack();
});

socket.on('register', function(info) {
var newBrowser;
var isRestart;
Expand Down
9 changes: 8 additions & 1 deletion test/client/karma.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,15 @@ describe('Karma', function() {

spyOn(socket, 'disconnect');

socket.on('complete', function(data, ack) {
ack();
});

k.complete();
expect(windowLocation.href).toBe('http://return.com');

waitsFor(function(){
return windowLocation.href === 'http://return.com';
}, '', 9000);
});

it('should patch the console if captureConsole is true', function() {
Expand Down

0 comments on commit f4144b0

Please sign in to comment.