mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 863063: quitting private browsing mode does not delete partially downloaded files, r=mak
This commit is contained in:
parent
c2a5090d51
commit
a10749e8ff
@ -231,7 +231,7 @@ nsDownloadManager::RemoveAllDownloads(nsCOMArray<nsDownload>& aDownloads)
|
||||
nsRefPtr<nsDownload> dl = aDownloads[0];
|
||||
|
||||
nsresult result = NS_OK;
|
||||
if (dl->IsPaused() && GetQuitBehavior() != QUIT_AND_CANCEL)
|
||||
if (!dl->mPrivate && dl->IsPaused() && GetQuitBehavior() != QUIT_AND_CANCEL)
|
||||
aDownloads.RemoveObject(dl);
|
||||
else
|
||||
result = dl->Cancel();
|
||||
@ -2418,7 +2418,6 @@ nsDownloadManager::Observe(nsISupports *aSubject,
|
||||
// Upon leaving private browsing mode, cancel all private downloads,
|
||||
// remove all trace of them, and then blow away the private database
|
||||
// and recreate a blank one.
|
||||
PauseAllDownloads(mCurrentPrivateDownloads, true);
|
||||
RemoveAllDownloads(mCurrentPrivateDownloads);
|
||||
InitPrivateDB();
|
||||
} else if (strcmp(aTopic, "last-pb-context-exiting") == 0) {
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
/**
|
||||
Make sure that the download manager service is given a chance to cancel the
|
||||
private browisng mode transition.
|
||||
private browsing mode transition.
|
||||
**/
|
||||
|
||||
const Cm = Components.manager;
|
||||
@ -78,9 +78,9 @@ function trigger_pb_cleanup(expected)
|
||||
|
||||
function run_test() {
|
||||
function finishTest() {
|
||||
// Cancel Download-E
|
||||
dlF.cancel();
|
||||
dlF.remove();
|
||||
// Cancel Download-G
|
||||
dlG.cancel();
|
||||
dlG.remove();
|
||||
dm.cleanUp();
|
||||
dm.cleanUpPrivate();
|
||||
do_check_eq(dm.activeDownloadCount, 0);
|
||||
@ -161,11 +161,11 @@ function run_test() {
|
||||
trigger_pb_cleanup(false);
|
||||
do_check_true(promptService.wasCalled());
|
||||
do_check_eq(dm.activePrivateDownloadCount, 0);
|
||||
do_check_eq(dlE.state, dm.DOWNLOAD_PAUSED);
|
||||
do_check_eq(dlE.state, dm.DOWNLOAD_CANCELED);
|
||||
|
||||
// Create Download-F
|
||||
dlF = addDownload({
|
||||
isPrivate: false,
|
||||
isPrivate: true,
|
||||
targetFile: fileF,
|
||||
sourceURI: downloadFSource,
|
||||
downloadName: downloadFName
|
||||
@ -173,17 +173,42 @@ function run_test() {
|
||||
|
||||
// Wait for Download-F to start
|
||||
} else if (aDownload.targetFile.equals(dlF.targetFile)) {
|
||||
// Sanity check: Download-F must not be resumable
|
||||
do_check_false(dlF.resumable);
|
||||
// Sanity check: Download-F must be resumable
|
||||
do_check_true(dlF.resumable);
|
||||
dlF.pause();
|
||||
|
||||
} else if (aDownload.targetFile.equals(dlG.targetFile)) {
|
||||
// Sanity check: Download-G must not be resumable
|
||||
do_check_false(dlG.resumable);
|
||||
|
||||
promptService.sayCancel();
|
||||
trigger_pb_cleanup(false);
|
||||
do_check_false(promptService.wasCalled());
|
||||
do_check_eq(dm.activeDownloadCount, 1);
|
||||
do_check_eq(dlF.state, dm.DOWNLOAD_DOWNLOADING);
|
||||
do_check_eq(dlG.state, dm.DOWNLOAD_DOWNLOADING);
|
||||
finishTest();
|
||||
}
|
||||
break;
|
||||
|
||||
case dm.DOWNLOAD_PAUSED:
|
||||
if (aDownload.targetFile.equals(dlF.targetFile)) {
|
||||
promptService.sayProceed();
|
||||
trigger_pb_cleanup(false);
|
||||
do_check_true(promptService.wasCalled());
|
||||
do_check_eq(dm.activePrivateDownloadCount, 0);
|
||||
do_check_eq(dlF.state, dm.DOWNLOAD_CANCELED);
|
||||
|
||||
// Create Download-G
|
||||
dlG = addDownload({
|
||||
isPrivate: false,
|
||||
targetFile: fileG,
|
||||
sourceURI: downloadGSource,
|
||||
downloadName: downloadGName
|
||||
});
|
||||
|
||||
// Wait for Download-G to start
|
||||
}
|
||||
break;
|
||||
}
|
||||
},
|
||||
onStateChange: function(a, b, c, d, e) { },
|
||||
@ -204,10 +229,15 @@ function run_test() {
|
||||
const downloadEName = "download-E";
|
||||
|
||||
// properties of Download-F
|
||||
const downloadFSource = "http://localhost:4444/noresume";
|
||||
const downloadFSource = "http://localhost:4444/file/head_download_manager.js";
|
||||
const downloadFDest = "download-file-F";
|
||||
const downloadFName = "download-F";
|
||||
|
||||
// properties of Download-G
|
||||
const downloadGSource = "http://localhost:4444/noresume";
|
||||
const downloadGDest = "download-file-G";
|
||||
const downloadGName = "download-G";
|
||||
|
||||
// Create all target files
|
||||
let fileD = tmpDir.clone();
|
||||
fileD.append(downloadDDest);
|
||||
@ -218,6 +248,9 @@ function run_test() {
|
||||
let fileF = tmpDir.clone();
|
||||
fileF.append(downloadFDest);
|
||||
fileF.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
|
||||
let fileG = tmpDir.clone();
|
||||
fileG.append(downloadGDest);
|
||||
fileG.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
|
||||
|
||||
// Create Download-D
|
||||
let dlD = addDownload({
|
||||
@ -227,7 +260,7 @@ function run_test() {
|
||||
downloadName: downloadDName
|
||||
});
|
||||
|
||||
let dlE, dlF;
|
||||
let dlE, dlF, dlG;
|
||||
|
||||
// wait for Download-D to start
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user