Posted by: Raffaele Spinelli | September 20, 2015

Developing and testing Mozilla Add-on – part 2

In this article we will see how we can use a CI infrastructure like Travis in our add-on development process.
Before you proceed you should get familiar with how Travis work. You can find the relevant documentation here.

Before we can run our script for testing, we need to setup Firefox.
We will use the before_script section to download and install Firefox. We will use npm.

- npm install
- npm install -g jpm
- npm install -g mozilla-download

The script section, instead, will look like this:

- jpm test -v
Unfortunately we need something more. We need to specify the path of the Firefox binary.
The whole travis.yml file will look like:
language: node_js
  - "0.12"
  - DISPLAY=:99.0
  - TMP_DIR=/tmp
- sh -e /etc/init.d/xvfb start
- npm install
- npm install -g jpm
- npm install -g mozilla-download
- pwd
- cd $TMP_DIR
- mozilla-download --branch mozilla-central --product firefox $TMP_DIR
- export JPM_FIREFOX_BINARY=$TMP_DIR/firefox/firefox
- jpm test -v -b $JPM_FIREFOX_BINARY
    on_failure: never

Some further details:

The env section define three variables:

  • DISPLAY for the X server
  • TMP_DIR the directory in which we download Firefox
  • JPM_FIREFOX_BINARY the Firefox binary command

The before_script will install the necessary tool to download Firefox, it will install it and set the ENV variable JPM_FIREFOX_BINARY to the right path.

Finally the script section can run the test:

jpm test -v -b $JPM_FIREFOX_BINARY

I hope this can be useful, please feel free to contribute.
More post about add-on development are coming. Stay tuned.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


%d bloggers like this: