Closed
Bug 908246
Opened 11 years ago
Closed 11 years ago
Private downloads should be finalized when the last private browsing window is closed
Categories
(Toolkit :: Downloads API, defect)
Toolkit
Downloads API
Tracking
()
VERIFIED
FIXED
mozilla26
Tracking | Status | |
---|---|---|
firefox27 | --- | verified |
People
(Reporter: Paolo, Assigned: raymondlee)
References
Details
Attachments
(1 file, 3 obsolete files)
5.72 KB,
patch
|
Details | Diff | Splinter Review |
The list of private downloads should be cleared on the "last-pb-context-exited" notification. This includes in-progress downloads, since we already prompt before allowing private browsing mode to finish.
Assignee | ||
Updated•11 years ago
|
Assignee: nobody → raymond
Status: NEW → ASSIGNED
Assignee | ||
Comment 1•11 years ago
|
||
Attachment #800690 -
Flags: feedback?(paolo.mozmail)
Reporter | ||
Comment 2•11 years ago
|
||
Comment on attachment 800690 [details] [diff] [review] v1 Review of attachment 800690 [details] [diff] [review]: ----------------------------------------------------------------- ::: toolkit/components/jsdownloads/src/DownloadIntegration.jsm @@ +770,5 @@ > case "last-pb-context-exiting": > downloadsCount = this._privateInProgressDownloads.size; > this._confirmCancelDownloads(aSubject, downloadsCount, p, > p.ON_LEAVE_PRIVATE_BROWSING); > + if (aSubject.data) { You should just listen for "last-pb-context-exited", because other "last-pb-context-exiting" observers may cancel the operation and in this case we shouldn't cancel the downloads. @@ +773,5 @@ > p.ON_LEAVE_PRIVATE_BROWSING); > + if (aSubject.data) { > + Task.spawn(function() { > + let list = yield Downloads.getPrivateDownloadList(); > + list.removeAll(); I'd just inline this call for now, until we need a removeAll functionality elsewhere. Note that you should call "finalize" on the downloads in addition to removing them from the list.
Attachment #800690 -
Flags: feedback?(paolo.mozmail)
Assignee | ||
Comment 3•11 years ago
|
||
Attachment #800690 -
Attachment is obsolete: true
Attachment #801398 -
Flags: review?(paolo.mozmail)
Assignee | ||
Comment 4•11 years ago
|
||
The patch requires a method in the patch of bug 908240
Depends on: 908240
Reporter | ||
Comment 5•11 years ago
|
||
Comment on attachment 801398 [details] [diff] [review] v2 Review of attachment 801398 [details] [diff] [review]: ----------------------------------------------------------------- ::: toolkit/components/jsdownloads/src/DownloadIntegration.jsm @@ +776,5 @@ > + let list = yield Downloads.getPrivateDownloadList(); > + let downloads = yield list.getAll(); > + > + while (downloads.length > 0) { > + let download = downloads.splice(0, 1)[0]; You may use "for (let download of downloads)", the array is already a static snapshot. @@ +786,5 @@ > + > + // Handle test mode > + if (DownloadIntegration.testMode) { > + DownloadIntegration.testPromptDownloads = > + this._privateInProgressDownloads.size; I don't get why we are creating a Set here, leftover from a previous implementation? ::: toolkit/components/jsdownloads/test/unit/test_DownloadIntegration.js @@ +302,5 @@ > privateList.remove(download2); > }); > + > +/** > + * Tests both the downloads list and the in-progress downloads are clear nit: whitespace at end of line @@ +311,5 @@ > + enableObserversTestMode(); > + > + let privateList = yield promiseNewPrivateDownloadList(); > + let download1 = yield promiseNewDownload(httpUrl("interruptible.txt")); > + let download2 = yield promiseNewDownload(httpUrl("interruptible.txt")); You should use "interruptible.txt" together with mustInterruptResponses() only for the download that shouldn't complete, the other should be read from "source.txt". @@ +328,5 @@ > + // Simulate exiting the private browsing but not canceling the download. > + DownloadIntegration.testPromptDownloads = -1; > + let promoseObserved = promiseTopicObserved("last-pb-context-exited"); > + Services.obs.notifyObservers(null, "last-pb-context-exited", null); > + yield promoseObserved; Waiting for the notification won't guarantee that the removal task is completed. We should use our own test mode promise, resolved when the task completes, like we do in the "launch" test cases.
Attachment #801398 -
Flags: review?(paolo.mozmail)
Assignee | ||
Comment 6•11 years ago
|
||
(In reply to :Paolo Amadini from comment #5) > Comment on attachment 801398 [details] [diff] [review] > v2 > > Review of attachment 801398 [details] [diff] [review]: > ----------------------------------------------------------------- > > ::: toolkit/components/jsdownloads/src/DownloadIntegration.jsm > @@ +776,5 @@ > > + let list = yield Downloads.getPrivateDownloadList(); > > + let downloads = yield list.getAll(); > > + > > + while (downloads.length > 0) { > > + let download = downloads.splice(0, 1)[0]; > > You may use "for (let download of downloads)", the array is already a static > snapshot. Updated. > > @@ +786,5 @@ > > + > > + // Handle test mode > > + if (DownloadIntegration.testMode) { > > + DownloadIntegration.testPromptDownloads = > > + this._privateInProgressDownloads.size; > > I don't get why we are creating a Set here, leftover from a previous > implementation? > I have removed that. Since we use DownloadList.remove() to remove downloads from the list, this._privateInProgressDownloads would be updated by view.onDownloadRemoved() automatically. > ::: toolkit/components/jsdownloads/test/unit/test_DownloadIntegration.js > @@ +302,5 @@ > > privateList.remove(download2); > > }); > > + > > +/** > > + * Tests both the downloads list and the in-progress downloads are clear > > nit: whitespace at end of line > Updated. > @@ +311,5 @@ > > + enableObserversTestMode(); > > + > > + let privateList = yield promiseNewPrivateDownloadList(); > > + let download1 = yield promiseNewDownload(httpUrl("interruptible.txt")); > > + let download2 = yield promiseNewDownload(httpUrl("interruptible.txt")); > > You should use "interruptible.txt" together with mustInterruptResponses() > only for the download that shouldn't complete, the other should be read from > "source.txt". > Updated. > @@ +328,5 @@ > > + // Simulate exiting the private browsing but not canceling the download. > > + DownloadIntegration.testPromptDownloads = -1; > > + let promoseObserved = promiseTopicObserved("last-pb-context-exited"); > > + Services.obs.notifyObservers(null, "last-pb-context-exited", null); > > + yield promoseObserved; > > Waiting for the notification won't guarantee that the removal task is > completed. We should use our own test mode promise, resolved when the task > completes, like we do in the "launch" test cases. Updated.
Attachment #801398 -
Attachment is obsolete: true
Attachment #802129 -
Flags: review?(paolo.mozmail)
Reporter | ||
Comment 7•11 years ago
|
||
Comment on attachment 802129 [details] [diff] [review] v3 Review of attachment 802129 [details] [diff] [review]: ----------------------------------------------------------------- Looks good! Thank you for helping with fixing this bug. r+ with the following change: ::: toolkit/components/jsdownloads/src/DownloadIntegration.jsm @@ +824,5 @@ > + download.finalize(true).then(null, Cu.reportError); > + } > + }); > + deferred.then((value) => { DownloadIntegration._deferTestClearPrivateList.resolve("success"); }, > + (error) => { DownloadIntegration._deferTestClearPrivateList.reject(error); }); This should be done in test mode only, otherwise _deferTestClearPrivateList will be null.
Attachment #802129 -
Flags: review?(paolo.mozmail) → review+
Assignee | ||
Comment 8•11 years ago
|
||
Pushed to try and waiting for results https://tbpl.mozilla.org/?tree=Try&rev=d45acd4d3858
Attachment #802129 -
Attachment is obsolete: true
Assignee | ||
Comment 9•11 years ago
|
||
(In reply to Raymond Lee [:raymondlee] from comment #8) > Created attachment 802753 [details] [diff] [review] > bug-908246-v4.patch > > Pushed to try and waiting for results > https://tbpl.mozilla.org/?tree=Try&rev=d45acd4d3858 Passed Try!
Keywords: checkin-needed
Reporter | ||
Comment 10•11 years ago
|
||
https://hg.mozilla.org/integration/fx-team/rev/ed9f0499230d
Keywords: checkin-needed
Comment 11•11 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/ed9f0499230d
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla26
Updated•11 years ago
|
status-firefox27:
--- → fixed
Comment 12•11 years ago
|
||
I confirm the fix is verified on Latest Nightly 27 using Windows 7 x64 and Mac OS 10.8
Status: RESOLVED → VERIFIED
You need to log in
before you can comment on or make changes to this bug.
Description
•