Bug 1574469 - Removed block param from nsICookieManager::Remove. r=Ehsan

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Paul Zuehlcke 2019-09-19 17:10:58 +00:00
Родитель 7dbb6cb72e
Коммит b7de7aec93
23 изменённых файлов: 21 добавлений и 109 удалений

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

@ -83,7 +83,6 @@ add_task(async function test_cookie_getCookiesWithOriginAttributes() {
cookie.host,
cookie.name,
cookie.path,
false,
cookie.originAttributes
);
}

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

@ -73,7 +73,6 @@ function deleteCookies(onlyContext = null) {
cookie.host,
cookie.name,
cookie.path,
false,
cookie.originAttributes
);
}

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

@ -79,7 +79,6 @@ const clearCookies = async function(options) {
cookie.host,
cookie.name,
cookie.path,
false,
cookie.originAttributes
);

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

@ -698,7 +698,7 @@ Cookies.prototype = {
// a domain cookie. See bug 222343.
if (host.length) {
// Fist delete any possible extant matching host cookie.
Services.cookies.remove(host, name, path, false, {});
Services.cookies.remove(host, name, path, {});
// Now make it a domain cookie.
if (host[0] != "." && !hostIsIPAddress(host)) {
host = "." + host;

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

@ -101,10 +101,10 @@ const DiscoveryInternal = {
async update(reset = false) {
if (reset || !Discovery.enabled) {
for (let site of this.sites) {
Services.cookies.remove(site, TAAR_COOKIE_NAME, "/", false, {});
Services.cookies.remove(site, TAAR_COOKIE_NAME, "/", {});
ContextualIdentityService.getPublicIdentities().forEach(identity => {
let { userContextId } = identity;
Services.cookies.remove(site, TAAR_COOKIE_NAME, "/", false, {
Services.cookies.remove(site, TAAR_COOKIE_NAME, "/", {
userContextId,
});
});

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

@ -427,7 +427,6 @@ var SiteDataManager = {
cookie.host,
cookie.name,
cookie.path,
false,
cookie.originAttributes
);
}

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

@ -970,7 +970,6 @@ var cookieHelpers = {
origHost,
origName,
origPath,
false,
cookie.originAttributes
);
break;
@ -1037,7 +1036,6 @@ var cookieHelpers = {
cookie.host,
cookie.name,
cookie.path,
false,
cookie.originAttributes
);
}

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

@ -39,7 +39,6 @@ const clearCookies = async function(options) {
cookie.host,
cookie.name,
cookie.path,
false,
cookie.originAttributes
);

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

@ -36,8 +36,6 @@ using namespace mozilla;
static const bool kDefaultPolicy = true;
static const nsLiteralCString kPermissionType(NS_LITERAL_CSTRING("cookie"));
namespace {
mozilla::StaticRefPtr<nsCookiePermission> gSingleton;
}
@ -62,20 +60,6 @@ bool nsCookiePermission::Init() {
return mPermMgr != nullptr;
}
NS_IMETHODIMP
nsCookiePermission::SetAccess(nsIURI* aURI, nsCookieAccess aAccess) {
// Lazily initialize ourselves
if (!EnsureInitialized()) return NS_ERROR_UNEXPECTED;
//
// NOTE: nsCookieAccess values conveniently match up with
// the permission codes used by nsIPermissionManager.
// this is nice because it avoids conversion code.
//
return mPermMgr->Add(aURI, kPermissionType, aAccess,
nsIPermissionManager::EXPIRE_NEVER, 0);
}
NS_IMETHODIMP
nsCookiePermission::CanSetCookie(nsIURI* aURI, nsIChannel* aChannel,
nsICookie* aCookie, bool* aIsSession,
@ -90,7 +74,7 @@ nsCookiePermission::CanSetCookie(nsIURI* aURI, nsIChannel* aChannel,
nsCookie* cookie = static_cast<nsCookie*>(aCookie);
uint32_t perm;
mPermMgr->LegacyTestPermissionFromURI(aURI, &cookie->OriginAttributesRef(),
kPermissionType, &perm);
NS_LITERAL_CSTRING("cookie"), &perm);
switch (perm) {
case nsICookiePermission::ACCESS_SESSION:
*aIsSession = true;

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

@ -2527,7 +2527,7 @@ nsCookieService::AddNative(const nsACString& aHost, const nsACString& aPath,
nsresult nsCookieService::Remove(const nsACString& aHost,
const OriginAttributes& aAttrs,
const nsACString& aName,
const nsACString& aPath, bool aBlocked) {
const nsACString& aPath) {
if (!mDBState) {
NS_WARNING("No DBState! Profile already closed?");
return NS_ERROR_NOT_AVAILABLE;
@ -2557,20 +2557,6 @@ nsresult nsCookieService::Remove(const nsACString& aHost,
RemoveCookieFromList(matchIter);
}
// check if we need to add the host to the permissions blacklist.
if (aBlocked && mPermissionService) {
// strip off the domain dot, if necessary
if (!host.IsEmpty() && host.First() == '.') host.Cut(0, 1);
host.InsertLiteral("http://", 0);
nsCOMPtr<nsIURI> uri;
NS_NewURI(getter_AddRefs(uri), host);
if (uri)
mPermissionService->SetAccess(uri, nsICookiePermission::ACCESS_DENY);
}
if (cookie) {
// Everything's done. Notify observers.
NotifyChanged(cookie, u"deleted");
@ -2581,7 +2567,7 @@ nsresult nsCookieService::Remove(const nsACString& aHost,
NS_IMETHODIMP
nsCookieService::Remove(const nsACString& aHost, const nsACString& aName,
const nsACString& aPath, bool aBlocked,
const nsACString& aPath,
JS::HandleValue aOriginAttributes, JSContext* aCx) {
OriginAttributes attrs;
@ -2589,18 +2575,18 @@ nsCookieService::Remove(const nsACString& aHost, const nsACString& aName,
return NS_ERROR_INVALID_ARG;
}
return RemoveNative(aHost, aName, aPath, aBlocked, &attrs);
return RemoveNative(aHost, aName, aPath, &attrs);
}
NS_IMETHODIMP_(nsresult)
nsCookieService::RemoveNative(const nsACString& aHost, const nsACString& aName,
const nsACString& aPath, bool aBlocked,
const nsACString& aPath,
OriginAttributes* aOriginAttributes) {
if (NS_WARN_IF(!aOriginAttributes)) {
return NS_ERROR_FAILURE;
}
nsresult rv = Remove(aHost, *aOriginAttributes, aName, aPath, aBlocked);
nsresult rv = Remove(aHost, *aOriginAttributes, aName, aPath);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}

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

@ -342,8 +342,7 @@ class nsCookieService final : public nsICookieService,
* NOTE: this could be added to a public interface if we happen to need it.
*/
nsresult Remove(const nsACString& aHost, const OriginAttributes& aAttrs,
const nsACString& aName, const nsACString& aPath,
bool aBlocked);
const nsACString& aName, const nsACString& aPath);
protected:
nsresult RemoveCookiesFromExactHost(

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

@ -60,22 +60,18 @@ interface nsICookieManager : nsISupports
* @param aName The name specified in the cookie
* @param aPath The path for which the cookie was set
* @param aOriginAttributes The originAttributes of this cookie.
* @param aBlocked Indicates if cookies from this host should be permanently
* blocked.
*
*/
[implicit_jscontext]
void remove(in AUTF8String aHost,
in ACString aName,
in AUTF8String aPath,
in boolean aBlocked,
in jsval aOriginAttributes);
[notxpcom]
nsresult removeNative(in AUTF8String aHost,
in ACString aName,
in AUTF8String aPath,
in boolean aBlocked,
in OriginAttributesPtr aOriginAttributes);
/**

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

@ -38,21 +38,6 @@ interface nsICookiePermission : nsISupports
* ancient user profiles.
*/
/**
* setAccess
*
* this method is called to block cookie access for the given URI. this
* may result in other URIs being blocked as well (e.g., URIs which share
* the same host name).
*
* @param aURI
* the URI to block
* @param aAccess
* the new cookie access for the URI.
*/
void setAccess(in nsIURI aURI,
in nsCookieAccess aAccess);
/**
* canSetCookie
*

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

@ -922,32 +922,6 @@ TEST(TestCookie, TestCookieMain)
NS_LITERAL_CSTRING("test3"), &attrs, &found)));
EXPECT_TRUE(found);
// remove the cookie, block it, and ensure it can't be added again
EXPECT_TRUE(NS_SUCCEEDED(
cookieMgr->RemoveNative(NS_LITERAL_CSTRING("new.domain"), // domain
NS_LITERAL_CSTRING("test3"), // name
NS_LITERAL_CSTRING("/rabbit"), // path
true, // is blocked
&attrs))); // originAttributes
EXPECT_TRUE(NS_SUCCEEDED(cookieMgr2->CookieExistsNative(
NS_LITERAL_CSTRING("new.domain"), NS_LITERAL_CSTRING("/rabbit"),
NS_LITERAL_CSTRING("test3"), &attrs, &found)));
EXPECT_FALSE(found);
EXPECT_TRUE(NS_SUCCEEDED(
cookieMgr2->AddNative(NS_LITERAL_CSTRING("new.domain"), // domain
NS_LITERAL_CSTRING("/rabbit"), // path
NS_LITERAL_CSTRING("test3"), // name
NS_LITERAL_CSTRING("yes"), // value
false, // is secure
false, // is httponly
true, // is session
INT64_MIN, // expiry time
&attrs, // originAttributes
nsICookie::SAMESITE_NONE)));
EXPECT_TRUE(NS_SUCCEEDED(cookieMgr2->CookieExistsNative(
NS_LITERAL_CSTRING("new.domain"), NS_LITERAL_CSTRING("/rabbit"),
NS_LITERAL_CSTRING("test3"), &attrs, &found)));
EXPECT_FALSE(found);
// sleep four seconds, to make sure the second cookie has expired
PR_Sleep(4 * PR_TicksPerSecond());
// check that both CountCookiesFromHost() and CookieExistsNative() count the

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

@ -39,9 +39,9 @@ function run_test() {
do_check_throws(function() {
cm.countCookiesFromHost("..baz.com");
}, Cr.NS_ERROR_ILLEGAL_VALUE);
cm.remove("BAZ.com.", "foo", "/", false, {});
cm.remove("BAZ.com.", "foo", "/", {});
Assert.equal(cm.countCookiesFromHost("baz.com"), 1);
cm.remove("baz.com", "foo", "/", false, {});
cm.remove("baz.com", "foo", "/", {});
Assert.equal(cm.countCookiesFromHost("baz.com"), 0);
// Test that 'baz.com' and 'baz.com.' are treated differently
@ -62,9 +62,9 @@ function run_test() {
Assert.equal(cm.countCookiesFromHost(".baz.com"), 0);
Assert.equal(cm.countCookiesFromHost("baz.com."), 1);
Assert.equal(cm.countCookiesFromHost(".baz.com."), 1);
cm.remove("baz.com", "foo", "/", false, {});
cm.remove("baz.com", "foo", "/", {});
Assert.equal(cm.countCookiesFromHost("baz.com."), 1);
cm.remove("baz.com.", "foo", "/", false, {});
cm.remove("baz.com.", "foo", "/", {});
Assert.equal(cm.countCookiesFromHost("baz.com."), 0);
// test that domain cookies are illegal for IP addresses, aliases such as
@ -238,10 +238,10 @@ function run_test() {
}, Cr.NS_ERROR_ILLEGAL_VALUE);
Assert.equal(getCookieCount(), 1);
cm.remove("", "foo2", "/", false, {});
cm.remove("", "foo2", "/", {});
Assert.equal(getCookieCount(), 0);
do_check_throws(function() {
cm.remove(".", "foo3", "/", false, {});
cm.remove(".", "foo3", "/", {});
}, Cr.NS_ERROR_ILLEGAL_VALUE);
// test that the 'domain' attribute accepts a leading dot for IP addresses,

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

@ -76,7 +76,7 @@ function* do_run_test() {
}, Cr.NS_ERROR_NOT_AVAILABLE);
do_check_throws(function() {
Services.cookiemgr.remove("foo.com", "", "oh4", false, {});
Services.cookiemgr.remove("foo.com", "", "oh4", {});
}, Cr.NS_ERROR_NOT_AVAILABLE);
do_check_throws(function() {

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

@ -87,11 +87,11 @@ function* do_run_test() {
// remove some of the cookies, in both reverse and forward order
for (let i = 100; i-- > 0; ) {
let host = i.toString() + ".com";
Services.cookiemgr.remove(host, "oh", "/", false, {});
Services.cookiemgr.remove(host, "oh", "/", {});
}
for (let i = CMAX - 100; i < CMAX; ++i) {
let host = i.toString() + ".com";
Services.cookiemgr.remove(host, "oh", "/", false, {});
Services.cookiemgr.remove(host, "oh", "/", {});
}
// check the count

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

@ -84,7 +84,6 @@ const CookieCleaner = {
cookie.host,
cookie.name,
cookie.path,
false,
cookie.originAttributes
);
// We don't want to block the main-thread.

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

@ -499,7 +499,6 @@ this.cookies = class extends ExtensionAPI {
cookie.host,
cookie.name,
cookie.path,
false,
cookie.originAttributes
);

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

@ -199,7 +199,7 @@ async function testCookies(options) {
{},
Ci.nsICookie.SAMESITE_NONE
);
Services.cookies.remove(domain, "x", "/", false, {});
Services.cookies.remove(domain, "x", "/", {});
sendAsyncMessage("done");
});
});
@ -259,7 +259,7 @@ async function testCookies(options) {
}
for (let cookie of cookies) {
cookieSvc.remove(cookie.host, cookie.name, "/", false, {});
cookieSvc.remove(cookie.host, cookie.name, "/", {});
}
// Make sure we don't silently poison subsequent tests if something goes wrong.
assert.equal(getCookies(options.domain).length, 0, "cookies cleared");

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

@ -50,7 +50,6 @@ function finish_test(count) {
"example.com",
"xpinstall",
"/browser/" + RELATIVE_DIR,
false,
{}
);

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

@ -52,7 +52,6 @@ function finish_test(count) {
"example.com",
"xpinstall",
"/browser/" + RELATIVE_DIR,
false,
{}
);

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

@ -53,7 +53,6 @@ function finish_test(count) {
"example.org",
"xpinstall",
"/browser/" + RELATIVE_DIR,
false,
{}
);