2012-10-03 19:29:10 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2014-11-30 10:46:55 +03:00
|
|
|
"use strict";
|
|
|
|
|
2019-01-17 21:18:31 +03:00
|
|
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
2012-10-03 19:29:10 +04:00
|
|
|
|
2018-02-23 22:50:01 +03:00
|
|
|
var EXPORTED_SYMBOLS = ["ForgetAboutSite"];
|
2012-10-03 19:29:10 +04:00
|
|
|
|
2018-02-23 22:50:01 +03:00
|
|
|
var ForgetAboutSite = {
|
2017-05-12 15:42:39 +03:00
|
|
|
async removeDataFromDomain(aDomain) {
|
2019-04-05 12:57:34 +03:00
|
|
|
let errorCount = await new Promise(resolve => {
|
|
|
|
Services.clearData.deleteDataFromHost(
|
|
|
|
aDomain,
|
|
|
|
true /* user request */,
|
|
|
|
Ci.nsIClearDataService.CLEAR_FORGET_ABOUT_SITE,
|
|
|
|
errorCode => resolve(bitCounting(errorCode))
|
|
|
|
);
|
2018-06-01 15:29:59 +03:00
|
|
|
});
|
2012-10-03 19:29:10 +04:00
|
|
|
|
2018-06-01 15:31:16 +03:00
|
|
|
if (errorCount !== 0) {
|
|
|
|
throw new Error(
|
|
|
|
`There were a total of ${errorCount} errors during removal`
|
|
|
|
);
|
2017-03-27 16:57:35 +03:00
|
|
|
}
|
2018-08-31 08:59:17 +03:00
|
|
|
},
|
2017-10-15 21:50:30 +03:00
|
|
|
};
|
2018-06-01 15:31:16 +03:00
|
|
|
|
|
|
|
function bitCounting(value) {
|
|
|
|
// To know more about how to count bits set to 1 in a numeric value, see this
|
|
|
|
// interesting article:
|
|
|
|
// https://blogs.msdn.microsoft.com/jeuge/2005/06/08/bit-fiddling-3/
|
|
|
|
const count =
|
|
|
|
value - ((value >> 1) & 0o33333333333) - ((value >> 2) & 0o11111111111);
|
|
|
|
return ((count + (count >> 3)) & 0o30707070707) % 63;
|
|
|
|
}
|