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.

before_script:
- npm install
- npm install -g jpm
- npm install -g mozilla-download

The script section, instead, will look like this:

script:
- 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
node_js:
  - "0.12"
env:
  global:
  - DISPLAY=:99.0
  - JPM_FIREFOX_BINARY=firefox
  - TMP_DIR=/tmp
before_install:
- sh -e /etc/init.d/xvfb start
before_script:
- npm install
- npm install -g jpm
- npm install -g mozilla-download
- pwd
- cd $TMP_DIR
- mozilla-download --branch mozilla-central --product firefox $TMP_DIR
- cd $TRAVIS_BUILD_DIR
- export JPM_FIREFOX_BINARY=$TMP_DIR/firefox/firefox
script:
- jpm test -v -b $JPM_FIREFOX_BINARY
notifications:
  email:
    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.

Posted by: Raffaele Spinelli | September 8, 2015

Developing and testing Mozilla Add-on – part 1

Developing add-on for Mozilla is quite easy but testing every single changes made to the code can became tedious.

The usual process would be:

  • made a change
  • create the xpi
  • load Firefox
  • install the add-on in Firefox
  • test it

Have you ever wondered if you can simplify this process? The answer is “Yes! Of course.”
The idea is to automate the packaging and the installation of the add-on at every change it’s made.

Firstly, we need to know a little more about the Mozilla add-on SDK and its tool.
The latest tool made available by Mozilla to develop add-on is called jpm and it shows a very interesting command

– watchpost: It create a new xpi everytime a change is made to the add-on files and post the fresh xpi to a specified URL. More details can be found on Mozilla jpm page.

FUrther, thanks to Wladimir Palant, we can use an add-on that can help us to simplify this process.  It allows you to install/update an add-on by command line, using web-socket.
Download and install this add-on, you can find more information about the configuration here.

Now that we have a convenient way of installing/upgrading an add-on, we can take advantage of the jpm `watchpost` command.
We can now simply run the following command in our add-on directory:

jpm watchpost –post-url http://localhost:8888/

You can see a simple log for this command on my machine:

JPM [info] Starting jpm watchpost on <ADD-ON NAME>
Creating XPI
JPM [info] XPI created at <XPI-PATH> (249ms)
Created XPI at<XPI-PATH>
Successfully created xpi at<XPI-PATH>
Posted XPI to http://localhost:8888/
Removed XPI from<XPI-PATH>

Our process to test the add-on now is:

  • load Firefox
  • made a change to our add-on (the watchpost command will take care to upload the add-on to Firefox)
  • test it

I hope this can be useful, please feel free to contribute.
Next part will be about CI in add-on development using travis and github.

Posted by: Raffaele Spinelli | April 24, 2014

Studying GraphWalker

Last week, I decide it was time to change my way of testing Web Applications. Recently, I have heard of graphwalker, that seems to be a powerful tool so I decide to give it a try.
I really like to always have the latest version, so I checkout the latest version of code from their server.

git clone https://github.com/KristianKarl/GraphWalker-Examples

But Maven fails to build the project when I run mvn test.
The error is raised because of a missing jar:

If you incur in this error, you just have to fire up your preferred editor and edit the pom file.
Just add these repository to download the missing jar.


<repositories>
   <repository>
      <id>repository-for-graphwalker</id>
      <url>https://oss.sonatype.org/content/repositories/snapshots/ </url>
   </repository>
</repositories>

Rerun Maven and everything should be fine.
A modified version containing the repository is available here: pom.xml
Next weekend I’ll try to write down some example too.

Categories

Follow

Get every new post delivered to your Inbox.