browser_sanitize-passwordDisabledHosts.js
Go to the documentation of this file.
1 // Bug 474792 - Clear "Never remember passwords for this site" when
2 // clearing site-specific settings in Clear Recent History dialog
3 
4 Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader)
5  .loadSubScript("chrome://browser/content/sanitize.js");
6 
7 function test() {
8 
9  var pwmgr = Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager);
10 
11  // Add a disabled host
12  pwmgr.setLoginSavingEnabled("http://example.com", false);
13 
14  // Sanity check
15  is(pwmgr.getLoginSavingEnabled("http://example.com"), false,
16  "example.com should be disabled for password saving since we haven't cleared that yet.");
17 
18  // Set up the sanitizer to just clear siteSettings
19  let s = new Sanitizer();
20  s.ignoreTimespan = false;
21  s.prefDomain = "privacy.cpd.";
22  var itemPrefs = gPrefService.getBranch(s.prefDomain);
23  itemPrefs.setBoolPref("history", false);
24  itemPrefs.setBoolPref("downloads", false);
25  itemPrefs.setBoolPref("cache", false);
26  itemPrefs.setBoolPref("cookies", false);
27  itemPrefs.setBoolPref("formdata", false);
28  itemPrefs.setBoolPref("offlineApps", false);
29  itemPrefs.setBoolPref("passwords", false);
30  itemPrefs.setBoolPref("sessions", false);
31  itemPrefs.setBoolPref("siteSettings", true);
32 
33  // Clear it
34  s.sanitize();
35 
36  // Make sure it's gone
37  is(pwmgr.getLoginSavingEnabled("http://example.com"), true,
38  "example.com should be enabled for password saving again now that we've cleared.");
39 }
const Cc
var gPrefService
Definition: overlay.js:34
const Ci
function Sanitizer()
Definition: sanitize.js:42