moebius#30 and #37: ForgetAboutSite.jsm - promise - serialize vs. parallel + a comment

https://github.com/MoonchildProductions/moebius/pull/30
https://github.com/MoonchildProductions/moebius/pull/37
This commit is contained in:
janekptacijarabaci 2018-04-24 19:23:04 +02:00 • committed by Roy Tam
commit 82205cf721
7 changed files with 179 additions and 156 deletions

View file

@ -253,7 +253,8 @@ PlacesController.prototype = {
} }
else else
host = NetUtil.newURI(this._view.selectedNode.uri).host; host = NetUtil.newURI(this._view.selectedNode.uri).host;
ForgetAboutSite.removeDataFromDomain(host); ForgetAboutSite.removeDataFromDomain(host)
.catch(Components.utils.reportError);
break; break;
case "cmd_selectAll": case "cmd_selectAll":
this.selectAll(); this.selectAll();

View file

@ -67,9 +67,10 @@ function test2()
function test3() function test3()
{ {
// Remove database from domain 2 // Remove database from domain 2
ForgetAboutSite.removeDataFromDomain(domains[1]); ForgetAboutSite.removeDataFromDomain(domains[1]).then(() => {
setPermission(testPageURL4, "indexedDB"); setPermission(testPageURL4, "indexedDB");
executeSoon(test4); executeSoon(test4);
});
} }
function test4() function test4()

View file

