This class simplifies the access of the Download Manager window for Firefox.
Method overview
| downloadManager(); | 
| cancelActiveDownloads(); | 
| cleanAll(); | 
| cleanUp(); | 
| close(in boolean force); | 
| deleteDownloadedFiles(in array  | 
| array  getAllDownloads(); | 
| downloadState  getDownloadState(in ElemBase download); | 
| ElemBase getElement(in object spec); | 
| open(in  | 
| waitForDownloadState(in ElemBase download, in downloadState state, in number timeout); | 
| waitForOpened( | 
Attributes
| Attribute | Type | Description | 
|---|---|---|
| controller |  | Controller of the current Download Manager window | 
| activeDownloadCount | number | Count of currently active downloads. | 
Methods
downloadManager()
The constructor of the class.
downloadManager();
cancelActiveDownloads()
Cancel all active downloads.
cancelActiveDownloads();cleanAll()
Cancels any active downloads, removes any downloaded files, and cleans up the Download Manager database.
cleanAll();
cleanUp()
Remove all downloads from the database.
cleanUp();
close()
Close the Download Manager window.
close(in boolean force);Parameters
- force
- Force the closing of the DM window. When set to truethe window will be closed by callingwindow.close().
deleteDownloadedFiles()
Delete all the downloaded files from the local drive.
deleteDownloadedFiles(
in arraynsIDownloaddownloads
);
Parameters
- downloads
- List of nsIDownloadinstances
getAllDownloads()
Get the list of all downloaded files from the sqlite3 database.
arraynsIDownloadgetAllDownloads();
Return value
A list of nsIDownload instances 
getDownloadState()
Retrieves the download state of the given download.
downloadState getDownloadState(
in ElemBase download
);
Parameters
- download
- Download which state should be checked
Return value
The download state of the given download.
getElement()
Retrieve an UI element based on the given spec object.
ElemBase getElement(
  in object spec
);Parameters
- spec
- JSON object which specifies the element to retrieve. Use itsattributes to specify the exact element. This example will show the correct usage.
 spec.type ( string)
 spec.subtype ( string)spec.value ( mixed)Description "download"nodeName
 nodeValue (string)
 Get the download specified by any node of the richtlistbox entry. "download_button""cancel"
 Download (ElemBase)
 Get the cancel button of the specified download. "download_button""pause"Download (ElemBase)Get the pause button of the specified download. "download_button""resume"
 Download (ElemBase)Get the resume button of the specified download. "download_button""retry"
 Download (ElemBase)Get the retry button of the specified download. 
Return value
ElemBase instance of the requested element which matches the specifications.
open()
Open the Download Manager.
open(
  in MozMillController controller,
  in boolean shortcut
);Parameters
- controller
- MozMillController of the browser window to operate on
- shortcut
- If truethe keyboard shortcut is used to open the Download Manager window.
waitForDownloadState()
Waits until the given download has the expected download state or a timeout occurs.
getDownloadState(
in ElemBase download,
indownloadStatestate,
in number timeout
);
Parameters
- download
- Download which state should be checked
- state
- The download state to wait for.
- timeout
- (Optional) Maximal duration to wait before a timeout occurs.
Return value
None.
waitForOpened()
Wait until the Download Manager window has been opened.
waitForOpened(
  in MozMillController controller
);Parameters
- controller
- MozMillController of the Download Manager window to operate on.
Examples
In the example below the Download Manager gets opened by using the keyboard shortcut. Afterward the download with the specified URL is retrieved and used to get its resume button. With the click the download will be resumed. Finally the Download Manager gets closed again.
var RELATIVE_ROOT = '../../shared-modules';
var MODULE_REQUIRES = ['DownloadsAPI'];
var setupModule = function(module)
{
  module.controller = mozmill.getBrowserController();
  module.dm = new DownloadsAPI.downloadManager();
}
var testResumeDownload = function()
{
  dm.open(controller, true);
  var download = dm.getElement({type: "download", subtype: "uri", value: "http://www.mozilla.org/favicon.ico"});
  var resumeButton = dm.getElement({type: "download_button", subtype: "resume", value: download});
  controller.click(resumeButton);
  dm.close();
}