Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add path query for chromium #62

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
9 changes: 8 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -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"
8 changes: 4 additions & 4 deletions lib/local/instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/local/platform/unix.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']
},
Expand Down
22 changes: 14 additions & 8 deletions test/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});
Expand All @@ -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();
});
});
Expand Down