diff --git a/.travis.yml b/.travis.yml index 74e660e..5f135e2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,15 @@ sudo: false language: node_js +env: + global: + - DISPLAY=":99.0" + - DEBUG=launchpad:* before_install: - - "export DISPLAY=:99.0" - "sh -e /etc/init.d/xvfb start" node_js: + - "6" + - "5" + - "4" + - "0.12" - "0.11" - "0.10" diff --git a/lib/local/instance.js b/lib/local/instance.js index e138e86..0a17de7 100644 --- a/lib/local/instance.js +++ b/lib/local/instance.js @@ -7,10 +7,10 @@ var debug = require('debug')('launchpad:local:instance'); var getProcessId = function (name, callback) { var commands = { - darwin: "ps -clx | grep '" + name + "$' | awk '{print $2}' | head -1", - linux: "ps -ax | grep '" + name + "$' | awk '{print $2}' | head -1", - freebsd: "ps -clx | grep '" + name + "$' | awk '{print $2}' | head -1", - sunos: "ps -ax | grep '" + name + "$' | awk '{print $2}' | head -1" // Don't actually know about this + darwin: "ps -clx | grep -P '" + name + "$' | awk '{print $2}' | head -1", + linux: "ps -ax | grep -P '" + name + "$' | awk '{print $1}' | head -1", + freebsd: "ps -clx | grep -P '" + name + "$' | awk '{print $2}' | head -1", + sunos: "ps -ax | grep -P '" + name + "$' | awk '{print $1}' | head -1" // Don't actually know about this }; // Get the process with the given name if it is running diff --git a/lib/local/platform/unix.js b/lib/local/platform/unix.js index 13e0f58..bd49c89 100644 --- a/lib/local/platform/unix.js +++ b/lib/local/platform/unix.js @@ -2,8 +2,8 @@ var path = require('path'); module.exports = { chrome: { - pathQuery: 'which google-chrome', - process: 'chrome', + pathQuery: 'which chromium-browser chromium google-chrome google-chrome-stable || true', + process: 'chrom(e|ium( --(?!type)[^=]+=[^ ]+)*)', opensTab: true, args: ['--no-first-run'] }, diff --git a/test/local.js b/test/local.js index a3cd22b..055dd3e 100644 --- a/test/local.js +++ b/test/local.js @@ -42,13 +42,19 @@ describe('Local browser launcher tests', function() { return done(); } - server.once('request', function (req) { - var userAgent = useragent.parse(req.headers['user-agent']); - var expected = familyMapping[name] || name; + function request(req) { + if (req.url === '/') { + var userAgent = useragent.parse(req.headers['user-agent']); + var expected = familyMapping[name] || name; - assert.equal(userAgent.family.toLowerCase(), expected, 'Got expected browser family'); - instance.stop(done); - }); + assert.equal(userAgent.family.toLowerCase(), expected, 'Got expected browser family'); + instance.stop(done); + } else { + server.once('request', request); + } + } + + server.once('request', request); }); }); }); @@ -70,8 +76,8 @@ describe('Local browser launcher tests', function() { local(function (error, launcher) { launcher.browsers(function (error, browsers) { assert.ok(!error, 'No error discovering browsers'); - assert.ok(browsers.length == 1, 'Found PhantomJS browser'); - assert.ok(browsers[0].path == process.env.LAUNCHPAD_PHANTOM, 'Found PhantomJS at selected location'); + assert.equal(browsers.length, 1, 'Found PhantomJS browser'); + assert.equal(browsers[0].path, process.env.LAUNCHPAD_PHANTOM, 'Found PhantomJS at selected location'); done(); }); });