Shared Modules

While creating Mozmill tests for a given user interface the same elements have to be accessed probably over and over again, mostly in the same order. To make it easier to work with those elements and to reply a path of events, shared modules have been implemented which contain helper classes and helper functions with a focus to such an user interface. Some of them are special for Firefox while others can also be used in other applications which are based on the Gecko platform.

Shared modules are part of our Mozmill test repository for Firefox. They are still under permanent development. To stay on top of the development process and always use the latest revision the repository should be cloned to the local disk.  After cloning, be sure to read about the proper handling of branches to make sure that you are working with the shared modules that match the version of Firefox you are testing against.

List of available Shared Modules

The shared modules listed below are part of the mozmill-test repository and can be used in any test:

Shared Module Description
AddonsAPI Handling the Addons Manager.
DomUtilsAPI Several helper functions to work with the DOM.
DownloadsAPI Handling the Download Manager and other download related functions.
LocalizationAPI Handling the L10n related functions.
ModalDialogAPI Handling of modal dialogs.
PlacesAPI Places related helper functions.
PrefsAPI Handling the preferences dialog and the preferences system.
PrivateBrowsingAPI Handling the Private Browsing mode.
ScreenshotAPI Functions for taking screenshots.
SearchAPI Handling the Search Engine Manager and search related functions.
SessionStoreAPI Handling the Session Store elements and features 
SoftwareUpdateAPI Handling the Software Update dialog and the complete update process.
TabbedBrowsingAPI Handling the interaction with tab elements.
ToolbarAPI Handling the interaction with toolbar elements.
UtilsAPI Several helper functions which don't fit into the other categories.

How to use a Shared Module

If a test has to be implemented which could take advantage of an already existing shared module, the module has to be included. Therefor the RELATIVE_ROOT folder which contains the shared modules has to be specified. The collector of Mozmill will search recursively in this folder and all its sub-folders for available modules. To access the helper classes and functions of a special module its name has to be added to the local scope of the test. This is done by adding it to the MODULE_REQUIRES array.

The following example demonstrates the usage of the closeAllTabs function which is part of the TabbedBrowsingAPI. 

// Include required modules
var tabs = require("../../lib/tabs");

function setupModule(module) {
  module.controller = mozmill.getBrowserController();

function testCloseAllTabs() {

How to create a Shared Module

A module looks similar to any other Mozmill test, but contains an API for a specific component of Firefox.

 * Close all tabs and open about:blank
 * @param {MozMillController} controller
 *        MozMillController of the window to operate on
function closeAllTabs(controller) {
  var browser = new tabBrowser(controller);

 * Constructor
function TabBrowser() {

 * Class definition
var TabBrowser = {

// Export of functions
exports.closeAllTabs = closeAllTabs;

// Export of classes
exports.TabBrowser = TabBrowser;

Sometimes there are needs to use other modules directly from within a module. In such a situation simply include those modules.

// Include required modules
var tabs = require("tabs");

function prepare(controller) {

Document Tags and Contributors

 Last updated by: Whimboo,