@ -206,7 +206,7 @@ add_test(function test_login_on_sync() {
_("Old passphrase function is " + oldGetter); _("Old passphrase function is " + oldGetter);
Service.identity.__defineGetter__("syncKey", Service.identity.__defineGetter__("syncKey",
function() { function() {
throw "User canceled Master Password entry"; throw "User canceled master password entry";
}); });
let oldClearSyncTriggers = Service.scheduler.clearSyncTriggers; let oldClearSyncTriggers = Service.scheduler.clearSyncTriggers;

View file

@ -535,7 +535,7 @@ add_task(function* test_autoconnect_mp_locked() {
delete Service.identity.syncKey; delete Service.identity.syncKey;
Service.identity.__defineGetter__("syncKey", function() { Service.identity.__defineGetter__("syncKey", function() {
_("Faking Master Password entry cancelation."); _("Faking Master Password entry cancelation.");
throw "User canceled Master Password entry"; throw "User canceled master password entry";
}); });
let deferred = Promise.defer(); let deferred = Promise.defer();

View file

@ -45,33 +45,34 @@ const Ci = Components.interfaces;
const Cu = Components.utils; const Cu = Components.utils;
this.ForgetAboutSite = { this.ForgetAboutSite = {
removeDataFromDomain: function CRH_removeDataFromDomain(aDomain) removeDataFromDomain: Task.async(function* (aDomain)
{ {
PlacesUtils.history.removePagesFromHost(aDomain, true); PlacesUtils.history.removePagesFromHost(aDomain, true);
let promises = [];
// Cache // Cache
promises.push(Task.spawn(function*() {
let cs = Cc["@mozilla.org/netwerk/cache-storage-service;1"]. let cs = Cc["@mozilla.org/netwerk/cache-storage-service;1"].
getService(Ci.nsICacheStorageService); getService(Ci.nsICacheStorageService);
// NOTE: there is no way to clear just that domain, so we clear out // NOTE: there is no way to clear just that domain, so we clear out
// everything) // everything)
try {
cs.clear(); cs.clear();
} catch (ex) { }).catch(ex => {
Cu.reportError("Exception thrown while clearing the cache: " + throw new Error("Exception thrown while clearing the cache: " + ex);
ex.toString()); }));
}
// Image Cache // Image Cache
promises.push(Task.spawn(function*() {
let imageCache = Cc["@mozilla.org/image/tools;1"]. let imageCache = Cc["@mozilla.org/image/tools;1"].
getService(Ci.imgITools).getImgCacheForDocument(null); getService(Ci.imgITools).getImgCacheForDocument(null);
try {
imageCache.clearCache(false); // true=chrome, false=content imageCache.clearCache(false); // true=chrome, false=content
} catch (ex) { }).catch(ex => {
Cu.reportError("Exception thrown while clearing the image cache: " + throw new Error("Exception thrown while clearing the image cache: " + ex);
ex.toString()); }));
}
// Cookies // Cookies
// Need to maximize the number of cookies cleaned here
promises.push(Task.spawn(function*() {
let cm = Cc["@mozilla.org/cookiemanager;1"]. let cm = Cc["@mozilla.org/cookiemanager;1"].
getService(Ci.nsICookieManager2); getService(Ci.nsICookieManager2);
let enumerator = cm.getCookiesWithOriginAttributes(JSON.stringify({}), aDomain); let enumerator = cm.getCookiesWithOriginAttributes(JSON.stringify({}), aDomain);
@ -79,85 +80,92 @@ this.ForgetAboutSite = {
let cookie = enumerator.getNext().QueryInterface(Ci.nsICookie); let cookie = enumerator.getNext().QueryInterface(Ci.nsICookie);
cm.remove(cookie.host, cookie.name, cookie.path, false, cookie.originAttributes); cm.remove(cookie.host, cookie.name, cookie.path, false, cookie.originAttributes);
} }
}).catch(ex => {
throw new Error("Exception thrown while clearning cookies: " + ex);
}));
// EME // EME
promises.push(Task.spawn(function*() {
let mps = Cc["@mozilla.org/gecko-media-plugin-service;1"]. let mps = Cc["@mozilla.org/gecko-media-plugin-service;1"].
getService(Ci.mozIGeckoMediaPluginChromeService); getService(Ci.mozIGeckoMediaPluginChromeService);
mps.forgetThisSite(aDomain, JSON.stringify({})); mps.forgetThisSite(aDomain, JSON.stringify({}));
}).catch(ex => {
throw new Error("Exception thrown while clearing Encrypted Media Extensions: " + ex);
}));
// Plugin data // Plugin data
const phInterface = Ci.nsIPluginHost; const phInterface = Ci.nsIPluginHost;
const FLAG_CLEAR_ALL = phInterface.FLAG_CLEAR_ALL; const FLAG_CLEAR_ALL = phInterface.FLAG_CLEAR_ALL;
let ph = Cc["@mozilla.org/plugin/host;1"].getService(phInterface); let ph = Cc["@mozilla.org/plugin/host;1"].getService(phInterface);
let tags = ph.getPluginTags(); let tags = ph.getPluginTags();
let promises = [];
for (let i = 0; i < tags.length; i++) { for (let i = 0; i < tags.length; i++) {
let promise = new Promise(resolve => { promises.push(new Promise(resolve => {
let tag = tags[i];
try { try {
ph.clearSiteData(tags[i], aDomain, FLAG_CLEAR_ALL, -1, function(rv) { ph.clearSiteData(tags[i], aDomain, FLAG_CLEAR_ALL, -1, resolve);
resolve();
});
} catch (e) { } catch (e) {
// Ignore errors from the plugin, but resolve the promise // Ignore errors from the plugin, but resolve the promise
// We cannot check if something is a bailout or an error
resolve(); resolve();
} }
}); }));
promises.push(promise);
} }
// Downloads // Downloads
Task.spawn(function*() { promises.push(Task.spawn(function*() {
let list = yield Downloads.getList(Downloads.ALL); let list = yield Downloads.getList(Downloads.ALL);
list.removeFinished(download => hasRootDomain( list.removeFinished(download => hasRootDomain(
NetUtil.newURI(download.source.url).host, aDomain)); NetUtil.newURI(download.source.url).host, aDomain));
}).then(null, Cu.reportError); }).catch(ex => {
throw new Error("Exception in clearing Downloads: " + ex);
}));
// Passwords // Passwords
promises.push(Task.spawn(function*() {
let lm = Cc["@mozilla.org/login-manager;1"]. let lm = Cc["@mozilla.org/login-manager;1"].
getService(Ci.nsILoginManager); getService(Ci.nsILoginManager);
// Clear all passwords for domain // Clear all passwords for domain
try {
let logins = lm.getAllLogins(); let logins = lm.getAllLogins();
for (let i = 0; i < logins.length; i++) for (let i = 0; i < logins.length; i++) {
if (hasRootDomain(logins[i].hostname, aDomain)) if (hasRootDomain(logins[i].hostname, aDomain)) {
lm.removeLogin(logins[i]); lm.removeLogin(logins[i]);
} }
// XXXehsan: is there a better way to do this rather than this
// hacky comparison?
catch (ex) {
if (!ex.message.includes("User canceled Master Password entry")) {
throw ex;
} }
}).catch(ex => {
// XXX:
// Is there a better way to do this rather than this hacky comparison?
// Copied this from toolkit/components/passwordmgr/crypto-SDR.js
if (!ex.message.includes("User canceled master password entry")) {
throw new Error("Exception occured in clearing passwords: " + ex);
} }
}));
// Permissions // Permissions
let pm = Cc["@mozilla.org/permissionmanager;1"]. let pm = Cc["@mozilla.org/permissionmanager;1"].
getService(Ci.nsIPermissionManager); getService(Ci.nsIPermissionManager);
// Enumerate all of the permissions, and if one matches, remove it // Enumerate all of the permissions, and if one matches, remove it
enumerator = pm.enumerator; let enumerator = pm.enumerator;
while (enumerator.hasMoreElements()) { while (enumerator.hasMoreElements()) {
let perm = enumerator.getNext().QueryInterface(Ci.nsIPermission); let perm = enumerator.getNext().QueryInterface(Ci.nsIPermission);
promises.push(new Promise((resolve, reject) => {
try { try {
if (hasRootDomain(perm.principal.URI.host, aDomain)) { if (hasRootDomain(perm.principal.URI.host, aDomain)) {
pm.removePermission(perm); pm.removePermission(perm);
} }
} catch (e) { } catch (ex) {
/* Ignore entry */ // Ignore entry
} finally {
resolve();
} }
}));
} }
// Offline Storages // Offline Storages
promises.push(Task.spawn(function*() {
let qms = Cc["@mozilla.org/dom/quota-manager-service;1"]. let qms = Cc["@mozilla.org/dom/quota-manager-service;1"].
getService(Ci.nsIQuotaManagerService); getService(Ci.nsIQuotaManagerService);
// delete data from both HTTP and HTTPS sites // delete data from both HTTP and HTTPS sites
let caUtils = {}; let httpURI = NetUtil.newURI("http://" + aDomain);
let scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"]. let httpsURI = NetUtil.newURI("https://" + aDomain);
getService(Ci.mozIJSSubScriptLoader);
scriptLoader.loadSubScript("chrome://global/content/contentAreaUtils.js",
caUtils);
let httpURI = caUtils.makeURI("http://" + aDomain);
let httpsURI = caUtils.makeURI("https://" + aDomain);
// Following code section has been reverted to the state before Bug 1238183, // Following code section has been reverted to the state before Bug 1238183,
// but added a new argument to clearStoragesForPrincipal() for indicating // but added a new argument to clearStoragesForPrincipal() for indicating
// clear all storages under a given origin. // clear all storages under a given origin.
@ -167,53 +175,71 @@ this.ForgetAboutSite = {
.createCodebasePrincipal(httpsURI, {}); .createCodebasePrincipal(httpsURI, {});
qms.clearStoragesForPrincipal(httpPrincipal, null, true); qms.clearStoragesForPrincipal(httpPrincipal, null, true);
qms.clearStoragesForPrincipal(httpsPrincipal, null, true); qms.clearStoragesForPrincipal(httpsPrincipal, null, true);
}).catch(ex => {
throw new Error("Exception occured while clearing offline storages: " + ex);
function onContentPrefsRemovalFinished() { }));
// Everybody else (including extensions)
Services.obs.notifyObservers(null, "browser:purge-domain-data", aDomain);
}
// Content Preferences // Content Preferences
promises.push(Task.spawn(function*() {
let cps2 = Cc["@mozilla.org/content-pref/service;1"]. let cps2 = Cc["@mozilla.org/content-pref/service;1"].
getService(Ci.nsIContentPrefService2); getService(Ci.nsIContentPrefService2);
cps2.removeBySubdomain(aDomain, null, { cps2.removeBySubdomain(aDomain, null, {
handleCompletion: () => onContentPrefsRemovalFinished(), handleCompletion: (reason) => {
handleError: function() {} // Notify other consumers, including extensions
Services.obs.notifyObservers(null, "browser:purge-domain-data", aDomain);
if (reason === cps2.COMPLETE_ERROR) {
throw new Error("Exception occured while clearing content preferences");
}
},
handleError() {}
}); });
}));
// Predictive network data - like cache, no way to clear this per // Predictive network data - like cache, no way to clear this per
// domain, so just trash it all // domain, so just trash it all
promises.push(Task.spawn(function*() {
let np = Cc["@mozilla.org/network/predictor;1"]. let np = Cc["@mozilla.org/network/predictor;1"].
getService(Ci.nsINetworkPredictor); getService(Ci.nsINetworkPredictor);
np.reset(); np.reset();
}).catch(ex => {
throw new Error("Exception occured while clearing predictive network data: " + ex);
}));
// Push notifications. // Push notifications
promises.push(new Promise(resolve => { promises.push(Task.spawn(function*() {
var push = Cc["@mozilla.org/push/Service;1"] var push = Cc["@mozilla.org/push/Service;1"].
.getService(Ci.nsIPushService); getService(Ci.nsIPushService);
push.clearForDomain(aDomain, status => { push.clearForDomain(aDomain, status => {
(Components.isSuccessCode(status) ? resolve : reject)(status); if (!Components.isSuccessCode(status)) {
throw new Error("Exception occured while clearing push notifications: " + status);
}
}); });
}).catch(e => {
Cu.reportError("Exception thrown while clearing Push notifications: " +
e.toString());
})); }));
// HSTS and HPKP // HSTS and HPKP
// TODO (bug 1290529): also remove HSTS/HPKP information for subdomains. // TODO (bug 1290529): also remove HSTS/HPKP information for subdomains.
// Since we can't enumerate the information in the site security service // Since we can't enumerate the information in the site security service
// (bug 1115712), we can't implement this right now. // (bug 1115712), we can't implement this right now.
try { promises.push(Task.spawn(function*() {
let sss = Cc["@mozilla.org/ssservice;1"]. let sss = Cc["@mozilla.org/ssservice;1"].
getService(Ci.nsISiteSecurityService); getService(Ci.nsISiteSecurityService);
let httpsURI = NetUtil.newURI("https://" + aDomain);
sss.removeState(Ci.nsISiteSecurityService.HEADER_HSTS, httpsURI, 0); sss.removeState(Ci.nsISiteSecurityService.HEADER_HSTS, httpsURI, 0);
sss.removeState(Ci.nsISiteSecurityService.HEADER_HPKP, httpsURI, 0); sss.removeState(Ci.nsISiteSecurityService.HEADER_HPKP, httpsURI, 0);
} catch (e) { }).catch(ex => {
Cu.reportError("Exception thrown while clearing HSTS/HPKP: " + throw new Error("Exception thrown while clearing HSTS/HPKP: " + ex);
e.toString()); }));
}
return Promise.all(promises); let ErrorCount = 0;
for (let promise of promises) {
try {
yield promise;
} catch (ex) {
Cu.reportError(ex);
ErrorCount++;
}
}
if (ErrorCount !== 0)
throw new Error(`There were a total of ${ErrorCount} errors during removal`);
})
} }
};

View file

@ -37,7 +37,7 @@ function setTestPluginEnabledState(newEnabledState, plugin) {
}); });
} }
add_task(function* setup() { add_task(function* () {
var tags = pluginHost.getPluginTags(); var tags = pluginHost.getPluginTags();
// Find the test plugin // Find the test plugin
@ -50,12 +50,9 @@ add_task(function* setup() {
} }
if (!pluginTag) { if (!pluginTag) {
ok(false, "Test Plug-in not available, can't run test"); ok(false, "Test Plug-in not available, can't run test");
finish(); return;
} }
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, pluginTag); setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, pluginTag);
});
add_task(function* () {
yield BrowserTestUtils.openNewForegroundTab(gBrowser, testURL); yield BrowserTestUtils.openNewForegroundTab(gBrowser, testURL);
// Set data for the plugin after the page load. // Set data for the plugin after the page load.
@ -87,5 +84,3 @@ add_task(function* () {
gBrowser.removeCurrentTab(); gBrowser.removeCurrentTab();
}); });

