This article is in need of a technical review.

XPCShell tests are headless tests of Gecko XPCOM APIs. You can run XPCShell tests on B2G; in this article we will look at how to do so. Currently, these are mainly tested on the emulator, but should in theory run on devices as well.

Note: In this article $B2G_HOME refers to the cloned B2G repository.


  • You need to build B2G for the target you're testing (see: Building and installing Firefox OS).
  • You need to install some Python packages, either in a virtualenv or otherwise:
    pip install marionette_client
  • There's also a requirements.txt file that you should grab for convenience:
    wget people.mozilla.com/~ahalberstadt/runxpcshell-requirements.txt
    pip install -r runxpcshell-requirements.txt
  • Either make sure adb is on your path or specify it with --adbpath (on Linux it is found at $B2G_HOME/out/host/linux-x86/bin/adb.)
  • Have a local copy of Busybox (this isn't strictly necessary but greatly reduces the setup time required.)

Running the tests

You can then run xpcshell tests using one of the following sets of terminal commands:

If you are using an emulator:

cd $B2G_HOME/objdir-gecko
make package-tests
cd dist/test-package-stage/xpcshell
python runtestsb2g.py --b2gpath $B2G_HOME --adbpath $ADB_PATH --emulator arm --use-device-libs --manifest <path_to_xpcshell_manifest> --testing-modules-dir <path_to_testing_modules_dir> --busybox <path_to_busybox_binary>

If you are using a real device:

cd $B2G_HOME/objdir-gecko
make package-tests
cd dist/test-package-stage/xpcshell
python runtestsb2g.py --b2gpath $B2G_HOME --adbpath $ADB_PATH --use-device-libs --manifest <path_to_xpcshell_manifest> --testing-modules-dir <path_to_testing_modules_dir>

You can optionally add --total-chunks and --this-chunks arguments as you would with regular desktop xpcshell tests. Use:

python runtestsb2g.py --help

for a full list of supported arguments.

After you invoke runtestsb2g.py, the test runner will launch the emulator for you (if you're running the tests on an emulator) or reboot your device (if you're running the tests on a device), and start running the tests. Because the emulator is slow, and it is necessary to push a test profile to the emulator and restart B2G, the tests can take a few minutes to start. Before they start, you will just see a black or white screen. After they start, you should see the test log being dumped to the console.

When the tests are done, the emulator is shut down for you, or if you're using a device, the device is rebooted.

Installing busybox manually

When running xpcshell tests on devices there is no --busybox option, so setting up the test run can take a very long time. Fortunately you can still install it manually prior to running the tests. For an example of how to do this see https://github.com/mozilla/Negatus/blob/master/setup-tools.sh.

Running xpcshell tests with a downloaded emulator

If you've built B2G for another config (like otoro) and want to run the tests on an emulator, you can do so without building an emulator yourself.  Just download the latest trunk arm emulator, and use the same instructions as above, replacing the --b2gpath $B2G_HOME argument for runreftestb2g.py with --b2gpath /path/to/unpacked/emulator.

Document Tags and Contributors

Contributors to this page: Sheppy, chrisdavidmills, ethertank, ahal, kscarfone, mdas, teoli, gsvelto, Changbin
Last updated by: Changbin,
Hide Sidebar