If a test needs to interact with the Download Manager or simply has to handle a download of a given file, the DownloadsAPI can be used.
Class overview
| Class | Description | 
|---|---|
| downloadManager | This class supplies a full set of helper functions to provide access to any area of the download manager. | 
Method overview
| downloadFileOfUnknownType(in MozMillController controller, in string url) | 
| nsILocalFile getLocalFileFromNativePathOrUrl(in string aPathOrUrl) | 
Constants
downloadState constants
| Constant | Value | Description | 
|---|---|---|
| notStarted | -1 | Download state for uninitialized download object. | 
| downloading | 0 | Download is currently transferring data. | 
| finished | 1 | Download finished including any processing of the target file. | 
| failed | 2 | Transfer failed due to error. (completed) | 
| canceled | 3 | Download was canceled by the user. (completed) | 
| paused | 4 | Transfer was paused by the user. | 
| queued | 5 | Download is active but data has not yet been received. | 
| blockedParental | 6 | Transfer request was blocked by parental controls proxy. (completed) | 
| scanning | 7 | Transferred download is being scanned by virus scanners. | 
| dirty | 8 | A virus was detected in the download. The target will most likely no longer exist. (completed) | 
| blockedPolicy | 9 | Windows specific: Request was blocked by zone policy settings. (completed) | 
Methods
downloadFileOfUnknownType()
Until we are able to interact with the system level File Save dialog we can only use the helper application dialog to download a file of an unknown content type. This function will automatically download the given file specified by the URL to the current download folder.
downloadFileOfUnknownType( in MozMillController controller, in string url );
Parameters
- controller
- MozMillController of the browser window to work on.
- url
- URL of the file which has to be downloaded.
- aPathOrUrl
- Native path or URL of the file.
getLocalFileFromNativePathOrUrl()
When a test needs access to the real file object this function will return the nsILocalFile object from the given path or URL.
nsILocalFile getLocalFileFromNativePathOrUrl( in string aPathOrUrl );
Parameters
Return value
An nsILocalFile instance specifying the file.