Skip to content

Commit

Permalink
fix: support reconnecting for manually captured browsers
Browse files Browse the repository at this point in the history
Add "launchdId" (id) to manually captured browsers.

This also changes the browser id to be a string rather than a number.
  • Loading branch information
vojtajina committed Aug 26, 2013
1 parent 830ce34 commit a8ac6d2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/launcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ var Launcher = function(emitter, injector) {
Launcher.$inject = ['emitter', 'injector'];

Launcher.generateId = function() {
return Math.floor(Math.random() * 100000000);
return '' + Math.floor(Math.random() * 100000000);
};


Expand Down
4 changes: 3 additions & 1 deletion static/karma.src.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ var Karma = function(socket, context, navigator, location) {
var hasError = false;
var store = {};
var self = this;
var browserId = (location.search.match(/\?id=(.*)/) || [])[1] ||
'manual-' + Math.floor(Math.random() * 10000);

var resultsBufferLimit = 1;
var resultsBuffer = [];
Expand Down Expand Up @@ -281,7 +283,7 @@ var Karma = function(socket, context, navigator, location) {

socket.emit('register', {
name: navigator.userAgent,
id: parseInt((location.search.match(/\?id=(.*)/) || [])[1], 10) || null
id: browserId
});
});
};
7 changes: 5 additions & 2 deletions test/client/karma.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,14 @@ describe('karma', function() {


it('should report browser id', function() {
windowLocation.search = '?id=567';
socket = new MockSocket();
k = new Karma(socket, {}, windowNavigator, windowLocation);

var spyInfo = jasmine.createSpy('onInfo').andCallFake(function(info) {
expect(info.id).toBe(567);
expect(info.id).toBe('567');
});

windowLocation.search = '?id=567';
socket.on('register', spyInfo);
socket.emit('connect');

Expand Down

0 comments on commit a8ac6d2

Please sign in to comment.