Skip to content

Commit

Permalink
feat: Allow custom browser names
Browse files Browse the repository at this point in the history
Enable feature for defining custom browser names in `customLaunchers`
and  for manual testing.
  • Loading branch information
Christian Budde Christensen committed Jan 14, 2016
1 parent 81a388a commit 60ba85f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
10 changes: 7 additions & 3 deletions client/karma.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var Karma = function (socket, iframe, opener, navigator, location) {
var self = this
var queryParams = util.parseQueryParams(location.search)
var browserId = queryParams.id || util.generateId('manual-')
var displayName = queryParams.displayName
var returnUrl = queryParams['return_url' + ''] || null

var resultsBufferLimit = 50
Expand Down Expand Up @@ -233,11 +234,14 @@ var Karma = function (socket, iframe, opener, navigator, location) {
socket.io.engine.on('upgrade', function () {
resultsBufferLimit = 1
})

socket.emit('register', {
var info = {
name: navigator.userAgent,
id: browserId
})
}
if (displayName) {
info.displayName = displayName
}
socket.emit('register', info)
})
}

Expand Down
6 changes: 5 additions & 1 deletion lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,11 @@ var normalizeConfig = function (config, configFilePath) {
}

module[type + ':' + name] = ['factory', function (injector) {
return injector.createChild([locals], [token]).get(token)
var plugin = injector.createChild([locals], [token]).get(token)
if (type === 'launcher' && helper.isDefined(definition.displayName)) {
plugin.displayName = definition.displayName
}
return plugin
}]
hasSomeInlinedPlugin = true
})
Expand Down
3 changes: 2 additions & 1 deletion lib/launcher.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var Promise = require('bluebird')
var Batch = require('batch')

var helper = require('./helper')
var log = require('./logger').create('launcher')

var baseDecorator = require('./launchers/base').decoratorFactory
Expand Down Expand Up @@ -88,7 +89,7 @@ var Launcher = function (emitter, injector) {
}

batch.push(function (done) {
log.info('Starting browser %s', browser.name)
log.info('Starting browser %s', helper.isDefined(browser.displayName) ? browser.displayName : browser.name)

browser.start(url)
browser.on('browser_process_failure', function () {
Expand Down
3 changes: 2 additions & 1 deletion lib/launchers/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var EventEmitter = require('events').EventEmitter
var Promise = require('bluebird')

var log = require('../logger').create('launcher')
var helper = require('../helper')

var BEING_CAPTURED = 1
var CAPTURED = 2
Expand Down Expand Up @@ -38,7 +39,7 @@ var BaseLauncher = function (id, emitter) {

this.error = null
this.state = BEING_CAPTURED
this.emit('start', url + '?id=' + this.id)
this.emit('start', url + '?id=' + this.id + (helper.isDefined(self.displayName) ? '&displayName=' + encodeURIComponent(self.displayName) : ''))
}

this.kill = function () {
Expand Down
2 changes: 1 addition & 1 deletion lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ Server.prototype._start = function (config, launcher, preprocess, fileList, webS
} else {
newBrowser = self._injector.createChild([{
id: ['value', info.id || null],
fullName: ['value', info.name],
fullName: ['value', (helper.isDefined(info.displayName) ? info.displayName : info.name)],
socket: ['value', socket]
}]).instantiate(Browser)

Expand Down

0 comments on commit 60ba85f

Please sign in to comment.