View file

@ -257,7 +257,7 @@ function* test_history_cleared_with_direct_match()
do_check_false(yield promiseIsURIVisited(TEST_URI)); do_check_false(yield promiseIsURIVisited(TEST_URI));
yield PlacesTestUtils.addVisits(TEST_URI); yield PlacesTestUtils.addVisits(TEST_URI);
do_check_true(yield promiseIsURIVisited(TEST_URI)); do_check_true(yield promiseIsURIVisited(TEST_URI));
ForgetAboutSite.removeDataFromDomain("mozilla.org"); yield ForgetAboutSite.removeDataFromDomain("mozilla.org");
do_check_false(yield promiseIsURIVisited(TEST_URI)); do_check_false(yield promiseIsURIVisited(TEST_URI));
} }
@ -267,7 +267,7 @@ function* test_history_cleared_with_subdomain()
do_check_false(yield promiseIsURIVisited(TEST_URI)); do_check_false(yield promiseIsURIVisited(TEST_URI));
yield PlacesTestUtils.addVisits(TEST_URI); yield PlacesTestUtils.addVisits(TEST_URI);
do_check_true(yield promiseIsURIVisited(TEST_URI)); do_check_true(yield promiseIsURIVisited(TEST_URI));
ForgetAboutSite.removeDataFromDomain("mozilla.org"); yield ForgetAboutSite.removeDataFromDomain("mozilla.org");
do_check_false(yield promiseIsURIVisited(TEST_URI)); do_check_false(yield promiseIsURIVisited(TEST_URI));
} }
@ -277,7 +277,7 @@ function* test_history_not_cleared_with_uri_contains_domain()
do_check_false(yield promiseIsURIVisited(TEST_URI)); do_check_false(yield promiseIsURIVisited(TEST_URI));
yield PlacesTestUtils.addVisits(TEST_URI); yield PlacesTestUtils.addVisits(TEST_URI);
do_check_true(yield promiseIsURIVisited(TEST_URI)); do_check_true(yield promiseIsURIVisited(TEST_URI));
ForgetAboutSite.removeDataFromDomain("mozilla.org"); yield ForgetAboutSite.removeDataFromDomain("mozilla.org");
do_check_true(yield promiseIsURIVisited(TEST_URI)); do_check_true(yield promiseIsURIVisited(TEST_URI));
// Clear history since we left something there from this test. // Clear history since we left something there from this test.
@ -285,52 +285,52 @@ function* test_history_not_cleared_with_uri_contains_domain()
} }
// Cookie Service // Cookie Service
function test_cookie_cleared_with_direct_match() function* test_cookie_cleared_with_direct_match()
{ {
const TEST_DOMAIN = "mozilla.org"; const TEST_DOMAIN = "mozilla.org";
add_cookie(TEST_DOMAIN); add_cookie(TEST_DOMAIN);
ForgetAboutSite.removeDataFromDomain("mozilla.org"); yield ForgetAboutSite.removeDataFromDomain("mozilla.org");
check_cookie_exists(TEST_DOMAIN, false); check_cookie_exists(TEST_DOMAIN, false);
} }
function test_cookie_cleared_with_subdomain() function* test_cookie_cleared_with_subdomain()
{ {
const TEST_DOMAIN = "www.mozilla.org"; const TEST_DOMAIN = "www.mozilla.org";
add_cookie(TEST_DOMAIN); add_cookie(TEST_DOMAIN);
ForgetAboutSite.removeDataFromDomain("mozilla.org"); yield ForgetAboutSite.removeDataFromDomain("mozilla.org");
check_cookie_exists(TEST_DOMAIN, false); check_cookie_exists(TEST_DOMAIN, false);
} }
function test_cookie_not_cleared_with_uri_contains_domain() function* test_cookie_not_cleared_with_uri_contains_domain()
{ {
const TEST_DOMAIN = "ilovemozilla.org"; const TEST_DOMAIN = "ilovemozilla.org";
add_cookie(TEST_DOMAIN); add_cookie(TEST_DOMAIN);
ForgetAboutSite.removeDataFromDomain("mozilla.org"); yield ForgetAboutSite.removeDataFromDomain("mozilla.org");
check_cookie_exists(TEST_DOMAIN, true); check_cookie_exists(TEST_DOMAIN, true);
} }
// Login Manager // Login Manager
function test_login_manager_disabled_hosts_cleared_with_direct_match() function* test_login_manager_disabled_hosts_cleared_with_direct_match()
{ {
const TEST_HOST = "http://mozilla.org"; const TEST_HOST = "http://mozilla.org";
add_disabled_host(TEST_HOST); add_disabled_host(TEST_HOST);
ForgetAboutSite.removeDataFromDomain("mozilla.org"); yield ForgetAboutSite.removeDataFromDomain("mozilla.org");
check_disabled_host(TEST_HOST, false); check_disabled_host(TEST_HOST, false);
} }
function test_login_manager_disabled_hosts_cleared_with_subdomain() function* test_login_manager_disabled_hosts_cleared_with_subdomain()
{ {
const TEST_HOST = "http://www.mozilla.org"; const TEST_HOST = "http://www.mozilla.org";
add_disabled_host(TEST_HOST); add_disabled_host(TEST_HOST);
ForgetAboutSite.removeDataFromDomain("mozilla.org"); yield ForgetAboutSite.removeDataFromDomain("mozilla.org");
check_disabled_host(TEST_HOST, false); check_disabled_host(TEST_HOST, false);
} }
function test_login_manager_disabled_hosts_not_cleared_with_uri_contains_domain() function* test_login_manager_disabled_hosts_not_cleared_with_uri_contains_domain()
{ {
const TEST_HOST = "http://ilovemozilla.org"; const TEST_HOST = "http://ilovemozilla.org";
add_disabled_host(TEST_HOST); add_disabled_host(TEST_HOST);
ForgetAboutSite.removeDataFromDomain("mozilla.org"); yield ForgetAboutSite.removeDataFromDomain("mozilla.org");
check_disabled_host(TEST_HOST, true); check_disabled_host(TEST_HOST, true);
// Reset state // Reset state
@ -340,27 +340,27 @@ function test_login_manager_disabled_hosts_not_cleared_with_uri_contains_domain(
check_disabled_host(TEST_HOST, false); check_disabled_host(TEST_HOST, false);
} }
function test_login_manager_logins_cleared_with_direct_match() function* test_login_manager_logins_cleared_with_direct_match()
{ {
const TEST_HOST = "http://mozilla.org"; const TEST_HOST = "http://mozilla.org";
add_login(TEST_HOST); add_login(TEST_HOST);
ForgetAboutSite.removeDataFromDomain("mozilla.org"); yield ForgetAboutSite.removeDataFromDomain("mozilla.org");
check_login_exists(TEST_HOST, false); check_login_exists(TEST_HOST, false);
} }
function test_login_manager_logins_cleared_with_subdomain() function* test_login_manager_logins_cleared_with_subdomain()
{ {
const TEST_HOST = "http://www.mozilla.org"; const TEST_HOST = "http://www.mozilla.org";
add_login(TEST_HOST); add_login(TEST_HOST);
ForgetAboutSite.removeDataFromDomain("mozilla.org"); yield ForgetAboutSite.removeDataFromDomain("mozilla.org");
check_login_exists(TEST_HOST, false); check_login_exists(TEST_HOST, false);
} }
function test_login_manager_logins_not_cleared_with_uri_contains_domain() function* test_login_manager_logins_not_cleared_with_uri_contains_domain()
{ {
const TEST_HOST = "http://ilovemozilla.org"; const TEST_HOST = "http://ilovemozilla.org";
add_login(TEST_HOST); add_login(TEST_HOST);
ForgetAboutSite.removeDataFromDomain("mozilla.org"); yield ForgetAboutSite.removeDataFromDomain("mozilla.org");
check_login_exists(TEST_HOST, true); check_login_exists(TEST_HOST, true);
let lm = Cc["@mozilla.org/login-manager;1"]. let lm = Cc["@mozilla.org/login-manager;1"].
@ -370,27 +370,27 @@ function test_login_manager_logins_not_cleared_with_uri_contains_domain()
} }
// Permission Manager // Permission Manager
function test_permission_manager_cleared_with_direct_match() function* test_permission_manager_cleared_with_direct_match()
{ {
const TEST_URI = uri("http://mozilla.org"); const TEST_URI = uri("http://mozilla.org");
add_permission(TEST_URI); add_permission(TEST_URI);
ForgetAboutSite.removeDataFromDomain("mozilla.org"); yield ForgetAboutSite.removeDataFromDomain("mozilla.org");
check_permission_exists(TEST_URI, false); check_permission_exists(TEST_URI, false);
} }
function test_permission_manager_cleared_with_subdomain() function* test_permission_manager_cleared_with_subdomain()
{ {
const TEST_URI = uri("http://www.mozilla.org"); const TEST_URI = uri("http://www.mozilla.org");
add_permission(TEST_URI); add_permission(TEST_URI);
ForgetAboutSite.removeDataFromDomain("mozilla.org"); yield ForgetAboutSite.removeDataFromDomain("mozilla.org");
check_permission_exists(TEST_URI, false); check_permission_exists(TEST_URI, false);
} }
function test_permission_manager_not_cleared_with_uri_contains_domain() function* test_permission_manager_not_cleared_with_uri_contains_domain()
{ {
const TEST_URI = uri("http://ilovemozilla.org"); const TEST_URI = uri("http://ilovemozilla.org");
add_permission(TEST_URI); add_permission(TEST_URI);
ForgetAboutSite.removeDataFromDomain("mozilla.org"); yield ForgetAboutSite.removeDataFromDomain("mozilla.org");
check_permission_exists(TEST_URI, true); check_permission_exists(TEST_URI, true);
// Reset state // Reset state
@ -427,7 +427,7 @@ function* test_content_preferences_cleared_with_direct_match()
do_check_false(yield preference_exists(TEST_URI)); do_check_false(yield preference_exists(TEST_URI));
yield add_preference(TEST_URI); yield add_preference(TEST_URI);
do_check_true(yield preference_exists(TEST_URI)); do_check_true(yield preference_exists(TEST_URI));
ForgetAboutSite.removeDataFromDomain("mozilla.org"); yield ForgetAboutSite.removeDataFromDomain("mozilla.org");
yield waitForPurgeNotification(); yield waitForPurgeNotification();
do_check_false(yield preference_exists(TEST_URI)); do_check_false(yield preference_exists(TEST_URI));
} }
@ -438,7 +438,7 @@ function* test_content_preferences_cleared_with_subdomain()
do_check_false(yield preference_exists(TEST_URI)); do_check_false(yield preference_exists(TEST_URI));
yield add_preference(TEST_URI); yield add_preference(TEST_URI);
do_check_true(yield preference_exists(TEST_URI)); do_check_true(yield preference_exists(TEST_URI));
ForgetAboutSite.removeDataFromDomain("mozilla.org"); yield ForgetAboutSite.removeDataFromDomain("mozilla.org");
yield waitForPurgeNotification(); yield waitForPurgeNotification();
do_check_false(yield preference_exists(TEST_URI)); do_check_false(yield preference_exists(TEST_URI));
} }
@ -449,12 +449,12 @@ function* test_content_preferences_not_cleared_with_uri_contains_domain()
do_check_false(yield preference_exists(TEST_URI)); do_check_false(yield preference_exists(TEST_URI));
yield add_preference(TEST_URI); yield add_preference(TEST_URI);
do_check_true(yield preference_exists(TEST_URI)); do_check_true(yield preference_exists(TEST_URI));
ForgetAboutSite.removeDataFromDomain("mozilla.org"); yield ForgetAboutSite.removeDataFromDomain("mozilla.org");
yield waitForPurgeNotification(); yield waitForPurgeNotification();
do_check_true(yield preference_exists(TEST_URI)); do_check_true(yield preference_exists(TEST_URI));
// Reset state // Reset state
ForgetAboutSite.removeDataFromDomain("ilovemozilla.org"); yield ForgetAboutSite.removeDataFromDomain("ilovemozilla.org");
yield waitForPurgeNotification(); yield waitForPurgeNotification();
do_check_false(yield preference_exists(TEST_URI)); do_check_false(yield preference_exists(TEST_URI));
} }
@ -535,7 +535,7 @@ function* test_push_cleared()
} }
// Cache // Cache
function test_cache_cleared() function* test_cache_cleared()
{ {
// Because this test is asynchronous, it should be the last test // Because this test is asynchronous, it should be the last test
do_check_true(tests[tests.length - 1] == arguments.callee); do_check_true(tests[tests.length - 1] == arguments.callee);
@ -557,7 +557,7 @@ function test_cache_cleared()
} }
}; };
os.addObserver(observer, "cacheservice:empty-cache", false); os.addObserver(observer, "cacheservice:empty-cache", false);
ForgetAboutSite.removeDataFromDomain("mozilla.org"); yield ForgetAboutSite.removeDataFromDomain("mozilla.org");
do_test_pending(); do_test_pending();
} }
@ -588,7 +588,7 @@ function* test_storage_cleared()
do_check_eq(storage.getItem("test"), "value" + i); do_check_eq(storage.getItem("test"), "value" + i);
} }
ForgetAboutSite.removeDataFromDomain("mozilla.org"); yield ForgetAboutSite.removeDataFromDomain("mozilla.org");
yield waitForPurgeNotification(); yield waitForPurgeNotification();
do_check_eq(s[0].getItem("test"), null); do_check_eq(s[0].getItem("test"), null);