1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 ChromeUtils.import("resource://gre/modules/Services.jsm");
9 var EXPORTED_SYMBOLS = ["ForgetAboutSite"];
11 var ForgetAboutSite = {
12 async removeDataFromDomain(aDomain) {
16 ["http://", "https://"].forEach(scheme => {
17 promises.push(new Promise(resolve => {
18 Services.clearData.deleteDataFromHost(aDomain, true /* user request */,
19 Ci.nsIClearDataService.CLEAR_FORGET_ABOUT_SITE,
21 errorCount += bitCounting(value);
27 await Promise.all(promises);
29 if (errorCount !== 0) {
30 throw new Error(`There were a total of ${errorCount} errors during removal`);
35 function bitCounting(value) {
36 // To know more about how to count bits set to 1 in a numeric value, see this
37 // interesting article:
38 // https://blogs.msdn.microsoft.com/jeuge/2005/06/08/bit-fiddling-3/
39 const count = value - ((value >> 1) & 0o33333333333) - ((value >> 2) & 0o11111111111);
40 return ((count + (count >> 3)) & 0o30707070707) % 63;