[shared module] Need a way to cancel all active downloads (DownloadsAPI)

RESOLVED FIXED

Status

RESOLVED FIXED
9 years ago
8 years ago

People

(Reporter: ashughes, Assigned: ashughes)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [mozmill-doc-complete])

Attachments

(2 attachments)

(Assignee)

Description

9 years ago
In the DownloadsAPI, we do not have a way to cancel active downloads.  cleanUp() only acts on inactive downloads and deleteDownloadedFiles() only acts on files.
Currently, there is no method for canceling a download.  This should be integrated into our cleanUp() process as just doing delete and cleanup in teardownModule will result in a single active download remaining.

Naturally, I have a fix for this.  I'll post a minimized test case and a patch shortly.
(Assignee)

Comment 1

9 years ago
Created attachment 418697 [details]
Minimized test case

Here is a "minimized" test case.  I say that in quotes because it includes a few methods copied from the DownloadsAPI.  This way you can just copy and paste into the Mozmill IDE and run it (no importing of modules necessary).

I left out dm.close() from this test so you can see the state of the Download Manager prior to closing.  As you can see, the download is still active because it was never canceled, and active downloads are not taken care of with dm.cleanUp() -- clearly stated in the nsIDownloadManager API: https://developer.mozilla.org/en/NsIDownloadManager#cleanUp.28.29
(Assignee)

Comment 2

9 years ago
Created attachment 418701 [details] [diff] [review]
Initial Patch

Here is the patch to add a cancelActiveDownloads() method to the DownloadsAPI.  I suggest a follow up patch to this to possibly call this method from within the dm.cleanUp() method.
Assignee: nobody → anthony.s.hughes
Status: NEW → ASSIGNED
Attachment #418701 - Flags: review?(hskupin)
(Assignee)

Comment 3

9 years ago
A quick reminder for myself...I'll add API documentation for this method if/when the patch is checked in.
(Assignee)

Updated

9 years ago
Blocks: 524827
Attachment #418701 - Flags: review?(hskupin) → review+
Comment on attachment 418701 [details] [diff] [review]
Initial Patch

Looks good so far. I will just make two little changes here. We can use Ci instead of Components.interfaces and a better variable name would be nice. Checkin upcoming.
Comment on attachment 418701 [details] [diff] [review]
Initial Patch

>+  var enum = this._dms.activeDownloads;

Oh, and enum should not be used.
Landed as:
http://hg.mozilla.org/qa/mozmill-tests/rev/35d158df548e
http://hg.mozilla.org/qa/mozmill-tests/rev/eaf4af799781
Status: ASSIGNED → RESOLVED
Last Resolved: 9 years ago
Resolution: --- → FIXED
Whiteboard: [mozmill-doc-needed]
Docs are complete:
https://developer.mozilla.org/en/Mozmill_Tests/Shared_Modules/DownloadsAPI/downloadManager
Summary: Need a way to cancel all active downloads → [shared module] Need a way to cancel all active downloads (DownloadsAPI)
Whiteboard: [mozmill-doc-needed] → [mozmill-doc-complete]
Mass move of Mozmill Test related project bugs to newly created components. You can filter out those emails by using "Mozmill-Tests-to-MozillaQA" as criteria.
Component: Mozmill → Mozmill Tests
Product: Testing → Mozilla QA
QA Contact: mozmill → mozmill-tests
You need to log in before you can comment on or make changes to this bug.