Bug 1595934 - Make nsICookieManager cookie enumerators return Array<nsICookie> instead of nsISimpleEnumerator; r=baku

Differential Revision: https://phabricator.services.mozilla.com/D52761

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Ehsan Akhgari 2019-11-17 07:21:14 +00:00
Родитель 08068eb6ea
Коммит 30cf316b38
34 изменённых файлов: 91 добавлений и 132 удалений

Просмотреть файл

@ -69,7 +69,7 @@ function createDomainCookie(host, originAttributes) {
}
function checkCookie(host, originAttributes) {
for (let cookie of Services.cookies.enumerator) {
for (let cookie of Services.cookies.cookies) {
if (
ChromeUtils.isOriginAttributesEqual(
originAttributes,

Просмотреть файл

@ -67,7 +67,7 @@ const clearCookies = async function(options) {
if (options.since || options.hostnames) {
// Iterate through the cookies and delete any created after our cutoff.
for (const cookie of cookieMgr.enumerator) {
for (const cookie of cookieMgr.cookies) {
if (
(!options.since ||
cookie.creationTime >= PlacesUtils.toPRTime(options.since)) &&

Просмотреть файл

@ -85,7 +85,7 @@ add_task(async function cookie_test() {
await BrowserTestUtils.browserLoaded(tab.linkedBrowser, true);
let count = 0;
for (let cookie of Services.cookies.enumerator) {
for (let cookie of Services.cookies.cookies) {
count++;
Assert.equal(cookie.value, "foo", "Cookie value should be foo");
Assert.equal(

Просмотреть файл

@ -194,7 +194,7 @@ var SessionCookiesInternal = {
return;
}
for (let cookie of Services.cookies.sessionEnumerator) {
for (let cookie of Services.cookies.sessionCookies) {
this._addCookie(cookie);
}
},

Просмотреть файл

@ -25,7 +25,7 @@ add_task(async function() {
// verify our cookie got set during pageload
let i = 0;
for (var cookie of Services.cookies.enumerator) {
for (var cookie of Services.cookies.cookies) {
i++;
}
Assert.equal(i, 1, "expected one cookie");
@ -37,7 +37,7 @@ add_task(async function() {
await setBrowserState(state);
// at this point, the cookie should be restored...
for (var cookie2 of Services.cookies.enumerator) {
for (var cookie2 of Services.cookies.cookies) {
if (cookie.name == cookie2.name) {
break;
}

Просмотреть файл

@ -4,7 +4,7 @@ const TEST_URL = "http://example.com";
const MAX_EXPIRY = Math.pow(2, 62);
function getSingleCookie() {
let cookies = Array.from(Services.cookies.enumerator);
let cookies = Array.from(Services.cookies.cookies);
Assert.equal(cookies.length, 1, "expected one cookie");
return cookies[0];
}

Просмотреть файл

@ -810,9 +810,9 @@ class PrincipalsCollector {
// Let's take the list of unique hosts+OA from cookies.
progress.step = "principals-cookies";
let enumerator = Services.cookies.enumerator;
let cookies = Services.cookies.cookies;
let hosts = new Set();
for (let cookie of enumerator) {
for (let cookie of cookies) {
hosts.add(
cookie.rawHost +
ChromeUtils.originAttributesToSuffix(cookie.originAttributes)

Просмотреть файл

@ -178,7 +178,7 @@ var SiteDataManager = {
},
_getAllCookies() {
for (let cookie of Services.cookies.enumerator) {
for (let cookie of Services.cookies.cookies) {
let site = this._getOrInsertSite(cookie.rawHost);
site.cookies.push(cookie);
if (site.lastAccessed < cookie.lastAccessed) {

Просмотреть файл

@ -2,7 +2,7 @@ addMessageListener("getCookieFromManager", ({ host, path }) => {
let cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager);
let values = [];
path = path.substring(0, path.lastIndexOf("/"));
for (let cookie of cm.enumerator) {
for (let cookie of cm.cookies) {
if (!cookie) {
break;
}

Просмотреть файл

@ -30,7 +30,7 @@ async function realTest(noneRequiresSecure) {
let cookies = { test: null, test2: null, test3: null };
for (let cookie of Services.cookies.enumerator) {
for (let cookie of Services.cookies.cookies) {
if (cookie.host != "example.com") continue;
if (cookie.name == "test" && cookie.value == "wow") {

Просмотреть файл

@ -32,7 +32,7 @@ const clearCookies = async function(options) {
// Convert it to microseconds
let since = options.since * 1000;
// Iterate through the cookies and delete any created after our cutoff.
for (let cookie of cookieMgr.enumerator) {
for (let cookie of cookieMgr.cookies) {
if (cookie.creationTime >= since) {
// This cookie was created after our cutoff, clear it.
cookieMgr.remove(

Просмотреть файл

@ -46,15 +46,12 @@
#include "nsTArray.h"
#include "nsCOMArray.h"
#include "nsIMutableArray.h"
#include "nsArrayEnumerator.h"
#include "nsEnumeratorUtils.h"
#include "nsAutoPtr.h"
#include "nsReadableUtils.h"
#include "nsCRT.h"
#include "prprf.h"
#include "nsNetUtil.h"
#include "nsNetCID.h"
#include "nsISimpleEnumerator.h"
#include "nsIInputStream.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsNetCID.h"
@ -2427,7 +2424,7 @@ nsCookieService::RemoveAll() {
}
NS_IMETHODIMP
nsCookieService::GetEnumerator(nsISimpleEnumerator** aEnumerator) {
nsCookieService::GetCookies(nsTArray<RefPtr<nsICookie>>& aCookies) {
if (!mDBState) {
NS_WARNING("No DBState! Profile already closed?");
return NS_ERROR_NOT_AVAILABLE;
@ -2435,19 +2432,19 @@ nsCookieService::GetEnumerator(nsISimpleEnumerator** aEnumerator) {
EnsureReadComplete(true);
nsCOMArray<nsICookie> cookieList(mDBState->cookieCount);
aCookies.SetCapacity(mDBState->cookieCount);
for (auto iter = mDBState->hostTable.Iter(); !iter.Done(); iter.Next()) {
const nsCookieEntry::ArrayType& cookies = iter.Get()->GetCookies();
for (nsCookieEntry::IndexType i = 0; i < cookies.Length(); ++i) {
cookieList.AppendObject(cookies[i]);
aCookies.AppendElement(cookies[i]);
}
}
return NS_NewArrayEnumerator(aEnumerator, cookieList, NS_GET_IID(nsICookie));
return NS_OK;
}
NS_IMETHODIMP
nsCookieService::GetSessionEnumerator(nsISimpleEnumerator** aEnumerator) {
nsCookieService::GetSessionCookies(nsTArray<RefPtr<nsICookie>>& aCookies) {
if (!mDBState) {
NS_WARNING("No DBState! Profile already closed?");
return NS_ERROR_NOT_AVAILABLE;
@ -2455,19 +2452,19 @@ nsCookieService::GetSessionEnumerator(nsISimpleEnumerator** aEnumerator) {
EnsureReadComplete(true);
nsCOMArray<nsICookie> cookieList(mDBState->cookieCount);
aCookies.SetCapacity(mDBState->cookieCount);
for (auto iter = mDBState->hostTable.Iter(); !iter.Done(); iter.Next()) {
const nsCookieEntry::ArrayType& cookies = iter.Get()->GetCookies();
for (nsCookieEntry::IndexType i = 0; i < cookies.Length(); ++i) {
nsCookie* cookie = cookies[i];
// Filter out non-session cookies.
if (cookie->IsSession()) {
cookieList.AppendObject(cookie);
aCookies.AppendElement(cookie);
}
}
}
return NS_NewArrayEnumerator(aEnumerator, cookieList, NS_GET_IID(nsICookie));
return NS_OK;
}
NS_IMETHODIMP

Просмотреть файл

@ -13,7 +13,6 @@ class OriginAttributes;
[ptr] native OriginAttributesPtr(mozilla::OriginAttributes);
interface nsISimpleEnumerator;
interface nsICookie;
interface nsIFile;
@ -32,20 +31,20 @@ interface nsICookieManager : nsISupports
void removeAll();
/**
* Called to enumerate through each cookie in the cookie list.
* The objects enumerated over are of type nsICookie
* This enumerator should only be used for non-private browsing cookies.
* To retrieve an enumerator for private browsing cookies, use
* Returns an array of cookies in the cookie list.
* The objects in the array are of type nsICookie
* This array only contains non-private browsing cookies.
* To retrieve an array of private browsing cookies, use
* getCookiesWithOriginAttributes.
*/
readonly attribute nsISimpleEnumerator enumerator;
readonly attribute Array<nsICookie> cookies;
/**
* Called to enumerate through each session cookie in the cookie list.
* The objects enumerated over are of type nsICookie
* This enumerator should only be used for non-private browsing cookies.
* Returns an array of session cookies in the cookie list.
* The objects in the array are of type nsICookie
* This array only contains non-private browsing cookies.
*/
readonly attribute nsISimpleEnumerator sessionEnumerator;
readonly attribute Array<nsICookie> sessionCookies;
/**
* Called to remove an individual cookie from the cookie list, specified
@ -178,7 +177,7 @@ interface nsICookieManager : nsISupports
unsigned long countCookiesFromHost(in AUTF8String aHost);
/**
* Returns an enumerator of cookies that exist within the base domain of
* Returns an array of cookies that exist within the base domain of
* 'aHost'. Thus, for a host "weather.yahoo.com", the base domain would be
* "yahoo.com", and any host or domain cookies for "yahoo.com" and its
* subdomains would be returned.
@ -190,7 +189,7 @@ interface nsICookieManager : nsISupports
* @param aOriginAttributes The originAttributes of cookies that would be
* retrived.
*
* @return an nsISimpleEnumerator of nsICookie objects.
* @return an array of nsICookie objects.
*
* @see countCookiesFromHost
*/

Просмотреть файл

@ -58,8 +58,8 @@ conn.executeSimpleSQL(
);
// Now start the cookie service, and then check the fields in the table.
// Get sessionEnumerator to wait for the initialization in cookie thread
const enumerator = Services.cookies.sessionEnumerator;
// Get sessionCookies to wait for the initialization in cookie thread
const cookies = Services.cookies.sessionCookies;
Assert.equal(conn.schemaVersion, 10);
let stmt = conn.createStatement(

Просмотреть файл

@ -15,7 +15,6 @@
#include "nsIChannel.h"
#include "nsIPrincipal.h"
#include "nsIScriptSecurityManager.h"
#include "nsISimpleEnumerator.h"
#include "nsServiceManagerUtils.h"
#include "nsNetCID.h"
#include "nsIPrefBranch.h"
@ -883,28 +882,18 @@ TEST(TestCookie, TestCookieMain)
&attrs, // originAttributes
nsICookie::SAMESITE_NONE)));
// confirm using enumerator
nsCOMPtr<nsISimpleEnumerator> enumerator;
EXPECT_TRUE(
NS_SUCCEEDED(cookieMgr->GetEnumerator(getter_AddRefs(enumerator))));
int32_t i = 0;
bool more;
nsTArray<RefPtr<nsICookie>> cookies;
EXPECT_TRUE(NS_SUCCEEDED(cookieMgr->GetCookies(cookies)));
nsCOMPtr<nsICookie> expiredCookie, newDomainCookie;
while (NS_SUCCEEDED(enumerator->HasMoreElements(&more)) && more) {
nsCOMPtr<nsISupports> cookie;
if (NS_FAILED(enumerator->GetNext(getter_AddRefs(cookie)))) break;
++i;
// keep tabs on the second and third cookies, so we can check them later
nsCOMPtr<nsICookie> cookie2(do_QueryInterface(cookie));
if (!cookie2) break;
for (const auto& cookie : cookies) {
nsAutoCString name;
cookie2->GetName(name);
cookie->GetName(name);
if (name.EqualsLiteral("test2"))
expiredCookie = cookie2;
expiredCookie = cookie;
else if (name.EqualsLiteral("test3"))
newDomainCookie = cookie2;
newDomainCookie = cookie;
}
EXPECT_EQ(i, 3);
EXPECT_EQ(cookies.Length(), 3ul);
// check the httpOnly attribute of the second cookie is honored
GetACookie(cookieService, "http://cookiemgr.test/foo/", nullptr, cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_CONTAIN, "test2=yes"));
@ -935,9 +924,9 @@ TEST(TestCookie, TestCookieMain)
EXPECT_TRUE(found);
// double-check RemoveAll() using the enumerator
EXPECT_TRUE(NS_SUCCEEDED(cookieMgr->RemoveAll()));
EXPECT_TRUE(
NS_SUCCEEDED(cookieMgr->GetEnumerator(getter_AddRefs(enumerator))) &&
NS_SUCCEEDED(enumerator->HasMoreElements(&more)) && !more);
cookies.SetLength(0);
EXPECT_TRUE(NS_SUCCEEDED(cookieMgr->GetCookies(cookies)) &&
cookies.IsEmpty());
// *** eviction and creation ordering tests
@ -1004,18 +993,10 @@ TEST(TestCookie, TestCookieMain)
SetASameSiteCookie(cookieService, "http://samesite.test", nullptr,
"lax=yes; samesite=lax", nullptr, false);
EXPECT_TRUE(
NS_SUCCEEDED(cookieMgr->GetEnumerator(getter_AddRefs(enumerator))));
i = 0;
cookies.SetLength(0);
EXPECT_TRUE(NS_SUCCEEDED(cookieMgr->GetCookies(cookies)));
// check the cookies for the required samesite value
while (NS_SUCCEEDED(enumerator->HasMoreElements(&more)) && more) {
nsCOMPtr<nsISupports> cookie;
if (NS_FAILED(enumerator->GetNext(getter_AddRefs(cookie)))) break;
++i;
}
EXPECT_TRUE(i == 0);
EXPECT_TRUE(cookies.IsEmpty());
// Set cookies with various incantations of the samesite attribute:
// No same site attribute present
@ -1037,23 +1018,15 @@ TEST(TestCookie, TestCookieMain)
SetASameSiteCookie(cookieService, "http://samesite.test", nullptr,
"lax=yes; samesite=lax", nullptr, true);
EXPECT_TRUE(
NS_SUCCEEDED(cookieMgr->GetEnumerator(getter_AddRefs(enumerator))));
i = 0;
cookies.SetLength(0);
EXPECT_TRUE(NS_SUCCEEDED(cookieMgr->GetCookies(cookies)));
// check the cookies for the required samesite value
while (NS_SUCCEEDED(enumerator->HasMoreElements(&more)) && more) {
nsCOMPtr<nsISupports> cookie;
if (NS_FAILED(enumerator->GetNext(getter_AddRefs(cookie)))) break;
++i;
// keep tabs on the second and third cookies, so we can check them later
nsCOMPtr<nsICookie> cookie2(do_QueryInterface(cookie));
if (!cookie2) break;
for (const auto& cookie : cookies) {
nsAutoCString name;
cookie2->GetName(name);
cookie->GetName(name);
int32_t sameSiteAttr;
cookie2->GetSameSite(&sameSiteAttr);
cookie->GetSameSite(&sameSiteAttr);
if (name.EqualsLiteral("unset")) {
EXPECT_TRUE(sameSiteAttr == nsICookie::SAMESITE_NONE);
} else if (name.EqualsLiteral("unspecified")) {
@ -1069,7 +1042,7 @@ TEST(TestCookie, TestCookieMain)
}
}
EXPECT_TRUE(i == 6);
EXPECT_TRUE(cookies.Length() == 6);
// *** SameSite attribute
// Clear the cookies

Просмотреть файл

@ -2,7 +2,7 @@ let cs = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager);
addMessageListener("getCookieCountAndClear", () => {
let count = 0;
for (let cookie of cs.enumerator) {
for (let cookie of cs.cookies) {
++count;
}
cs.removeAll();

Просмотреть файл

@ -4,7 +4,7 @@ function getCookieService() {
function getCookies(cs) {
let cookies = [];
for (let cookie of cs.enumerator) {
for (let cookie of cs.cookies) {
cookies.push({
host: cookie.host,
path: cookie.path,

Просмотреть файл

@ -68,7 +68,7 @@ obs.prototype = {
function getCookieCount(cs) {
let count = 0;
for (let cookie of cs.enumerator) {
for (let cookie of cs.cookies) {
info("cookie: " + cookie);
info(
"cookie host " +

Просмотреть файл

@ -149,17 +149,8 @@ function do_set_cookies(uri, channel, session, expected) {
Assert.equal(Services.cookiemgr.countCookiesFromHost(uri.host), expected[3]);
}
function do_count_enumerator(enumerator) {
let i = 0;
for (let cookie of enumerator) {
void cookie;
++i;
}
return i;
}
function do_count_cookies() {
return do_count_enumerator(Services.cookiemgr.enumerator);
return Services.cookiemgr.cookies.length;
}
// Helper object to store cookie data.

Просмотреть файл

@ -19,7 +19,7 @@ function run_test() {
const now = Math.floor(new Date().getTime() / 1000);
var found = false;
for (let cookie of cm.enumerator) {
for (let cookie of cm.cookies) {
if (
cookie.host == "example.com" &&
cookie.path == "/" &&

Просмотреть файл

@ -257,7 +257,7 @@ function run_test() {
function getCookieCount() {
var count = 0;
var cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager);
for (let cookie of cm.enumerator) {
for (let cookie of cm.cookies) {
++count;
}
return count;

Просмотреть файл

@ -30,10 +30,9 @@ function* do_run_test() {
// Set a cookie.
let uri = NetUtil.newURI("http://foo.com");
Services.cookies.setCookieString(uri, null, "oh=hai; max-age=1000", null);
let enumerator = Services.cookiemgr.enumerator;
Assert.ok(enumerator.hasMoreElements());
let cookie = enumerator.getNext().QueryInterface(Ci.nsICookie);
Assert.ok(!enumerator.hasMoreElements());
let cookies = Services.cookiemgr.cookies;
Assert.ok(cookies.length == 1);
let cookie = cookies[0];
// Fire 'profile-before-change'.
do_close_profile();
@ -57,7 +56,7 @@ function* do_run_test() {
}, Cr.NS_ERROR_NOT_AVAILABLE);
do_check_throws(function() {
Services.cookiemgr.enumerator;
Services.cookiemgr.cookies;
}, Cr.NS_ERROR_NOT_AVAILABLE);
do_check_throws(function() {

Просмотреть файл

@ -27,8 +27,8 @@ function* do_run_test() {
Services.prefs.setIntPref("network.cookie.cookieBehavior", 0);
// Start the cookieservice, to force creation of a database.
// Get the sessionEnumerator to join the initialization in cookie thread
Services.cookiemgr.sessionEnumerator;
// Get the sessionCookies to join the initialization in cookie thread
Services.cookiemgr.sessionCookies;
// Open a database connection now, after synchronous initialization has
// completed. We may not be able to open one later once asynchronous writing

Просмотреть файл

@ -56,7 +56,7 @@ function* do_run_test() {
setCookies("tasty.horse.radish", 50, futureExpiry);
Assert.equal(countCookies("horse.radish", "horse.radish"), 50);
for (let cookie of Services.cookiemgr.enumerator) {
for (let cookie of Services.cookiemgr.cookies) {
if (cookie.host == "horse.radish") {
do_throw("cookies not evicted by lastAccessed order");
}
@ -125,15 +125,15 @@ function setCookies(aHost, aNumber, aExpiry) {
// count how many cookies are within domain 'aBaseDomain', using three
// independent interface methods on nsICookieManager:
// 1) 'enumerator', an enumerator of all cookies;
// 1) 'cookies', an array of all cookies;
// 2) 'countCookiesFromHost', which returns the number of cookies within the
// base domain of 'aHost',
// 3) 'getCookiesFromHost', which returns an enumerator of 2).
// 3) 'getCookiesFromHost', which returns an array of 2).
function countCookies(aBaseDomain, aHost) {
// count how many cookies are within domain 'aBaseDomain' using the cookie
// enumerator.
// count how many cookies are within domain 'aBaseDomain' using the cookies
// array.
let cookies = [];
for (let cookie of Services.cookiemgr.enumerator) {
for (let cookie of Services.cookiemgr.cookies) {
if (
cookie.host.length >= aBaseDomain.length &&
cookie.host.slice(cookie.host.length - aBaseDomain.length) == aBaseDomain
@ -165,7 +165,7 @@ function countCookies(aBaseDomain, aHost) {
}
if (!found) {
do_throw("cookie " + cookie.name + " not found in master enumerator");
do_throw("cookie " + cookie.name + " not found in master cookies");
}
} else {
do_throw(

Просмотреть файл

@ -235,7 +235,7 @@ function get_creationTime(i) {
// + 10% are exceeded.
function check_remaining_cookies(aNumberTotal, aNumberOld, aNumberToExpect) {
let i = 0;
for (let cookie of Services.cookiemgr.enumerator) {
for (let cookie of Services.cookiemgr.cookies) {
++i;
if (aNumberTotal != aNumberToExpect) {

Просмотреть файл

@ -23,8 +23,8 @@ function* do_run_test() {
let profile = do_get_profile();
// Start the cookieservice, to force creation of a database.
// Get the sessionEnumerator to join the initialization in cookie thread
Services.cookiemgr.sessionEnumerator;
// Get the sessionCookies to join the initialization in cookie thread
Services.cookiemgr.sessionCookies;
// Close the profile.
do_close_profile(test_generator);

Просмотреть файл

@ -23,8 +23,8 @@ function* do_run_test() {
let profile = do_get_profile();
// Start the cookieservice, to force creation of a database.
// Get the sessionEnumerator to join the initialization in cookie thread
Services.cookiemgr.sessionEnumerator;
// Get the sessionCookies to join the initialization in cookie thread
Services.cookiemgr.sessionCookies;
// Close the profile.
do_close_profile(test_generator);

Просмотреть файл

@ -73,9 +73,9 @@ const CookieCleaner = {
},
deleteByRange(aFrom, aTo) {
let enumerator = Services.cookies.enumerator;
let cookies = Services.cookies.cookies;
return this._deleteInternal(
enumerator,
cookies,
aCookie => aCookie.creationTime > aFrom
);
},
@ -87,13 +87,13 @@ const CookieCleaner = {
});
},
_deleteInternal(aEnumerator, aCb) {
_deleteInternal(aCookies, aCb) {
// A number of iterations after which to yield time back to the system.
const YIELD_PERIOD = 10;
return new Promise((aResolve, aReject) => {
let count = 0;
for (let cookie of aEnumerator) {
for (let cookie of aCookies) {
if (aCb(cookie)) {
Services.cookies.remove(
cookie.host,
@ -104,7 +104,7 @@ const CookieCleaner = {
// We don't want to block the main-thread.
if (++count % YIELD_PERIOD == 0) {
setTimeout(() => {
this._deleteInternal(aEnumerator, aCb).then(aResolve, aReject);
this._deleteInternal(aCookies, aCb).then(aResolve, aReject);
}, 0);
return;
}

Просмотреть файл

@ -142,7 +142,7 @@ var SiteDataTestUtils = {
let principal = Services.scriptSecurityManager.createContentPrincipalFromOrigin(
origin
);
for (let cookie of Services.cookies.enumerator) {
for (let cookie of Services.cookies.cookies) {
if (
ChromeUtils.isOriginAttributesEqual(
principal.originAttributes,

Просмотреть файл

@ -606,7 +606,7 @@ _ContextualIdentityService.prototype = {
// Collect the userContextIds currently used by any stored cookie.
let cookiesUserContextIds = new Set();
for (let cookie of Services.cookies.enumerator) {
for (let cookie of Services.cookies.cookies) {
// Skip any userContextIds that should not be cleared.
if (
cookie.originAttributes.userContextId >= minUserContextId &&

Просмотреть файл

@ -54,7 +54,7 @@ server.registerPathHandler("/sw.js", (request, response) => {
function assertCookiesForHost(url, cookiesCount, message) {
const { host } = new URL(url);
const cookies = Array.from(Services.cookies.enumerator).filter(
const cookies = Services.cookies.cookies.filter(
cookie => cookie.host === host
);
equal(cookies.length, cookiesCount, message);
@ -279,7 +279,7 @@ add_task(async function test_ext_page_3rdparty_cookies() {
function clearAllCookies() {
Services.cookies.removeAll();
let cookies = Array.from(Services.cookies.enumerator);
let cookies = Services.cookies.cookies;
equal(cookies.length, 0, "There shouldn't be any cookies after clearing");
}

Просмотреть файл

@ -46,9 +46,9 @@ function countCacheEntries() {
function countCookieEntries() {
info("Enumerating cookies");
let enumerator = Services.cookies.enumerator;
let cookies = Services.cookies.cookies;
let cookieCount = 0;
for (let cookie of enumerator) {
for (let cookie of cookies) {
info(
"Cookie:" + cookie.rawHost + " " + JSON.stringify(cookie.originAttributes)
);

Просмотреть файл

@ -24,9 +24,9 @@ var ForgetAboutSite = {
try {
let baseDomain = Services.eTLD.getBaseDomainFromHost(aDomain);
let enumerator = Services.cookies.enumerator;
let cookies = Services.cookies.cookies;
let hosts = new Set();
for (let cookie of enumerator) {
for (let cookie of cookies) {
if (Services.eTLD.hasRootDomain(cookie.rawHost, baseDomain)) {
hosts.add(cookie.rawHost);
}

Просмотреть файл

@ -6,7 +6,7 @@ const { SiteDataTestUtils } = ChromeUtils.import(
);
function checkCookie(host, originAttributes) {
for (let cookie of Services.cookies.enumerator) {
for (let cookie of Services.cookies.cookies) {
if (
ChromeUtils.isOriginAttributesEqual(
originAttributes,