зеркало из https://github.com/mozilla/gecko-dev.git
Bug 863063: quitting private browsing mode does not delete partially downloaded files, r=mak
This commit is contained in:
Родитель
323b7f4c12
Коммит
6f048316bf
|
@ -231,7 +231,7 @@ nsDownloadManager::RemoveAllDownloads(nsCOMArray<nsDownload>& aDownloads)
|
||||||
nsRefPtr<nsDownload> dl = aDownloads[0];
|
nsRefPtr<nsDownload> dl = aDownloads[0];
|
||||||
|
|
||||||
nsresult result = NS_OK;
|
nsresult result = NS_OK;
|
||||||
if (dl->IsPaused() && GetQuitBehavior() != QUIT_AND_CANCEL)
|
if (!dl->mPrivate && dl->IsPaused() && GetQuitBehavior() != QUIT_AND_CANCEL)
|
||||||
aDownloads.RemoveObject(dl);
|
aDownloads.RemoveObject(dl);
|
||||||
else
|
else
|
||||||
result = dl->Cancel();
|
result = dl->Cancel();
|
||||||
|
@ -2418,7 +2418,6 @@ nsDownloadManager::Observe(nsISupports *aSubject,
|
||||||
// Upon leaving private browsing mode, cancel all private downloads,
|
// Upon leaving private browsing mode, cancel all private downloads,
|
||||||
// remove all trace of them, and then blow away the private database
|
// remove all trace of them, and then blow away the private database
|
||||||
// and recreate a blank one.
|
// and recreate a blank one.
|
||||||
PauseAllDownloads(mCurrentPrivateDownloads, true);
|
|
||||||
RemoveAllDownloads(mCurrentPrivateDownloads);
|
RemoveAllDownloads(mCurrentPrivateDownloads);
|
||||||
InitPrivateDB();
|
InitPrivateDB();
|
||||||
} else if (strcmp(aTopic, "last-pb-context-exiting") == 0) {
|
} 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
|
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;
|
const Cm = Components.manager;
|
||||||
|
@ -78,9 +78,9 @@ function trigger_pb_cleanup(expected)
|
||||||
|
|
||||||
function run_test() {
|
function run_test() {
|
||||||
function finishTest() {
|
function finishTest() {
|
||||||
// Cancel Download-E
|
// Cancel Download-G
|
||||||
dlF.cancel();
|
dlG.cancel();
|
||||||
dlF.remove();
|
dlG.remove();
|
||||||
dm.cleanUp();
|
dm.cleanUp();
|
||||||
dm.cleanUpPrivate();
|
dm.cleanUpPrivate();
|
||||||
do_check_eq(dm.activeDownloadCount, 0);
|
do_check_eq(dm.activeDownloadCount, 0);
|
||||||
|
@ -161,11 +161,11 @@ function run_test() {
|
||||||
trigger_pb_cleanup(false);
|
trigger_pb_cleanup(false);
|
||||||
do_check_true(promptService.wasCalled());
|
do_check_true(promptService.wasCalled());
|
||||||
do_check_eq(dm.activePrivateDownloadCount, 0);
|
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
|
// Create Download-F
|
||||||
dlF = addDownload({
|
dlF = addDownload({
|
||||||
isPrivate: false,
|
isPrivate: true,
|
||||||
targetFile: fileF,
|
targetFile: fileF,
|
||||||
sourceURI: downloadFSource,
|
sourceURI: downloadFSource,
|
||||||
downloadName: downloadFName
|
downloadName: downloadFName
|
||||||
|
@ -173,17 +173,42 @@ function run_test() {
|
||||||
|
|
||||||
// Wait for Download-F to start
|
// Wait for Download-F to start
|
||||||
} else if (aDownload.targetFile.equals(dlF.targetFile)) {
|
} else if (aDownload.targetFile.equals(dlF.targetFile)) {
|
||||||
// Sanity check: Download-F must not be resumable
|
// Sanity check: Download-F must be resumable
|
||||||
do_check_false(dlF.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();
|
promptService.sayCancel();
|
||||||
trigger_pb_cleanup(false);
|
trigger_pb_cleanup(false);
|
||||||
do_check_false(promptService.wasCalled());
|
do_check_false(promptService.wasCalled());
|
||||||
do_check_eq(dm.activeDownloadCount, 1);
|
do_check_eq(dm.activeDownloadCount, 1);
|
||||||
do_check_eq(dlF.state, dm.DOWNLOAD_DOWNLOADING);
|
do_check_eq(dlG.state, dm.DOWNLOAD_DOWNLOADING);
|
||||||
finishTest();
|
finishTest();
|
||||||
}
|
}
|
||||||
break;
|
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) { },
|
onStateChange: function(a, b, c, d, e) { },
|
||||||
|
@ -204,10 +229,15 @@ function run_test() {
|
||||||
const downloadEName = "download-E";
|
const downloadEName = "download-E";
|
||||||
|
|
||||||
// properties of Download-F
|
// 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 downloadFDest = "download-file-F";
|
||||||
const downloadFName = "download-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
|
// Create all target files
|
||||||
let fileD = tmpDir.clone();
|
let fileD = tmpDir.clone();
|
||||||
fileD.append(downloadDDest);
|
fileD.append(downloadDDest);
|
||||||
|
@ -218,6 +248,9 @@ function run_test() {
|
||||||
let fileF = tmpDir.clone();
|
let fileF = tmpDir.clone();
|
||||||
fileF.append(downloadFDest);
|
fileF.append(downloadFDest);
|
||||||
fileF.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
|
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
|
// Create Download-D
|
||||||
let dlD = addDownload({
|
let dlD = addDownload({
|
||||||
|
@ -227,7 +260,7 @@ function run_test() {
|
||||||
downloadName: downloadDName
|
downloadName: downloadDName
|
||||||
});
|
});
|
||||||
|
|
||||||
let dlE, dlF;
|
let dlE, dlF, dlG;
|
||||||
|
|
||||||
// wait for Download-D to start
|
// wait for Download-D to start
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче