@@ -12,6 +12,7 @@ var Karma = function(socket, context, navigator, location) {
12
12
var queryParams = util . parseQueryParams ( location . search ) ;
13
13
var browserId = queryParams . id || util . generateId ( 'manual-' ) ;
14
14
var returnUrl = queryParams . return_url || null ;
15
+ var currentTransport ;
15
16
16
17
var resultsBufferLimit = 1 ;
17
18
var resultsBuffer = [ ] ;
@@ -129,11 +130,15 @@ var Karma = function(socket, context, navigator, location) {
129
130
// tests could run in the same event loop, we wouldn't notice.
130
131
setTimeout ( function ( ) {
131
132
socket . emit ( 'complete' , result || { } ) ;
133
+ clearContext ( ) ;
134
+
135
+ // Redirect to the return_url, however we need to give the browser some time,
136
+ // so that all the messages are sent.
137
+ // TODO(vojta): can we rather get notification from socket.io?
132
138
if ( returnUrl ) {
133
- socket . disconnect ( ) ;
134
- location . href = returnUrl ;
135
- } else {
136
- clearContext ( ) ;
139
+ setTimeout ( function ( ) {
140
+ location . href = returnUrl ;
141
+ } , ( currentTransport === 'websocket' || currentTransport === 'flashsocket' ) ? 0 : 3000 ) ;
137
142
}
138
143
} , 0 ) ;
139
144
} ;
@@ -197,10 +202,10 @@ var Karma = function(socket, context, navigator, location) {
197
202
198
203
// report browser name, id
199
204
socket . on ( 'connect' , function ( ) {
200
- var transport = socket . socket . transport . name ;
205
+ currentTransport = socket . socket . transport . name ;
201
206
202
207
// TODO(vojta): make resultsBufferLimit configurable
203
- if ( transport === 'websocket' || transport === 'flashsocket' ) {
208
+ if ( currentTransport === 'websocket' || currentTransport === 'flashsocket' ) {
204
209
resultsBufferLimit = 1 ;
205
210
} else {
206
211
resultsBufferLimit = 50 ;
0 commit comments