Support for extensions using XUL/XPCOM or the Add-on SDK was removed in Firefox 57, released November 2017. As there is no supported version of Firefox enabling these technologies, this page will be removed by December 2020.

Add-ons using the techniques described in this document are considered a legacy technology in Firefox. Don't use these techniques to develop new add-ons. Use WebExtensions instead. If you maintain an add-on which uses the techniques described here, consider migrating it to use WebExtensions.

Starting from Firefox 53, no new legacy add-ons will be accepted on addons.mozilla.org (AMO) for desktop Firefox and Firefox for Android.

Starting from Firefox 57, only extensions developed using WebExtensions APIs will be supported on Desktop Firefox and Firefox for Android.

Even before Firefox 57, changes coming up in the Firefox platform will break many legacy extensions. These changes include multiprocess Firefox (e10s), sandboxing, and multiple content processes. Legacy extensions that are affected by these changes should migrate to use WebExtensions APIs if they can. See the "Compatibility Milestones" document for more information.

A wiki page containing resources, migration paths, office hours, and more, is available to help developers transition to the new technologies.



A simple list-like class and utilities for using it.


A collection is ordered, like an array, but its items are unique, like a set.




Creates a new collection. The collection is backed by an array.


array : array
If array is given, it will be used as the backing array. This way the caller can fully control the collection. Otherwise a new empty array will be used, and no one but the collection will have access to it.


addCollectionProperty(object, propName, [backingArray])

Adds a collection property to the given object. Setting the property to a scalar value empties the collection and adds the value. Setting it to an array empties the collection and adds all the items in the array.


object : object
The property will be defined on this object.

propName : string
The name of the property.

backingArray : array
If given, this will be used as the collection's backing array.


A collection object provides for...in-loop iteration. Items are yielded in the order they were added. For example, the following code...

var collection = require("sdk/util/collection");
var c = new collection.Collection();
for (item in c)

... would print this to the console:


Iteration proceeds over a copy of the collection made before iteration begins, so it is safe to mutate the collection during iteration; doing so does not affect the results of the iteration.



Adds a single item or an array of items to the collection. Any items already contained in the collection are ignored.


itemOrItems : object
An item or array of items.


Collection : The Collection.


Removes a single item or an array of items from the collection. Any items not contained in the collection are ignored.


itemOrItems : object
An item or array of items.


Collection : The Collection.



The number of items in the collection array.

Document Tags and Contributors

Contributors to this page: rebloor, mdnwebdocs-bot, wbamberg, n8chz, jsantell
Last updated by: rebloor,