fune/browser/base/content/test/sanitize/browser_sanitize-sitepermissions.js
Johann Hofmann 8a87220e95 Bug 1167238 - Part 4 - Move sanitize tests into a topical directory and clean up sanitize.js usage. r=mak
We're changing the way sanitize.js/Sanitizer.jsm works and need to adjust a lot of tests to that.
I'm using this opportunity to also move the sanitization tests into their
own topical directory and out of b/b/c/test/general.

MozReview-Commit-ID: GHOqr4hT52b

--HG--
rename : browser/base/content/test/general/browser_purgehistory_clears_sh.js => browser/base/content/test/sanitize/browser_purgehistory_clears_sh.js
rename : browser/base/content/test/general/browser_bug409624.js => browser/base/content/test/sanitize/browser_sanitize-formhistory.js
rename : browser/base/content/test/general/browser_sanitize-passwordDisabledHosts.js => browser/base/content/test/sanitize/browser_sanitize-passwordDisabledHosts.js
rename : browser/base/content/test/general/browser_sanitize-sitepermissions.js => browser/base/content/test/sanitize/browser_sanitize-sitepermissions.js
rename : browser/base/content/test/general/browser_sanitize-timespans.js => browser/base/content/test/sanitize/browser_sanitize-timespans.js
rename : browser/base/content/test/general/browser_sanitizeDialog.js => browser/base/content/test/sanitize/browser_sanitizeDialog.js
extra : rebase_source : 10577846b8a407d12f7459b270a5c5573cd425ad
2018-01-18 16:05:36 +01:00

33 lines
1 KiB
JavaScript

// Bug 380852 - Delete permission manager entries in Clear Recent History
function countPermissions() {
let result = 0;
let enumerator = Services.perms.enumerator;
while (enumerator.hasMoreElements()) {
result++;
enumerator.getNext();
}
return result;
}
add_task(async function test() {
// sanitize before we start so we have a good baseline.
await Sanitizer.sanitize(["siteSettings"], {ignoreTimespan: false});
// Count how many permissions we start with - some are defaults that
// will not be sanitized.
let numAtStart = countPermissions();
// Add a permission entry
var pm = Services.perms;
pm.add(Services.io.newURI("http://example.com"), "testing", pm.ALLOW_ACTION);
// Sanity check
ok(pm.enumerator.hasMoreElements(), "Permission manager should have elements, since we just added one");
// Clear it
await Sanitizer.sanitize(["siteSettings"], {ignoreTimespan: false});
// Make sure it's gone
is(numAtStart, countPermissions(), "Permission manager should have the same count it started with");
});