mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 528416 - Download Directory Persists After "Clear Recent History"; r=gavin ui-r=faaborg
--HG-- extra : rebase_source : a5856e02bc394b7359b507d9a40e05d59a114155
This commit is contained in:
parent
e764036ed7
commit
832b7b21db
@ -53,13 +53,21 @@ let observer = {
|
||||
throw Components.results.NS_NOINTERFACE;
|
||||
},
|
||||
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"]
|
||||
.getService(Components.interfaces.nsIObserverService)
|
||||
.addObserver(observer, "private-browsing", true);
|
||||
let os = Components.classes["@mozilla.org/observer-service;1"]
|
||||
.getService(Components.interfaces.nsIObserverService);
|
||||
os.addObserver(observer, "private-browsing", true);
|
||||
os.addObserver(observer, "browser:purge-session-history", true);
|
||||
|
||||
let gOpenLocationLastURLData = "";
|
||||
let gOpenLocationLastURL = {
|
||||
|
@ -43,6 +43,13 @@ function run_test_on_service()
|
||||
let Cu = Components.utils;
|
||||
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].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
let pref = Cc["@mozilla.org/preferences-service;1"].
|
||||
@ -64,6 +71,10 @@ function run_test_on_service()
|
||||
gOpenLocationLastURL.value = url2;
|
||||
do_check_eq(gOpenLocationLastURL.value, url2);
|
||||
|
||||
clearHistory();
|
||||
do_check_eq(gOpenLocationLastURL.value, "");
|
||||
gOpenLocationLastURL.value = url2;
|
||||
|
||||
pb.privateBrowsingEnabled = true;
|
||||
do_check_eq(gOpenLocationLastURL.value, "");
|
||||
|
||||
@ -76,6 +87,15 @@ function run_test_on_service()
|
||||
|
||||
pb.privateBrowsingEnabled = false;
|
||||
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
|
||||
|
@ -57,16 +57,26 @@ let observer = {
|
||||
throw Components.results.NS_NOINTERFACE;
|
||||
},
|
||||
observe: function (aSubject, aTopic, aData) {
|
||||
if (aData == "enter")
|
||||
gDownloadLastDirFile = readLastDirPref();
|
||||
else if (aData == "exit")
|
||||
gDownloadLastDirFile = null;
|
||||
switch (aTopic) {
|
||||
case "private-browsing":
|
||||
if (aData == "enter")
|
||||
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"]
|
||||
.getService(Components.interfaces.nsIObserverService)
|
||||
.addObserver(observer, "private-browsing", true);
|
||||
let os = Components.classes["@mozilla.org/observer-service;1"]
|
||||
.getService(Components.interfaces.nsIObserverService);
|
||||
os.addObserver(observer, "private-browsing", true);
|
||||
os.addObserver(observer, "browser:purge-session-history", true);
|
||||
|
||||
function readLastDirPref() {
|
||||
try {
|
||||
|
@ -41,6 +41,13 @@ function run_test()
|
||||
let Cu = Components.utils;
|
||||
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(gDownloadLastDir.file, null);
|
||||
|
||||
@ -60,6 +67,10 @@ function run_test()
|
||||
do_check_eq(gDownloadLastDir.file, null);
|
||||
gDownloadLastDir.file = tmpDir;
|
||||
|
||||
clearHistory();
|
||||
do_check_eq(gDownloadLastDir.file, null);
|
||||
gDownloadLastDir.file = tmpDir;
|
||||
|
||||
let pb;
|
||||
try {
|
||||
pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
@ -85,5 +96,13 @@ function run_test()
|
||||
do_check_eq(gDownloadLastDir.file.path, tmpDir.path);
|
||||
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user