Permalink
Browse files

run tests on travis-ci (based on mocha, chai, jpm & mozilla-download)

  • Loading branch information...
rpl committed Jul 27, 2015
1 parent 9a07969 commit f5982a82436fc6e3971a939c6db2c62e2a1731fe
Showing with 181 additions and 0 deletions.
  1. +4 −0 .gitignore
  2. +5 −0 .jpmignore
  3. +23 −0 .travis.yml
  4. +12 −0 .xpiignore
  5. +11 −0 bootstrap.js
  6. 0 index.js
  7. +24 −0 package.json
  8. +3 −0 test/fixtures/test-prefs.json
  9. +99 −0 test/test-repl.js
View
@@ -0,0 +1,4 @@
*~
*.xpi
node_modules/
tmp/
View
@@ -0,0 +1,5 @@
node_modules
test
package.json
README.md
tmp
View
@@ -0,0 +1,23 @@
sudo: false
language: node_js
node_js:
- "0.10"
before_install:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16 -extension RANDR"
- npm install -g npm
- npm --version
before_script:
- npm install
- npm install mozilla-download -g
- cd ..
- mozilla-download --branch FIREFOX_39_0 --product firefox $TRAVIS_BUILD_DIR/../
- cd $TRAVIS_BUILD_DIR
script:
- export JPM_FIREFOX_BINARY=$TRAVIS_BUILD_DIR/../firefox/firefox
- export FIREFOX_BIN=$JPM_FIREFOX_BINARY
- npm run test
View
@@ -0,0 +1,12 @@
.git/*
.*
*~
*.xpi
tmp/*
node_modules/*
test/*
npm-debug.log
README.md
package.json
index.js
bootstrap.js
View
@@ -0,0 +1,11 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { utils: Cu } = Components;
const rootURI = __SCRIPT_URI_SPEC__.replace("bootstrap.js", "");
const COMMONJS_URI = "resource://gre/modules/commonjs";
const { require } = Cu.import(COMMONJS_URI + "/toolkit/require.js", {});
const { Bootstrap } = require(COMMONJS_URI + "/sdk/addon/bootstrap.js");
const { startup, shutdown, install, uninstall } = new Bootstrap(rootURI);
View
No changes.
View
@@ -0,0 +1,24 @@
{
"name": "mozrepl",
"title": "MozRepl",
"id": "mozrepl@hyperstruct.net",
"description": "Interactive console for Mozilla applications",
"version": "1.1.2",
"author": "Massimiliano Mirra <bard@hyperstruct.net>",
"contributors": [
"Luca Greco <luca.greco@alcacoop.it>"
],
"engines": {
"firefox": ">=36 <=*"
},
"scripts": {
"xpi": "zip -r mozrepl.xpi . --exclude @.xpiignore",
"test": "mocha test"
},
"devDependencies": {
"chai": "^3.2.0",
"jpm": "^1.0.0",
"mocha": "^2.2.5",
"mozfee": "^0.1.5"
}
}
@@ -0,0 +1,3 @@
{
"extensions.mozrepl.autoStart": true
}
View
@@ -0,0 +1,99 @@
var expect = require("chai").expect;
require('mozfee/node_modules/coffee-script');
var Mozrepl = require('mozfee/lib/mozrepl').Mozrepl;
var jpm_utils = require("jpm/lib/utils");
var jpm_run = require("jpm/lib/run");
var path = require("path");
var mozrepl;
var manifest = jpm_utils.getManifest();
jpm_run(manifest, {
verbose: process.env.VERBOSE,
prefs: "./test/fixtures/test-prefs.json",
binary: process.env.FIREFOX_BIN || "/usr/bin/firefox"
});
beforeEach(function(done) {
this.timeout(20000);
mozrepl = new Mozrepl();
var retries = 3;
var retry_interval = 2000;
function retry() {
mozrepl.connect();
}
mozrepl.on("connect", done);
mozrepl.on("error", function() {
if (retries > 0) {
console.log("RETRY");
retries -= 1;
setTimeout(retry, retry_interval);
} else {
throw Error("Error connecting to mozrepl");
}
});
retry();
});
afterEach(function () {
mozrepl.close();
});
describe("repl API", function() {
describe("browser privileged context", function () {
it("should be connected", function(done) {
mozrepl.eval("'hello' + 'world'", function (err, result) {
expect(result).to.be.equal('"helloworld"');
done();
});
});
describe("repl.whereAmI", function() {
it("should work correctly in a ChromeWindow", function(done) {
mozrepl.eval(mozrepl.repl_name + ".whereAmI()", function (err, result) {
expect(err).to.not.exist;
expect(result.indexOf("[object ChromeWindow] - Document title: \"") == 0).to.be.true;
done();
});
})
});
});
describe("content privileged context", function () {
beforeEach(function (done) {
mozrepl.eval(mozrepl.repl_name + ".enter(content)", function (err, result) {
expect(err).to.not.exist;
done();
});
});
it("should be working correctly in content", function(done) {
mozrepl.eval("'hello' + 'world'", function (err, result) {
expect(result).to.be.equal('"helloworld"');
done();
});
});
describe("repl.whereAmI", function() {
it("should work correctly in a DOM Window", function(done) {
mozrepl.eval(mozrepl.repl_name + ".whereAmI()", function (err, result) {
expect(err).to.not.exist;
expect(result.trim()).to.be.equal("[object Window]");
done();
});
})
});
});
});

0 comments on commit f5982a8

Please sign in to comment.