third_party/js/mozmill/shared-modules/downloads.js
function downloadManager_waitForDownloadState(download, state, timeout) {
    this._controller.waitForEval("subject.manager.getDownloadState(subject.download) == subject.state", timeout, 100,
                                 {manager: this, download: download, state: state});
  }
function downloadManager_waitForDownloadState(download, state, timeout) {
    this._controller.waitForEval("subject.manager.getDownloadState(subject.download) == subject.state", timeout, 100,
                                 {manager: this, download: download, state: state});
  }
function downloadManager_waitForDownloadState ( download , state , timeout ) { this . _controller . waitForEval ( "subject.manager.getDownloadState(subject.download) == subject.state" , timeout , 100 , { manager : this , download : download , state : state } ) ; }
Wait for the given download state

@param {MozMillController} controller
MozMillController of the window to operate on
@param {downloadState} state
Expected state of the download
@param {number} timeout
Timeout for waiting for the download state (optional)
Wait for the given download state