Bug 850210 - Part 3. Update DownloadLastDir usage of removePrefsByName to nsIContentPrefService2. r=adw

This commit is contained in:
Felipe Gomes 2013-04-01 02:59:17 -03:00
parent 1d5b463737
commit 586824cf24
2 changed files with 20 additions and 12 deletions

View File

@ -127,16 +127,6 @@ function runTest() {
"uri3 should return dir3"); // set in CPS
is(gDownloadLastDir.getFile(uri4).path, dir2.path,
"uri4 should return dir2"); // fallback
// check clearHistory removes all data
clearHistory();
is(gDownloadLastDir.file, null, "clearHistory removes all data");
is(Services.contentPrefs.hasPref(uri1, "browser.download.lastDir", null),
false, "LastDir preference should be absent");
is(gDownloadLastDir.getFile(uri1), null, "uri1 should point to null");
is(gDownloadLastDir.getFile(uri2), null, "uri2 should point to null");
is(gDownloadLastDir.getFile(uri3), null, "uri3 should point to null");
is(gDownloadLastDir.getFile(uri4), null, "uri4 should point to null");
}
function checkDownloadLastDir(aWin, gDownloadLastDir, aLastDir) {
@ -180,6 +170,19 @@ function runTest() {
yield testOnWindow(false, function(win, downloadDir) {
checkInit(win, downloadDir);
clearHistory();
});
yield testOnWindow(false, function(win, downloadDir) {
// check clearHistory removes all data
is(downloadDir.file, null, "clearHistory removes all data");
is(Services.contentPrefs.hasPref(uri1, "browser.download.lastDir", null),
false, "LastDir preference should be absent");
is(downloadDir.getFile(uri1), null, "uri1 should point to null");
is(downloadDir.getFile(uri2), null, "uri2 should point to null");
is(downloadDir.getFile(uri3), null, "uri3 should point to null");
is(downloadDir.getFile(uri4), null, "uri4 should point to null");
downloadDir.setFile(null, tmpDir);
});
@ -244,6 +247,8 @@ function runTest() {
yield testOnWindow(true, function(win, downloadDir) {
downloadDir.setFile(uri1, dir2);
clearHistory();
});
yield testOnWindow(true, function(win, downloadDir) {
checkDownloadLastDirNull(win, downloadDir);
});
yield testOnWindow(false, function(win, downloadDir) {

View File

@ -52,8 +52,11 @@ let observer = {
Services.prefs.clearUserPref(LAST_DIR_PREF);
// Ensure that purging session history causes both the session-only PB cache
// and persistent prefs to be cleared.
Services.contentPrefs.removePrefsByName(LAST_DIR_PREF, {usePrivateBrowsing: false});
Services.contentPrefs.removePrefsByName(LAST_DIR_PREF, {usePrivateBrowsing: true});
let cps2 = Components.classes["@mozilla.org/content-pref/service;1"].
getService(Components.interfaces.nsIContentPrefService2);
cps2.removeByName(LAST_DIR_PREF, {usePrivateBrowsing: false});
cps2.removeByName(LAST_DIR_PREF, {usePrivateBrowsing: true});
break;
}
}