зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1422365 - Introduce nsIClearDataService - part 18 - custom flags for ForgetAboutSite, r=johannh
This commit is contained in:
Родитель
7517b0c5ab
Коммит
4eee763067
|
@ -765,11 +765,9 @@ async function maybeSanitizeSessionPrincipals(principals) {
|
|||
|
||||
async function sanitizeSessionPrincipal(principal) {
|
||||
await new Promise(resolve => {
|
||||
let service = Cc["@mozilla.org/clear-data-service;1"]
|
||||
.getService(Ci.nsIClearDataService);
|
||||
service.deleteDataFromPrincipal(principal, true /* user request */,
|
||||
Ci.nsIClearDataService.CLEAR_DOM_STORAGES,
|
||||
resolve);
|
||||
Services.clearData.deleteDataFromPrincipal(principal, true /* user request */,
|
||||
Ci.nsIClearDataService.CLEAR_DOM_STORAGES,
|
||||
resolve);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -178,14 +178,10 @@ interface nsIClearDataService : nsISupports
|
|||
*/
|
||||
const uint32_t CLEAR_EME = 1 << 18;
|
||||
|
||||
/* TODO
|
||||
const uint32_t CLEAR_FORMDATA = 1 << 16;
|
||||
*/
|
||||
|
||||
/**
|
||||
* Use this value to delete all the data.
|
||||
*/
|
||||
const uint32_t CLEAR_ALL = 0xFFFF;
|
||||
const uint32_t CLEAR_ALL = 0xFFFFFF;
|
||||
|
||||
/**************************************************************************
|
||||
* The following flags are helpers: they combine some of the previous flags
|
||||
|
@ -194,7 +190,6 @@ interface nsIClearDataService : nsISupports
|
|||
|
||||
/**
|
||||
* Delete all the possible caches.
|
||||
* TODO: add CLEAR_PREDICTOR_CACHE ?
|
||||
*/
|
||||
const uint32_t CLEAR_ALL_CACHES = CLEAR_NETWORK_CACHE | CLEAR_IMAGE_CACHE;
|
||||
|
||||
|
@ -202,6 +197,16 @@ interface nsIClearDataService : nsISupports
|
|||
* Delete all DOM storages
|
||||
*/
|
||||
const uint32_t CLEAR_DOM_STORAGES = CLEAR_APPCACHE | CLEAR_DOM_QUOTA | CLEAR_DOM_PUSH_NOTIFICATIONS;
|
||||
|
||||
/**
|
||||
* Helper flag for forget about site
|
||||
*/
|
||||
const uint32_t CLEAR_FORGET_ABOUT_SITE =
|
||||
CLEAR_HISTORY | CLEAR_NETWORK_CACHE | CLEAR_IMAGE_CACHE | CLEAR_COOKIES |
|
||||
CLEAR_EME | CLEAR_PLUGIN_DATA | CLEAR_DOWNLOADS | CLEAR_PASSWORDS |
|
||||
CLEAR_PERMISSIONS | CLEAR_DOM_STORAGES | CLEAR_CONTENT_PREFERENCES |
|
||||
CLEAR_PREDICTOR_NETWORK_DATA | CLEAR_DOM_PUSH_NOTIFICATIONS |
|
||||
CLEAR_SECURITY_SETTINGS;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
add_task(async function test_basic() {
|
||||
const service = Cc["@mozilla.org/clear-data-service;1"]
|
||||
.getService(Ci.nsIClearDataService);
|
||||
Assert.ok(!!service);
|
||||
Assert.ok(!!Services.clearData);
|
||||
|
||||
await new Promise(aResolve => {
|
||||
service.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => {
|
||||
Assert.equal(value, 0);
|
||||
aResolve();
|
||||
});
|
||||
|
|
|
@ -10,10 +10,6 @@
|
|||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
add_task(async function test_all_cookies() {
|
||||
const service = Cc["@mozilla.org/clear-data-service;1"]
|
||||
.getService(Ci.nsIClearDataService);
|
||||
Assert.ok(!!service);
|
||||
|
||||
const expiry = Date.now() + 24 * 60 * 60;
|
||||
Services.cookies.add("example.net", "path", "name", "value", true /* secure */,
|
||||
true /* http only */, false /* session */,
|
||||
|
@ -21,7 +17,7 @@ add_task(async function test_all_cookies() {
|
|||
Assert.equal(Services.cookies.countCookiesFromHost("example.net"), 1);
|
||||
|
||||
await new Promise(aResolve => {
|
||||
service.deleteData(Ci.nsIClearDataService.CLEAR_COOKIES, value => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_COOKIES, value => {
|
||||
Assert.equal(value, 0);
|
||||
aResolve();
|
||||
});
|
||||
|
@ -31,10 +27,6 @@ add_task(async function test_all_cookies() {
|
|||
});
|
||||
|
||||
add_task(async function test_range_cookies() {
|
||||
const service = Cc["@mozilla.org/clear-data-service;1"]
|
||||
.getService(Ci.nsIClearDataService);
|
||||
Assert.ok(!!service);
|
||||
|
||||
const expiry = Date.now() + 24 * 60 * 60;
|
||||
Services.cookies.add("example.net", "path", "name", "value", true /* secure */,
|
||||
true /* http only */, false /* session */,
|
||||
|
@ -44,8 +36,8 @@ add_task(async function test_range_cookies() {
|
|||
// The cookie is out of time range here.
|
||||
let from = Date.now() + 60 * 60;
|
||||
await new Promise(aResolve => {
|
||||
service.deleteDataInTimeRange(from * 1000, expiry * 2000, true /* user request */,
|
||||
Ci.nsIClearDataService.CLEAR_COOKIES, value => {
|
||||
Services.clearData.deleteDataInTimeRange(from * 1000, expiry * 2000, true /* user request */,
|
||||
Ci.nsIClearDataService.CLEAR_COOKIES, value => {
|
||||
Assert.equal(value, 0);
|
||||
aResolve();
|
||||
});
|
||||
|
@ -56,8 +48,8 @@ add_task(async function test_range_cookies() {
|
|||
// Now we delete all.
|
||||
from = Date.now() - 60 * 60;
|
||||
await new Promise(aResolve => {
|
||||
service.deleteDataInTimeRange(from * 1000, expiry * 2000, true /* user request */,
|
||||
Ci.nsIClearDataService.CLEAR_COOKIES, value => {
|
||||
Services.clearData.deleteDataInTimeRange(from * 1000, expiry * 2000, true /* user request */,
|
||||
Ci.nsIClearDataService.CLEAR_COOKIES, value => {
|
||||
Assert.equal(value, 0);
|
||||
aResolve();
|
||||
});
|
||||
|
@ -67,10 +59,6 @@ add_task(async function test_range_cookies() {
|
|||
});
|
||||
|
||||
add_task(async function test_principal_cookies() {
|
||||
const service = Cc["@mozilla.org/clear-data-service;1"]
|
||||
.getService(Ci.nsIClearDataService);
|
||||
Assert.ok(!!service);
|
||||
|
||||
const expiry = Date.now() + 24 * 60 * 60;
|
||||
Services.cookies.add("example.net", "path", "name", "value", true /* secure */,
|
||||
true /* http only */, false /* session */,
|
||||
|
@ -80,8 +68,8 @@ add_task(async function test_principal_cookies() {
|
|||
let uri = Services.io.newURI("http://example.com");
|
||||
let principal = Services.scriptSecurityManager.createCodebasePrincipal(uri, {});
|
||||
await new Promise(aResolve => {
|
||||
service.deleteDataFromPrincipal(principal, true /* user request */,
|
||||
Ci.nsIClearDataService.CLEAR_COOKIES, value => {
|
||||
Services.clearData.deleteDataFromPrincipal(principal, true /* user request */,
|
||||
Ci.nsIClearDataService.CLEAR_COOKIES, value => {
|
||||
Assert.equal(value, 0);
|
||||
aResolve();
|
||||
});
|
||||
|
@ -93,8 +81,8 @@ add_task(async function test_principal_cookies() {
|
|||
uri = Services.io.newURI("http://example.net");
|
||||
principal = Services.scriptSecurityManager.createCodebasePrincipal(uri, {});
|
||||
await new Promise(aResolve => {
|
||||
service.deleteDataFromPrincipal(principal, true /* user request */,
|
||||
Ci.nsIClearDataService.CLEAR_COOKIES, value => {
|
||||
Services.clearData.deleteDataFromPrincipal(principal, true /* user request */,
|
||||
Ci.nsIClearDataService.CLEAR_COOKIES, value => {
|
||||
Assert.equal(value, 0);
|
||||
aResolve();
|
||||
});
|
||||
|
|
|
@ -38,11 +38,6 @@ async function createDownloadList() {
|
|||
|
||||
add_task(async function test_all_downloads() {
|
||||
const url = createFileURL();
|
||||
|
||||
const service = Cc["@mozilla.org/clear-data-service;1"]
|
||||
.getService(Ci.nsIClearDataService);
|
||||
Assert.ok(!!service);
|
||||
|
||||
const list = await createDownloadList();
|
||||
|
||||
// First download.
|
||||
|
@ -66,7 +61,7 @@ add_task(async function test_all_downloads() {
|
|||
Assert.equal(items.length, 2);
|
||||
|
||||
await new Promise(resolve => {
|
||||
service.deleteData(Ci.nsIClearDataService.CLEAR_DOWNLOADS, value => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_DOWNLOADS, value => {
|
||||
Assert.equal(value, 0);
|
||||
resolve();
|
||||
});
|
||||
|
@ -80,7 +75,7 @@ add_task(async function test_all_downloads() {
|
|||
await download.cancel();
|
||||
|
||||
await new Promise(resolve => {
|
||||
service.deleteData(Ci.nsIClearDataService.CLEAR_DOWNLOADS, value => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_DOWNLOADS, value => {
|
||||
Assert.equal(value, 0);
|
||||
resolve();
|
||||
});
|
||||
|
@ -92,12 +87,6 @@ add_task(async function test_all_downloads() {
|
|||
|
||||
add_task(async function test_range_downloads() {
|
||||
const url = createFileURL();
|
||||
|
||||
const service = Cc["@mozilla.org/clear-data-service;1"]
|
||||
.getService(Ci.nsIClearDataService);
|
||||
|
||||
Assert.ok(!!service);
|
||||
|
||||
const list = await createDownloadList();
|
||||
|
||||
let download = await Downloads.createDownload({
|
||||
|
@ -115,7 +104,7 @@ add_task(async function test_range_downloads() {
|
|||
Assert.equal(items.length, 1);
|
||||
|
||||
await new Promise(resolve => {
|
||||
service.deleteDataInTimeRange(download.startTime.getTime() * 1000,
|
||||
Services.clearData.deleteDataInTimeRange(download.startTime.getTime() * 1000,
|
||||
download.startTime.getTime() * 1000,
|
||||
true /* user request */,
|
||||
Ci.nsIClearDataService.CLEAR_DOWNLOADS, value => {
|
||||
|
@ -129,11 +118,6 @@ add_task(async function test_range_downloads() {
|
|||
});
|
||||
|
||||
add_task(async function test_principal_downloads() {
|
||||
const service = Cc["@mozilla.org/clear-data-service;1"]
|
||||
.getService(Ci.nsIClearDataService);
|
||||
|
||||
Assert.ok(!!service);
|
||||
|
||||
const list = await createDownloadList();
|
||||
|
||||
let download = await Downloads.createDownload({
|
||||
|
@ -157,7 +141,7 @@ add_task(async function test_principal_downloads() {
|
|||
let principal = Services.scriptSecurityManager.createCodebasePrincipal(uri, {});
|
||||
|
||||
await new Promise(resolve => {
|
||||
service.deleteDataFromPrincipal(principal,
|
||||
Services.clearData.deleteDataFromPrincipal(principal,
|
||||
true /* user request */,
|
||||
Ci.nsIClearDataService.CLEAR_DOWNLOADS, value => {
|
||||
Assert.equal(value, 0);
|
||||
|
@ -169,7 +153,7 @@ add_task(async function test_principal_downloads() {
|
|||
Assert.equal(items.length, 1);
|
||||
|
||||
await new Promise(resolve => {
|
||||
service.deleteData(Ci.nsIClearDataService.CLEAR_DOWNLOADS, value => {
|
||||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_DOWNLOADS, value => {
|
||||
Assert.equal(value, 0);
|
||||
resolve();
|
||||
});
|
||||
|
|
|
@ -18,7 +18,7 @@ var ForgetAboutSite = {
|
|||
["http://", "https://"].forEach(scheme => {
|
||||
promises.push(new Promise(resolve => {
|
||||
Services.clearData.deleteDataFromHost(aDomain, true /* user request */,
|
||||
Ci.nsIClearDataService.CLEAR_ALL,
|
||||
Ci.nsIClearDataService.CLEAR_FORGET_ABOUT_SITE,
|
||||
value => {
|
||||
errorCount += bitCounting(value);
|
||||
resolve();
|
||||
|
|
Загрузка…
Ссылка в новой задаче