Skip to content

Commit

Permalink
feat: support Firefox headless
Browse files Browse the repository at this point in the history
  • Loading branch information
keithamus committed Oct 4, 2017
1 parent 2143fd2 commit a1fc1c8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
30 changes: 29 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,22 @@ var getFirefoxWithFallbackOnOSX = function () {
}
}

var makeHeadlessVersion = function (Browser) {
var HeadlessBrowser = function () {
Browser.apply(this, arguments)
var execCommand = this._execCommand
this._execCommand = function (command, args) {
execCommand.call(this, command, args.concat('-headless'))
}
}

HeadlessBrowser.prototype = Object.create(Browser.prototype, {
name: { value: Browser.prototype.name + 'Headless' }
})
HeadlessBrowser.$inject = Browser.$inject
return HeadlessBrowser
}

// https://developer.mozilla.org/en-US/docs/Command_Line_Options
var FirefoxBrowser = function (id, baseBrowserDecorator, args) {
baseBrowserDecorator(this)
Expand Down Expand Up @@ -146,6 +162,8 @@ FirefoxBrowser.prototype = {

FirefoxBrowser.$inject = ['id', 'baseBrowserDecorator', 'args']

var FirefoxHeadlessBrowser = makeHeadlessVersion(FirefoxBrowser)

var FirefoxDeveloperBrowser = function () {
FirefoxBrowser.apply(this, arguments)
}
Expand All @@ -162,6 +180,8 @@ FirefoxDeveloperBrowser.prototype = {

FirefoxDeveloperBrowser.$inject = ['id', 'baseBrowserDecorator', 'args']

var FirefoxDeveloperHeadlessBrowser = makeHeadlessVersion(FirefoxDeveloperBrowser)

var FirefoxAuroraBrowser = function () {
FirefoxBrowser.apply(this, arguments)
}
Expand All @@ -178,6 +198,8 @@ FirefoxAuroraBrowser.prototype = {

FirefoxAuroraBrowser.$inject = ['id', 'baseBrowserDecorator', 'args']

var FirefoxAuroraHeadlessBrowser = makeHeadlessVersion(FirefoxAuroraBrowser)

var FirefoxNightlyBrowser = function () {
FirefoxBrowser.apply(this, arguments)
}
Expand All @@ -195,10 +217,16 @@ FirefoxNightlyBrowser.prototype = {

FirefoxNightlyBrowser.$inject = ['id', 'baseBrowserDecorator', 'args']

var FirefoxNightlyHeadlessBrowser = makeHeadlessVersion(FirefoxNightlyBrowser)

// PUBLISH DI MODULE
module.exports = {
'launcher:Firefox': ['type', FirefoxBrowser],
'launcher:FirefoxHeadless': ['type', FirefoxHeadlessBrowser],
'launcher:FirefoxDeveloper': ['type', FirefoxDeveloperBrowser],
'launcher:FirefoxDeveloperHeadless': ['type', FirefoxDeveloperHeadlessBrowser],
'launcher:FirefoxAurora': ['type', FirefoxAuroraBrowser],
'launcher:FirefoxNightly': ['type', FirefoxNightlyBrowser]
'launcher:FirefoxAuroraHeadless': ['type', FirefoxAuroraHeadlessBrowser],
'launcher:FirefoxNightly': ['type', FirefoxNightlyBrowser],
'launcher:FirefoxNightlyHeadless': ['type', FirefoxNightlyHeadlessBrowser]
}
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = function (config) {
colors: true,
logLevel: config.LOG_INFO,
autoWatch: false,
browsers: ['Firefox'],
browsers: ['Firefox', 'FirefoxHeadless'],
singleRun: false,
concurrency: Infinity,
plugins: [
Expand Down

0 comments on commit a1fc1c8

Please sign in to comment.