browser_sanitize-sitepermissions.js
Go to the documentation of this file.
1 // Bug 380852 - Delete permission manager entries in Clear Recent History
2 
3 Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader)
4  .loadSubScript("chrome://browser/content/sanitize.js");
5 
6 function test() {
7 
8  // Add a permission entry
9  var pm = Cc["@mozilla.org/permissionmanager;1"]
10  .getService(Ci.nsIPermissionManager);
11  pm.add(makeURI("http://example.com"), "testing", pm.ALLOW_ACTION);
12 
13  // Sanity check
14  ok(pm.enumerator.hasMoreElements(), "Permission manager should have elements, since we just added one");
15 
16  // Set up the sanitizer to just clear siteSettings
17  let s = new Sanitizer();
18  s.ignoreTimespan = false;
19  s.prefDomain = "privacy.cpd.";
20  var itemPrefs = gPrefService.getBranch(s.prefDomain);
21  itemPrefs.setBoolPref("history", false);
22  itemPrefs.setBoolPref("downloads", false);
23  itemPrefs.setBoolPref("cache", false);
24  itemPrefs.setBoolPref("cookies", false);
25  itemPrefs.setBoolPref("formdata", false);
26  itemPrefs.setBoolPref("offlineApps", false);
27  itemPrefs.setBoolPref("passwords", false);
28  itemPrefs.setBoolPref("sessions", false);
29  itemPrefs.setBoolPref("siteSettings", true);
30 
31  // Clear it
32  s.sanitize();
33 
34  // Make sure it's gone
35  ok(!pm.enumerator.hasMoreElements(), "Permission manager shouldn't have entries after Sanitizing");
36 }
const Cc
function makeURI(aURLSpec, aCharset)
Definition: FeedWriter.js:71
var gPrefService
Definition: overlay.js:34
const Ci
function Sanitizer()
Definition: sanitize.js:42