зеркало из https://github.com/mozilla/pjs.git
Bug 528416 - Download Directory Persists After "Clear Recent History"; r=gavin ui-r=faaborg
--HG-- extra : rebase_source : a5856e02bc394b7359b507d9a40e05d59a114155
This commit is contained in:
Родитель
2fc8dd48c3
Коммит
103bdf00d2
|
@ -53,13 +53,21 @@ let observer = {
|
||||||
throw Components.results.NS_NOINTERFACE;
|
throw Components.results.NS_NOINTERFACE;
|
||||||
},
|
},
|
||||||
observe: function (aSubject, aTopic, aData) {
|
observe: function (aSubject, aTopic, aData) {
|
||||||
gOpenLocationLastURLData = "";
|
switch (aTopic) {
|
||||||
|
case "private-browsing":
|
||||||
|
gOpenLocationLastURLData = "";
|
||||||
|
break;
|
||||||
|
case "browser:purge-session-history":
|
||||||
|
gOpenLocationLastURL.reset();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Components.classes["@mozilla.org/observer-service;1"]
|
let os = Components.classes["@mozilla.org/observer-service;1"]
|
||||||
.getService(Components.interfaces.nsIObserverService)
|
.getService(Components.interfaces.nsIObserverService);
|
||||||
.addObserver(observer, "private-browsing", true);
|
os.addObserver(observer, "private-browsing", true);
|
||||||
|
os.addObserver(observer, "browser:purge-session-history", true);
|
||||||
|
|
||||||
let gOpenLocationLastURLData = "";
|
let gOpenLocationLastURLData = "";
|
||||||
let gOpenLocationLastURL = {
|
let gOpenLocationLastURL = {
|
||||||
|
|
|
@ -43,6 +43,13 @@ function run_test_on_service()
|
||||||
let Cu = Components.utils;
|
let Cu = Components.utils;
|
||||||
Cu.import("resource:///modules/openLocationLastURL.jsm");
|
Cu.import("resource:///modules/openLocationLastURL.jsm");
|
||||||
|
|
||||||
|
function clearHistory() {
|
||||||
|
// simulate clearing the private data
|
||||||
|
Cc["@mozilla.org/observer-service;1"].
|
||||||
|
getService(Ci.nsIObserverService).
|
||||||
|
notifyObservers(null, "browser:purge-session-history", "");
|
||||||
|
}
|
||||||
|
|
||||||
let pb = Cc[PRIVATEBROWSING_CONTRACT_ID].
|
let pb = Cc[PRIVATEBROWSING_CONTRACT_ID].
|
||||||
getService(Ci.nsIPrivateBrowsingService);
|
getService(Ci.nsIPrivateBrowsingService);
|
||||||
let pref = Cc["@mozilla.org/preferences-service;1"].
|
let pref = Cc["@mozilla.org/preferences-service;1"].
|
||||||
|
@ -64,6 +71,10 @@ function run_test_on_service()
|
||||||
gOpenLocationLastURL.value = url2;
|
gOpenLocationLastURL.value = url2;
|
||||||
do_check_eq(gOpenLocationLastURL.value, url2);
|
do_check_eq(gOpenLocationLastURL.value, url2);
|
||||||
|
|
||||||
|
clearHistory();
|
||||||
|
do_check_eq(gOpenLocationLastURL.value, "");
|
||||||
|
gOpenLocationLastURL.value = url2;
|
||||||
|
|
||||||
pb.privateBrowsingEnabled = true;
|
pb.privateBrowsingEnabled = true;
|
||||||
do_check_eq(gOpenLocationLastURL.value, "");
|
do_check_eq(gOpenLocationLastURL.value, "");
|
||||||
|
|
||||||
|
@ -76,6 +87,15 @@ function run_test_on_service()
|
||||||
|
|
||||||
pb.privateBrowsingEnabled = false;
|
pb.privateBrowsingEnabled = false;
|
||||||
do_check_eq(gOpenLocationLastURL.value, url2);
|
do_check_eq(gOpenLocationLastURL.value, url2);
|
||||||
|
|
||||||
|
pb.privateBrowsingEnabled = true;
|
||||||
|
gOpenLocationLastURL.value = url1;
|
||||||
|
do_check_neq(gOpenLocationLastURL.value, "");
|
||||||
|
clearHistory();
|
||||||
|
do_check_eq(gOpenLocationLastURL.value, "");
|
||||||
|
|
||||||
|
pb.privateBrowsingEnabled = false;
|
||||||
|
do_check_eq(gOpenLocationLastURL.value, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Support running tests on both the service itself and its wrapper
|
// Support running tests on both the service itself and its wrapper
|
||||||
|
|
|
@ -57,16 +57,26 @@ let observer = {
|
||||||
throw Components.results.NS_NOINTERFACE;
|
throw Components.results.NS_NOINTERFACE;
|
||||||
},
|
},
|
||||||
observe: function (aSubject, aTopic, aData) {
|
observe: function (aSubject, aTopic, aData) {
|
||||||
if (aData == "enter")
|
switch (aTopic) {
|
||||||
gDownloadLastDirFile = readLastDirPref();
|
case "private-browsing":
|
||||||
else if (aData == "exit")
|
if (aData == "enter")
|
||||||
gDownloadLastDirFile = null;
|
gDownloadLastDirFile = readLastDirPref();
|
||||||
|
else if (aData == "exit")
|
||||||
|
gDownloadLastDirFile = null;
|
||||||
|
break;
|
||||||
|
case "browser:purge-session-history":
|
||||||
|
gDownloadLastDirFile = null;
|
||||||
|
if (prefSvc.prefHasUserValue(LAST_DIR_PREF))
|
||||||
|
prefSvc.clearUserPref(LAST_DIR_PREF);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Components.classes["@mozilla.org/observer-service;1"]
|
let os = Components.classes["@mozilla.org/observer-service;1"]
|
||||||
.getService(Components.interfaces.nsIObserverService)
|
.getService(Components.interfaces.nsIObserverService);
|
||||||
.addObserver(observer, "private-browsing", true);
|
os.addObserver(observer, "private-browsing", true);
|
||||||
|
os.addObserver(observer, "browser:purge-session-history", true);
|
||||||
|
|
||||||
function readLastDirPref() {
|
function readLastDirPref() {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -41,6 +41,13 @@ function run_test()
|
||||||
let Cu = Components.utils;
|
let Cu = Components.utils;
|
||||||
Cu.import("resource://gre/modules/DownloadLastDir.jsm");
|
Cu.import("resource://gre/modules/DownloadLastDir.jsm");
|
||||||
|
|
||||||
|
function clearHistory() {
|
||||||
|
// simulate clearing the private data
|
||||||
|
Cc["@mozilla.org/observer-service;1"].
|
||||||
|
getService(Ci.nsIObserverService).
|
||||||
|
notifyObservers(null, "browser:purge-session-history", "");
|
||||||
|
}
|
||||||
|
|
||||||
do_check_eq(typeof gDownloadLastDir, "object");
|
do_check_eq(typeof gDownloadLastDir, "object");
|
||||||
do_check_eq(gDownloadLastDir.file, null);
|
do_check_eq(gDownloadLastDir.file, null);
|
||||||
|
|
||||||
|
@ -60,6 +67,10 @@ function run_test()
|
||||||
do_check_eq(gDownloadLastDir.file, null);
|
do_check_eq(gDownloadLastDir.file, null);
|
||||||
gDownloadLastDir.file = tmpDir;
|
gDownloadLastDir.file = tmpDir;
|
||||||
|
|
||||||
|
clearHistory();
|
||||||
|
do_check_eq(gDownloadLastDir.file, null);
|
||||||
|
gDownloadLastDir.file = tmpDir;
|
||||||
|
|
||||||
let pb;
|
let pb;
|
||||||
try {
|
try {
|
||||||
pb = Cc["@mozilla.org/privatebrowsing;1"].
|
pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||||
|
@ -85,5 +96,13 @@ function run_test()
|
||||||
do_check_eq(gDownloadLastDir.file.path, tmpDir.path);
|
do_check_eq(gDownloadLastDir.file.path, tmpDir.path);
|
||||||
do_check_neq(gDownloadLastDir.file, tmpDir);
|
do_check_neq(gDownloadLastDir.file, tmpDir);
|
||||||
|
|
||||||
|
pb.privateBrowsingEnabled = true;
|
||||||
|
do_check_neq(gDownloadLastDir.file, null);
|
||||||
|
clearHistory();
|
||||||
|
do_check_eq(gDownloadLastDir.file, null);
|
||||||
|
|
||||||
|
pb.privateBrowsingEnabled = false;
|
||||||
|
do_check_eq(gDownloadLastDir.file, null);
|
||||||
|
|
||||||
newDir.remove(true);
|
newDir.remove(true);
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче