Bug 1631523 - Remove unused params in nsICookieService methods - setCookieStringFromHttp without first URI, r=dimi

Depends on D71611

Differential Revision: https://phabricator.services.mozilla.com/D71612
This commit is contained in:
Andrea Marchesini 2020-04-20 18:58:28 +00:00
Родитель 4eec356d45
Коммит ebc905d3f2
15 изменённых файлов: 154 добавлений и 226 удалений

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

@ -425,7 +425,7 @@ CookieService::SetCookieString(nsIURI* aHostURI,
}
NS_IMETHODIMP
CookieService::SetCookieStringFromHttp(nsIURI* aHostURI, nsIURI* /*aFirstURI*/,
CookieService::SetCookieStringFromHttp(nsIURI* aHostURI,
const nsACString& aCookieHeader,
nsIChannel* aChannel) {
return SetCookieStringCommon(aHostURI, aCookieHeader, aChannel, true);

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

@ -585,7 +585,6 @@ CookieServiceChild::SetCookieString(nsIURI* aHostURI,
NS_IMETHODIMP
CookieServiceChild::SetCookieStringFromHttp(nsIURI* aHostURI,
nsIURI* /*aFirstURI*/,
const nsACString& aCookieString,
nsIChannel* aChannel) {
return SetCookieStringInternal(aHostURI, aChannel, aCookieString, true);

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

@ -156,9 +156,6 @@ interface nsICookieService : nsISupports
* file:// URIs (i.e. with an empty host) are allowed, but any other
* scheme must have a non-empty host. A trailing dot in the host
* is acceptable, and will be stripped. This argument must not be null.
* @param aFirstURI
* the URI that the user originally typed in or clicked on to initiate
* the load of the document referenced by aURI.
* @param aCookie
* the cookie string to set.
* @param aChannel
@ -168,9 +165,8 @@ interface nsICookieService : nsISupports
* to determine the originating URI of the document; if it is not
* provided, the cookies will be assumed third-party.)
*/
void setCookieStringFromHttp(in nsIURI aURI, in nsIURI aFirstURI,
in ACString aCookie, in nsIChannel aChannel);
void setCookieStringFromHttp(in nsIURI aURI, in ACString aCookie,
in nsIChannel aChannel);
/*
* Batch SQLite operations into one transaction. By default each call to

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

@ -73,7 +73,7 @@ function setCookie(value, expected) {
}
Services.obs.addObserver(observer, "cookie-changed");
cs.setCookieStringFromHttp(URI, null, valueInternal, null);
cs.setCookieStringFromHttp(URI, valueInternal, null);
Services.obs.removeObserver(observer, "cookie-changed");
}

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

@ -11,7 +11,7 @@ function run_test() {
let set = "foo=bar\nbaz=foo";
let expected = "foo=bar; baz=foo";
cs.setCookieStringFromHttp(uri, null, set, null);
cs.setCookieStringFromHttp(uri, set, null);
let actual = cs.getCookieStringFromHttp(uri, null);
Assert.equal(actual, expected);

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

@ -176,7 +176,7 @@ function setCookie(name, domain, path, maxAge, url) {
}
s += " for " + url.spec;
info(s);
cs.setCookieStringFromHttp(url, null, value, null);
cs.setCookieStringFromHttp(url, value, null);
return new Promise(function(resolve) {
// Windows XP has low precision timestamps that cause our cookie eviction
// algorithm to produce different results from other platforms. We work around

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

@ -6,7 +6,7 @@ const cm = cs.QueryInterface(Ci.nsICookieManager);
function setCookie(name, url) {
let value = `${name}=${Math.random()}; Path=/; Max-Age=1000; sameSite=none`;
info(`Setting cookie ${value} for ${url.spec}`);
cs.setCookieStringFromHttp(url, null, value, null);
cs.setCookieStringFromHttp(url, value, null);
}
async function sleep() {

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

@ -16,7 +16,7 @@ function run_test() {
let uri = NetUtil.newURI("http://example.org/");
let set = "foo=bar";
cs.setCookieStringFromHttp(uri, null, set, null);
cs.setCookieStringFromHttp(uri, set, null);
let expected = "foo=bar";
let actual = cs.getCookieStringFromHttp(uri, null);

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

@ -16,7 +16,7 @@ function run_test() {
let uri = NetUtil.newURI("http://example.org/");
let set = "foo=b;max-age=3600, c=d;path=/";
cs.setCookieStringFromHttp(uri, null, set, null);
cs.setCookieStringFromHttp(uri, set, null);
let expected = "foo=b";
let actual = cs.getCookieStringFromHttp(uri, null);

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

@ -97,7 +97,7 @@ add_task(async _ => {
Services.obs.addObserver(observer, "cookie-saved-on-disk");
});
cs.setCookieStringFromHttp(uri, null, test.cookie, channel);
cs.setCookieStringFromHttp(uri, test.cookie, channel);
await promise;

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

@ -2128,7 +2128,7 @@ HttpBaseChannel::SetCookie(const nsACString& aCookieHeader) {
nsICookieService* cs = gHttpHandler->GetCookieService();
NS_ENSURE_TRUE(cs, NS_ERROR_FAILURE);
nsresult rv = cs->SetCookieStringFromHttp(mURI, nullptr, aCookieHeader, this);
nsresult rv = cs->SetCookieStringFromHttp(mURI, aCookieHeader, this);
if (NS_SUCCEEDED(rv)) {
NotifySetCookie(aCookieHeader);
}

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

@ -63,38 +63,35 @@ void SetTime(PRTime offsetTime, nsAutoCString& serverString,
cookieString.Append(timeStringPreset);
}
void SetACookie(nsICookieService* aCookieService, const char* aSpec1,
const char* aSpec2, const char* aCookieString) {
nsCOMPtr<nsIURI> uri1, uri2;
NS_NewURI(getter_AddRefs(uri1), aSpec1);
if (aSpec2) NS_NewURI(getter_AddRefs(uri2), aSpec2);
void SetACookie(nsICookieService* aCookieService, const char* aSpec,
const char* aCookieString) {
nsCOMPtr<nsIURI> uri;
NS_NewURI(getter_AddRefs(uri), aSpec);
nsresult rv = aCookieService->SetCookieStringFromHttp(
uri1, uri2, nsDependentCString(aCookieString), nullptr);
uri, nsDependentCString(aCookieString), nullptr);
EXPECT_TRUE(NS_SUCCEEDED(rv));
}
// Custom Cookie Generator specifically for the needs of same-site cookies!
// Hands off unless you know exactly what you are doing!
void SetASameSiteCookie(nsICookieService* aCookieService, const char* aSpec1,
const char* aSpec2, const char* aCookieString,
const char* aServerTime, bool aAllowed) {
nsCOMPtr<nsIURI> uri1, uri2;
NS_NewURI(getter_AddRefs(uri1), aSpec1);
if (aSpec2) NS_NewURI(getter_AddRefs(uri2), aSpec2);
void SetASameSiteCookie(nsICookieService* aCookieService, const char* aSpec,
const char* aCookieString, bool aAllowed) {
nsCOMPtr<nsIURI> uri;
NS_NewURI(getter_AddRefs(uri), aSpec);
// We create a dummy channel using the aSpec1 to simulate same-siteness
// We create a dummy channel using the aSpec to simulate same-siteness
nsresult rv0;
nsCOMPtr<nsIScriptSecurityManager> ssm =
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv0);
ASSERT_TRUE(NS_SUCCEEDED(rv0));
nsCOMPtr<nsIPrincipal> spec1Principal;
nsCString tmpString(aSpec1);
nsCOMPtr<nsIPrincipal> specPrincipal;
nsCString tmpString(aSpec);
ssm->CreateContentPrincipalFromOrigin(tmpString,
getter_AddRefs(spec1Principal));
getter_AddRefs(specPrincipal));
nsCOMPtr<nsIChannel> dummyChannel;
NS_NewChannel(getter_AddRefs(dummyChannel), uri1, spec1Principal,
NS_NewChannel(getter_AddRefs(dummyChannel), uri, specPrincipal,
nsILoadInfo::SEC_ONLY_FOR_EXPLICIT_CONTENTSEC_CHECK,
nsIContentPolicy::TYPE_OTHER);
@ -107,7 +104,7 @@ void SetASameSiteCookie(nsICookieService* aCookieService, const char* aSpec1,
loadInfo->SetCookieJarSettings(cookieJarSettings);
nsresult rv = aCookieService->SetCookieStringFromHttp(
uri1, uri2, nsDependentCString(aCookieString), dummyChannel);
uri, nsDependentCString(aCookieString), dummyChannel);
EXPECT_TRUE(NS_SUCCEEDED(rv));
}
@ -232,7 +229,7 @@ TEST(TestCookie, TestCookieMain)
*/
// test some basic variations of the domain & path
SetACookie(cookieService, "http://www.basic.com", nullptr, "test=basic");
SetACookie(cookieService, "http://www.basic.com", "test=basic");
GetACookie(cookieService, "http://www.basic.com", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=basic"));
GetACookie(cookieService, "http://www.basic.com/testPath/testfile.txt",
@ -247,8 +244,7 @@ TEST(TestCookie, TestCookieMain)
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
GetACookie(cookieService, "http://www.basic2.com/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
SetACookie(cookieService, "http://www.basic.com", nullptr,
"test=basic; max-age=-1");
SetACookie(cookieService, "http://www.basic.com", "test=basic; max-age=-1");
GetACookie(cookieService, "http://www.basic.com/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
@ -256,7 +252,7 @@ TEST(TestCookie, TestCookieMain)
// test some variations of the domain & path, for different domains of
// a domain cookie
SetACookie(cookieService, "http://www.domain.com", nullptr,
SetACookie(cookieService, "http://www.domain.com",
"test=domain; domain=domain.com");
GetACookie(cookieService, "http://domain.com", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=domain"));
@ -266,12 +262,12 @@ TEST(TestCookie, TestCookieMain)
EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=domain"));
GetACookie(cookieService, "http://foo.domain.com", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=domain"));
SetACookie(cookieService, "http://www.domain.com", nullptr,
SetACookie(cookieService, "http://www.domain.com",
"test=domain; domain=domain.com; max-age=-1");
GetACookie(cookieService, "http://domain.com", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
SetACookie(cookieService, "http://www.domain.com", nullptr,
SetACookie(cookieService, "http://www.domain.com",
"test=domain; domain=.domain.com");
GetACookie(cookieService, "http://domain.com", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=domain"));
@ -279,41 +275,41 @@ TEST(TestCookie, TestCookieMain)
EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=domain"));
GetACookie(cookieService, "http://bah.domain.com", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=domain"));
SetACookie(cookieService, "http://www.domain.com", nullptr,
SetACookie(cookieService, "http://www.domain.com",
"test=domain; domain=.domain.com; max-age=-1");
GetACookie(cookieService, "http://domain.com", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
SetACookie(cookieService, "http://www.domain.com", nullptr,
SetACookie(cookieService, "http://www.domain.com",
"test=domain; domain=.foo.domain.com");
GetACookie(cookieService, "http://foo.domain.com", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
SetACookie(cookieService, "http://www.domain.com", nullptr,
SetACookie(cookieService, "http://www.domain.com",
"test=domain; domain=moose.com");
GetACookie(cookieService, "http://foo.domain.com", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
SetACookie(cookieService, "http://www.domain.com", nullptr,
SetACookie(cookieService, "http://www.domain.com",
"test=domain; domain=domain.com.");
GetACookie(cookieService, "http://foo.domain.com", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
SetACookie(cookieService, "http://www.domain.com", nullptr,
SetACookie(cookieService, "http://www.domain.com",
"test=domain; domain=..domain.com");
GetACookie(cookieService, "http://foo.domain.com", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
SetACookie(cookieService, "http://www.domain.com", nullptr,
SetACookie(cookieService, "http://www.domain.com",
"test=domain; domain=..domain.com.");
GetACookie(cookieService, "http://foo.domain.com", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
SetACookie(cookieService, "http://path.net/path/file", nullptr,
SetACookie(cookieService, "http://path.net/path/file",
R"(test=taco; path="/bogus")");
GetACookie(cookieService, "http://path.net/path/file", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=taco"));
SetACookie(cookieService, "http://path.net/path/file", nullptr,
SetACookie(cookieService, "http://path.net/path/file",
"test=taco; max-age=-1");
GetACookie(cookieService, "http://path.net/path/file", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
@ -322,7 +318,7 @@ TEST(TestCookie, TestCookieMain)
// test some variations of the domain & path, for different paths of
// a path cookie
SetACookie(cookieService, "http://path.net/path/file", nullptr,
SetACookie(cookieService, "http://path.net/path/file",
"test=path; path=/path");
GetACookie(cookieService, "http://path.net/path", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=path"));
@ -336,18 +332,18 @@ TEST(TestCookie, TestCookieMain)
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
GetACookie(cookieService, "http://path.net/path2/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
SetACookie(cookieService, "http://path.net/path/file", nullptr,
SetACookie(cookieService, "http://path.net/path/file",
"test=path; path=/path; max-age=-1");
GetACookie(cookieService, "http://path.net/path/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
SetACookie(cookieService, "http://path.net/path/file", nullptr,
SetACookie(cookieService, "http://path.net/path/file",
"test=path; path=/path/");
GetACookie(cookieService, "http://path.net/path", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
GetACookie(cookieService, "http://path.net/path/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=path"));
SetACookie(cookieService, "http://path.net/path/file", nullptr,
SetACookie(cookieService, "http://path.net/path/file",
"test=path; path=/path/; max-age=-1");
GetACookie(cookieService, "http://path.net/path/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
@ -355,13 +351,13 @@ TEST(TestCookie, TestCookieMain)
// note that a site can set a cookie for a path it's not on.
// this is an intentional deviation from spec (see comments in
// CookieService::CheckPath()), so we test this functionality too
SetACookie(cookieService, "http://path.net/path/file", nullptr,
SetACookie(cookieService, "http://path.net/path/file",
"test=path; path=/foo/");
GetACookie(cookieService, "http://path.net/path", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
GetACookie(cookieService, "http://path.net/foo", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
SetACookie(cookieService, "http://path.net/path/file", nullptr,
SetACookie(cookieService, "http://path.net/path/file",
"test=path; path=/foo/; max-age=-1");
GetACookie(cookieService, "http://path.net/foo/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
@ -371,7 +367,7 @@ TEST(TestCookie, TestCookieMain)
// the following cookie has a path > 1024 bytes explicitly specified in the
// cookie
SetACookie(
cookieService, "http://path.net/", nullptr,
cookieService, "http://path.net/",
"test=path; "
"path=/"
"123456789012345678901234567890123456789012345678901234567890123456789012"
@ -429,7 +425,7 @@ TEST(TestCookie, TestCookieMain)
"567890123456789012345678901234567890123456789012345678901234567890123456"
"789012345678901234567890123456789012345678901234567890123456789012345678"
"9012345678901234567890/",
nullptr, "test=path");
"test=path");
GetACookie(
cookieService,
"http://path.net/"
@ -451,20 +447,18 @@ TEST(TestCookie, TestCookieMain)
cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
// the following cookie includes a tab in the path
SetACookie(cookieService, "http://path.net/", nullptr,
"test=path; path=/foo\tbar/");
SetACookie(cookieService, "http://path.net/", "test=path; path=/foo\tbar/");
GetACookie(cookieService, "http://path.net/foo\tbar/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
// the following cookie includes a tab in the name
SetACookie(cookieService, "http://path.net/", nullptr, "test\ttabs=tab");
SetACookie(cookieService, "http://path.net/", "test\ttabs=tab");
GetACookie(cookieService, "http://path.net/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
// the following cookie includes a tab in the value - allowed
SetACookie(cookieService, "http://path.net/", nullptr, "test=tab\ttest");
SetACookie(cookieService, "http://path.net/", "test=tab\ttest");
GetACookie(cookieService, "http://path.net/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=tab\ttest"));
SetACookie(cookieService, "http://path.net/", nullptr,
"test=tab\ttest; max-age=-1");
SetACookie(cookieService, "http://path.net/", "test=tab\ttest; max-age=-1");
GetACookie(cookieService, "http://path.net/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
@ -473,68 +467,61 @@ TEST(TestCookie, TestCookieMain)
// test some variations of the expiry time,
// and test deletion of previously set cookies
SetACookie(cookieService, "http://expireme.org/", nullptr,
"test=expiry; max-age=-1");
SetACookie(cookieService, "http://expireme.org/", "test=expiry; max-age=-1");
GetACookie(cookieService, "http://expireme.org/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
SetACookie(cookieService, "http://expireme.org/", nullptr,
"test=expiry; max-age=0");
SetACookie(cookieService, "http://expireme.org/", "test=expiry; max-age=0");
GetACookie(cookieService, "http://expireme.org/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
SetACookie(cookieService, "http://expireme.org/", nullptr,
"test=expiry; expires=bad");
SetACookie(cookieService, "http://expireme.org/", "test=expiry; expires=bad");
GetACookie(cookieService, "http://expireme.org/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=expiry"));
SetACookie(cookieService, "http://expireme.org/", nullptr,
SetACookie(cookieService, "http://expireme.org/",
"test=expiry; expires=Thu, 10 Apr 1980 16:33:12 GMT");
GetACookie(cookieService, "http://expireme.org/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
SetACookie(cookieService, "http://expireme.org/", nullptr,
SetACookie(cookieService, "http://expireme.org/",
R"(test=expiry; expires="Thu, 10 Apr 1980 16:33:12 GMT)");
GetACookie(cookieService, "http://expireme.org/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
SetACookie(cookieService, "http://expireme.org/", nullptr,
SetACookie(cookieService, "http://expireme.org/",
R"(test=expiry; expires="Thu, 10 Apr 1980 16:33:12 GMT")");
GetACookie(cookieService, "http://expireme.org/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
SetACookie(cookieService, "http://expireme.org/", nullptr,
"test=expiry; max-age=60");
SetACookie(cookieService, "http://expireme.org/", "test=expiry; max-age=60");
GetACookie(cookieService, "http://expireme.org/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=expiry"));
SetACookie(cookieService, "http://expireme.org/", nullptr,
"test=expiry; max-age=-20");
SetACookie(cookieService, "http://expireme.org/", "test=expiry; max-age=-20");
GetACookie(cookieService, "http://expireme.org/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
SetACookie(cookieService, "http://expireme.org/", nullptr,
"test=expiry; max-age=60");
SetACookie(cookieService, "http://expireme.org/", "test=expiry; max-age=60");
GetACookie(cookieService, "http://expireme.org/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=expiry"));
SetACookie(cookieService, "http://expireme.org/", nullptr,
SetACookie(cookieService, "http://expireme.org/",
"test=expiry; expires=Thu, 10 Apr 1980 16:33:12 GMT");
GetACookie(cookieService, "http://expireme.org/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
SetACookie(cookieService, "http://expireme.org/", nullptr,
"test=expiry; max-age=60");
SetACookie(cookieService, "http://expireme.org/", nullptr,
SetACookie(cookieService, "http://expireme.org/", "test=expiry; max-age=60");
SetACookie(cookieService, "http://expireme.org/",
"newtest=expiry; max-age=60");
GetACookie(cookieService, "http://expireme.org/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_CONTAIN, "test=expiry"));
EXPECT_TRUE(CheckResult(cookie.get(), MUST_CONTAIN, "newtest=expiry"));
SetACookie(cookieService, "http://expireme.org/", nullptr,
SetACookie(cookieService, "http://expireme.org/",
"test=differentvalue; max-age=0");
GetACookie(cookieService, "http://expireme.org/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "newtest=expiry"));
SetACookie(cookieService, "http://expireme.org/", nullptr,
SetACookie(cookieService, "http://expireme.org/",
"newtest=evendifferentvalue; max-age=0");
GetACookie(cookieService, "http://expireme.org/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
SetACookie(cookieService, "http://foo.expireme.org/", nullptr,
SetACookie(cookieService, "http://foo.expireme.org/",
"test=expiry; domain=.expireme.org; max-age=60");
GetACookie(cookieService, "http://expireme.org/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=expiry"));
SetACookie(cookieService, "http://bar.expireme.org/", nullptr,
SetACookie(cookieService, "http://bar.expireme.org/",
"test=differentvalue; domain=.expireme.org; max-age=0");
GetACookie(cookieService, "http://expireme.org/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
@ -546,7 +533,7 @@ TEST(TestCookie, TestCookieMain)
// test the setting of multiple cookies, and test the order of precedence
// (a later cookie overwriting an earlier one, in the same header string)
SetACookie(cookieService, "http://multiple.cookies/", nullptr,
SetACookie(cookieService, "http://multiple.cookies/",
"test=multiple; domain=.multiple.cookies \n test=different \n "
"test=same; domain=.multiple.cookies \n newtest=ciao \n "
"newtest=foo; max-age=-6 \n newtest=reincarnated");
@ -557,15 +544,15 @@ TEST(TestCookie, TestCookieMain)
EXPECT_TRUE(CheckResult(cookie.get(), MUST_NOT_CONTAIN, "newtest=ciao"));
EXPECT_TRUE(CheckResult(cookie.get(), MUST_NOT_CONTAIN, "newtest=foo"));
EXPECT_TRUE(CheckResult(cookie.get(), MUST_CONTAIN, "newtest=reincarnated"));
SetACookie(cookieService, "http://multiple.cookies/", nullptr,
SetACookie(cookieService, "http://multiple.cookies/",
"test=expiry; domain=.multiple.cookies; max-age=0");
GetACookie(cookieService, "http://multiple.cookies/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_NOT_CONTAIN, "test=same"));
SetACookie(cookieService, "http://multiple.cookies/", nullptr,
SetACookie(cookieService, "http://multiple.cookies/",
"\n test=different; max-age=0 \n");
GetACookie(cookieService, "http://multiple.cookies/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_NOT_CONTAIN, "test=different"));
SetACookie(cookieService, "http://multiple.cookies/", nullptr,
SetACookie(cookieService, "http://multiple.cookies/",
"newtest=dead; max-age=0");
GetACookie(cookieService, "http://multiple.cookies/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
@ -573,22 +560,22 @@ TEST(TestCookie, TestCookieMain)
// *** parser tests
// test the cookie header parser, under various circumstances.
SetACookie(cookieService, "http://parser.test/", nullptr,
SetACookie(cookieService, "http://parser.test/",
"test=parser; domain=.parser.test; ;; ;=; ,,, ===,abc,=; "
"abracadabra! max-age=20;=;;");
GetACookie(cookieService, "http://parser.test/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=parser"));
SetACookie(cookieService, "http://parser.test/", nullptr,
SetACookie(cookieService, "http://parser.test/",
"test=parser; domain=.parser.test; max-age=0");
GetACookie(cookieService, "http://parser.test/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
SetACookie(cookieService, "http://parser.test/", nullptr,
SetACookie(cookieService, "http://parser.test/",
"test=\"fubar! = foo;bar\\\";\" parser; domain=.parser.test; "
"max-age=6\nfive; max-age=2.63,");
GetACookie(cookieService, "http://parser.test/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_CONTAIN, R"(test="fubar! = foo)"));
EXPECT_TRUE(CheckResult(cookie.get(), MUST_CONTAIN, "five"));
SetACookie(cookieService, "http://parser.test/", nullptr,
SetACookie(cookieService, "http://parser.test/",
"test=kill; domain=.parser.test; max-age=0 \n five; max-age=0");
GetACookie(cookieService, "http://parser.test/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
@ -596,16 +583,16 @@ TEST(TestCookie, TestCookieMain)
// test the handling of VALUE-only cookies (see bug 169091),
// i.e. "six" should assume an empty NAME, which allows other VALUE-only
// cookies to overwrite it
SetACookie(cookieService, "http://parser.test/", nullptr, "six");
SetACookie(cookieService, "http://parser.test/", "six");
GetACookie(cookieService, "http://parser.test/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "six"));
SetACookie(cookieService, "http://parser.test/", nullptr, "seven");
SetACookie(cookieService, "http://parser.test/", "seven");
GetACookie(cookieService, "http://parser.test/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "seven"));
SetACookie(cookieService, "http://parser.test/", nullptr, " =eight");
SetACookie(cookieService, "http://parser.test/", " =eight");
GetACookie(cookieService, "http://parser.test/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "eight"));
SetACookie(cookieService, "http://parser.test/", nullptr, "test=six");
SetACookie(cookieService, "http://parser.test/", "test=six");
GetACookie(cookieService, "http://parser.test/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_CONTAIN, "test=six"));
@ -613,18 +600,17 @@ TEST(TestCookie, TestCookieMain)
// test that cookies are returned in path order - longest to shortest.
// if the header doesn't specify a path, it's taken from the host URI.
SetACookie(cookieService, "http://multi.path.tests/", nullptr,
SetACookie(cookieService, "http://multi.path.tests/",
"test1=path; path=/one/two/three");
SetACookie(cookieService, "http://multi.path.tests/", nullptr,
SetACookie(cookieService, "http://multi.path.tests/",
"test2=path; path=/one \n test3=path; path=/one/two/three/four \n "
"test4=path; path=/one/two \n test5=path; path=/one/two/");
SetACookie(cookieService, "http://multi.path.tests/one/two/three/four/five/",
nullptr, "test6=path");
"test6=path");
SetACookie(cookieService,
"http://multi.path.tests/one/two/three/four/five/six/", nullptr,
"http://multi.path.tests/one/two/three/four/five/six/",
"test7=path; path=");
SetACookie(cookieService, "http://multi.path.tests/", nullptr,
"test8=path; path=/");
SetACookie(cookieService, "http://multi.path.tests/", "test8=path; path=/");
GetACookie(cookieService,
"http://multi.path.tests/one/two/three/four/five/six/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL,
@ -639,16 +625,14 @@ TEST(TestCookie, TestCookieMain)
GetACookie(cookieService, "http://httponly.test/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
// Since this cookie is set via http, it can be retrieved
SetACookie(cookieService, "http://httponly.test/", nullptr,
"test=httponly; httponly");
SetACookie(cookieService, "http://httponly.test/", "test=httponly; httponly");
GetACookie(cookieService, "http://httponly.test/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=httponly"));
// ... but not by web content
GetACookieNoHttp(cookieService, "http://httponly.test/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
// Non-Http cookies should not replace HttpOnly cookies
SetACookie(cookieService, "http://httponly.test/", nullptr,
"test=httponly; httponly");
SetACookie(cookieService, "http://httponly.test/", "test=httponly; httponly");
SetACookieNoHttp(cookieService, "http://httponly.test/", "test=not-httponly");
GetACookie(cookieService, "http://httponly.test/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=httponly"));
@ -656,28 +640,24 @@ TEST(TestCookie, TestCookieMain)
GetACookieNoHttp(cookieService, "http://httponly.test/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
// Non-Http cookies should not delete HttpOnly cookies
SetACookie(cookieService, "http://httponly.test/", nullptr,
"test=httponly; httponly");
SetACookie(cookieService, "http://httponly.test/", "test=httponly; httponly");
SetACookieNoHttp(cookieService, "http://httponly.test/",
"test=httponly; max-age=-1");
GetACookie(cookieService, "http://httponly.test/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=httponly"));
// ... but HttpOnly cookies should
SetACookie(cookieService, "http://httponly.test/", nullptr,
SetACookie(cookieService, "http://httponly.test/",
"test=httponly; httponly; max-age=-1");
GetACookie(cookieService, "http://httponly.test/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
// Non-Httponly cookies can replace HttpOnly cookies when set over http
SetACookie(cookieService, "http://httponly.test/", nullptr,
"test=httponly; httponly");
SetACookie(cookieService, "http://httponly.test/", nullptr,
"test=not-httponly");
SetACookie(cookieService, "http://httponly.test/", "test=httponly; httponly");
SetACookie(cookieService, "http://httponly.test/", "test=not-httponly");
GetACookieNoHttp(cookieService, "http://httponly.test/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=not-httponly"));
// scripts should not be able to set httponly cookies by replacing an existing
// non-httponly cookie
SetACookie(cookieService, "http://httponly.test/", nullptr,
"test=not-httponly");
SetACookie(cookieService, "http://httponly.test/", "test=not-httponly");
SetACookieNoHttp(cookieService, "http://httponly.test/",
"test=httponly; httponly");
GetACookieNoHttp(cookieService, "http://httponly.test/", cookie);
@ -686,29 +666,25 @@ TEST(TestCookie, TestCookieMain)
// *** Cookie prefix tests
// prefixed cookies can't be set from insecure HTTP
SetACookie(cookieService, "http://prefixed.test/", nullptr,
"__Secure-test1=test");
SetACookie(cookieService, "http://prefixed.test/", nullptr,
SetACookie(cookieService, "http://prefixed.test/", "__Secure-test1=test");
SetACookie(cookieService, "http://prefixed.test/",
"__Secure-test2=test; secure");
SetACookie(cookieService, "http://prefixed.test/", nullptr,
"__Host-test1=test");
SetACookie(cookieService, "http://prefixed.test/", nullptr,
SetACookie(cookieService, "http://prefixed.test/", "__Host-test1=test");
SetACookie(cookieService, "http://prefixed.test/",
"__Host-test2=test; secure");
GetACookie(cookieService, "http://prefixed.test/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
// prefixed cookies won't be set without the secure flag
SetACookie(cookieService, "https://prefixed.test/", nullptr,
"__Secure-test=test");
SetACookie(cookieService, "https://prefixed.test/", nullptr,
"__Host-test=test");
SetACookie(cookieService, "https://prefixed.test/", "__Secure-test=test");
SetACookie(cookieService, "https://prefixed.test/", "__Host-test=test");
GetACookie(cookieService, "https://prefixed.test/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
// prefixed cookies can be set when done correctly
SetACookie(cookieService, "https://prefixed.test/", nullptr,
SetACookie(cookieService, "https://prefixed.test/",
"__Secure-test=test; secure");
SetACookie(cookieService, "https://prefixed.test/", nullptr,
SetACookie(cookieService, "https://prefixed.test/",
"__Host-test=test; secure");
GetACookie(cookieService, "https://prefixed.test/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_CONTAIN, "__Secure-test=test"));
@ -719,23 +695,23 @@ TEST(TestCookie, TestCookieMain)
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
// Host-prefixed cookies cannot specify a domain
SetACookie(cookieService, "https://host.prefixed.test/", nullptr,
SetACookie(cookieService, "https://host.prefixed.test/",
"__Host-a=test; secure; domain=prefixed.test");
SetACookie(cookieService, "https://host.prefixed.test/", nullptr,
SetACookie(cookieService, "https://host.prefixed.test/",
"__Host-b=test; secure; domain=.prefixed.test");
SetACookie(cookieService, "https://host.prefixed.test/", nullptr,
SetACookie(cookieService, "https://host.prefixed.test/",
"__Host-c=test; secure; domain=host.prefixed.test");
SetACookie(cookieService, "https://host.prefixed.test/", nullptr,
SetACookie(cookieService, "https://host.prefixed.test/",
"__Host-d=test; secure; domain=.host.prefixed.test");
GetACookie(cookieService, "https://host.prefixed.test/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
// Host-prefixed cookies can only have a path of "/"
SetACookie(cookieService, "https://host.prefixed.test/some/path", nullptr,
SetACookie(cookieService, "https://host.prefixed.test/some/path",
"__Host-e=test; secure");
SetACookie(cookieService, "https://host.prefixed.test/some/path", nullptr,
SetACookie(cookieService, "https://host.prefixed.test/some/path",
"__Host-f=test; secure; path=/");
SetACookie(cookieService, "https://host.prefixed.test/some/path", nullptr,
SetACookie(cookieService, "https://host.prefixed.test/some/path",
"__Host-g=test; secure; path=/some");
GetACookie(cookieService, "https://host.prefixed.test/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "__Host-f=test"));
@ -744,53 +720,52 @@ TEST(TestCookie, TestCookieMain)
// testing items 0 & 1 for 3.1 of spec Deprecate modification of secure
// cookies from non-secure origins
SetACookie(cookieService, "http://www.security.test/", nullptr,
SetACookie(cookieService, "http://www.security.test/",
"test=non-security; secure");
GetACookieNoHttp(cookieService, "https://www.security.test/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
SetACookie(cookieService, "https://www.security.test/path/", nullptr,
SetACookie(cookieService, "https://www.security.test/path/",
"test=security; secure; path=/path/");
GetACookieNoHttp(cookieService, "https://www.security.test/path/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=security"));
// testing items 2 & 3 & 4 for 3.2 of spec Deprecate modification of secure
// cookies from non-secure origins
// Secure site can modify cookie value
SetACookie(cookieService, "https://www.security.test/path/", nullptr,
SetACookie(cookieService, "https://www.security.test/path/",
"test=security2; secure; path=/path/");
GetACookieNoHttp(cookieService, "https://www.security.test/path/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=security2"));
// If new cookie contains same name, same host and partially matching path
// with an existing security cookie on non-security site, it can't modify an
// existing security cookie.
SetACookie(cookieService, "http://www.security.test/path/foo/", nullptr,
SetACookie(cookieService, "http://www.security.test/path/foo/",
"test=non-security; path=/path/foo");
GetACookieNoHttp(cookieService, "https://www.security.test/path/foo/",
cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=security2"));
// Non-secure cookie can set by same name, same host and non-matching path.
SetACookie(cookieService, "http://www.security.test/bar/", nullptr,
SetACookie(cookieService, "http://www.security.test/bar/",
"test=non-security; path=/bar");
GetACookieNoHttp(cookieService, "http://www.security.test/bar/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=non-security"));
// Modify value and downgrade secure level.
SetACookie(
cookieService, "https://www.security.test/", nullptr,
cookieService, "https://www.security.test/",
"test_modify_cookie=security-cookie; secure; domain=.security.test");
GetACookieNoHttp(cookieService, "https://www.security.test/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL,
"test_modify_cookie=security-cookie"));
SetACookie(cookieService, "https://www.security.test/", nullptr,
SetACookie(cookieService, "https://www.security.test/",
"test_modify_cookie=non-security-cookie; domain=.security.test");
GetACookieNoHttp(cookieService, "https://www.security.test/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL,
"test_modify_cookie=non-security-cookie"));
// Test the non-security cookie can set when domain or path not same to secure
// cookie of same name.
SetACookie(cookieService, "https://www.security.test/", nullptr,
"test=security3");
SetACookie(cookieService, "https://www.security.test/", "test=security3");
GetACookieNoHttp(cookieService, "http://www.security.test/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_CONTAIN, "test=security3"));
SetACookie(cookieService, "http://www.security.test/", nullptr,
SetACookie(cookieService, "http://www.security.test/",
"test=non-security2; domain=security.test");
GetACookieNoHttp(cookieService, "http://www.security.test/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_CONTAIN, "test=non-security2"));
@ -900,8 +875,7 @@ TEST(TestCookie, TestCookieMain)
name = NS_LITERAL_CSTRING("test");
name.AppendInt(i);
name += NS_LITERAL_CSTRING("=creation");
SetACookie(cookieService, "http://creation.ordering.tests/", nullptr,
name.get());
SetACookie(cookieService, "http://creation.ordering.tests/", name.get());
if (i >= 10) {
expected += name;
@ -921,13 +895,11 @@ TEST(TestCookie, TestCookieMain)
// Create 50 cookies that include the secure flag.
if (i < 50) {
name += NS_LITERAL_CSTRING("; secure");
SetACookie(cookieService, "https://creation.ordering.tests/", nullptr,
name.get());
SetACookie(cookieService, "https://creation.ordering.tests/", name.get());
} else {
// non-security cookies will be removed beside the latest cookie that be
// created.
SetACookie(cookieService, "http://creation.ordering.tests/", nullptr,
name.get());
SetACookie(cookieService, "http://creation.ordering.tests/", name.get());
}
}
GetACookie(cookieService, "http://creation.ordering.tests/", cookie);
@ -940,18 +912,17 @@ TEST(TestCookie, TestCookieMain)
// None of these cookies will be set because using
// CookieJarSettings::GetBlockingAll().
SetASameSiteCookie(cookieService, "http://samesite.test", nullptr,
"unset=yes", nullptr, false);
SetASameSiteCookie(cookieService, "http://samesite.test", nullptr,
"unspecified=yes; samesite", nullptr, false);
SetASameSiteCookie(cookieService, "http://samesite.test", nullptr,
"empty=yes; samesite=", nullptr, false);
SetASameSiteCookie(cookieService, "http://samesite.test", nullptr,
"bogus=yes; samesite=bogus", nullptr, false);
SetASameSiteCookie(cookieService, "http://samesite.test", nullptr,
"strict=yes; samesite=strict", nullptr, false);
SetASameSiteCookie(cookieService, "http://samesite.test", nullptr,
"lax=yes; samesite=lax", nullptr, false);
SetASameSiteCookie(cookieService, "http://samesite.test", "unset=yes", false);
SetASameSiteCookie(cookieService, "http://samesite.test",
"unspecified=yes; samesite", false);
SetASameSiteCookie(cookieService, "http://samesite.test",
"empty=yes; samesite=", false);
SetASameSiteCookie(cookieService, "http://samesite.test",
"bogus=yes; samesite=bogus", false);
SetASameSiteCookie(cookieService, "http://samesite.test",
"strict=yes; samesite=strict", false);
SetASameSiteCookie(cookieService, "http://samesite.test",
"lax=yes; samesite=lax", false);
cookies.SetLength(0);
EXPECT_TRUE(NS_SUCCEEDED(cookieMgr->GetCookies(cookies)));
@ -960,23 +931,22 @@ TEST(TestCookie, TestCookieMain)
// Set cookies with various incantations of the samesite attribute:
// No same site attribute present
SetASameSiteCookie(cookieService, "http://samesite.test", nullptr,
"unset=yes", nullptr, true);
SetASameSiteCookie(cookieService, "http://samesite.test", "unset=yes", true);
// samesite attribute present but with no value
SetASameSiteCookie(cookieService, "http://samesite.test", nullptr,
"unspecified=yes; samesite", nullptr, true);
SetASameSiteCookie(cookieService, "http://samesite.test",
"unspecified=yes; samesite", true);
// samesite attribute present but with an empty value
SetASameSiteCookie(cookieService, "http://samesite.test", nullptr,
"empty=yes; samesite=", nullptr, true);
SetASameSiteCookie(cookieService, "http://samesite.test",
"empty=yes; samesite=", true);
// samesite attribute present but with an invalid value
SetASameSiteCookie(cookieService, "http://samesite.test", nullptr,
"bogus=yes; samesite=bogus", nullptr, true);
SetASameSiteCookie(cookieService, "http://samesite.test",
"bogus=yes; samesite=bogus", true);
// samesite=strict
SetASameSiteCookie(cookieService, "http://samesite.test", nullptr,
"strict=yes; samesite=strict", nullptr, true);
SetASameSiteCookie(cookieService, "http://samesite.test",
"strict=yes; samesite=strict", true);
// samesite=lax
SetASameSiteCookie(cookieService, "http://samesite.test", nullptr,
"lax=yes; samesite=lax", nullptr, true);
SetASameSiteCookie(cookieService, "http://samesite.test",
"lax=yes; samesite=lax", true);
cookies.SetLength(0);
EXPECT_TRUE(NS_SUCCEEDED(cookieMgr->GetCookies(cookies)));
@ -1012,12 +982,12 @@ TEST(TestCookie, TestCookieMain)
// setup because no nsIChannel is passed to SetCookieString(). therefore we
// can only test that no cookies are sent for cross origin requests using
// same-site cookies.
SetACookie(cookieService, "http://www.samesite.com", nullptr,
SetACookie(cookieService, "http://www.samesite.com",
"test=sameSiteStrictVal; samesite=strict");
GetACookie(cookieService, "http://www.notsamesite.com", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
SetACookie(cookieService, "http://www.samesite.test", nullptr,
SetACookie(cookieService, "http://www.samesite.test",
"test=sameSiteLaxVal; samesite=lax");
GetACookie(cookieService, "http://www.notsamesite.com", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
@ -1030,7 +1000,7 @@ TEST(TestCookie, TestCookieMain)
uint32_t numSecureURIs = sizeof(secureURIs) / sizeof(const char*);
for (uint32_t i = 0; i < numSecureURIs; ++i) {
SetACookie(cookieService, secureURIs[i], nullptr, "test=basic; secure");
SetACookie(cookieService, secureURIs[i], "test=basic; secure");
GetACookie(cookieService, secureURIs[i], cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=basic"));
}
@ -1057,8 +1027,7 @@ TEST(TestCookie, SameSiteLax)
EXPECT_TRUE(NS_SUCCEEDED(cookieMgr->RemoveAll()));
SetASameSiteCookie(cookieService, "http://samesite.test", nullptr,
"unset=yes", nullptr, true);
SetASameSiteCookie(cookieService, "http://samesite.test", "unset=yes", true);
nsTArray<RefPtr<nsICookie>> cookies;
EXPECT_TRUE(NS_SUCCEEDED(cookieMgr->GetCookies(cookies)));
@ -1077,8 +1046,7 @@ TEST(TestCookie, SameSiteLax)
EXPECT_TRUE(NS_SUCCEEDED(cookieMgr->GetCookies(cookies)));
EXPECT_EQ(cookies.Length(), (uint64_t)0);
SetASameSiteCookie(cookieService, "http://samesite.test", nullptr,
"unset=yes", nullptr, true);
SetASameSiteCookie(cookieService, "http://samesite.test", "unset=yes", true);
cookies.SetLength(0);
EXPECT_TRUE(NS_SUCCEEDED(cookieMgr->GetCookies(cookies)));

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

@ -109,7 +109,7 @@ function do_load_profile(generator) {
// Set a single session cookie using http and test the cookie count
// against 'expected'
function do_set_single_http_cookie(uri, channel, expected) {
Services.cookies.setCookieStringFromHttp(uri, null, "foo=bar", channel);
Services.cookies.setCookieStringFromHttp(uri, "foo=bar", channel);
Assert.equal(Services.cookiemgr.countCookiesFromHost(uri.host), expected);
}
@ -125,20 +125,10 @@ function do_set_cookies(uri, channel, session, expected) {
Services.cookies.setCookieString(uri, "can=has" + suffix, channel);
Assert.equal(Services.cookiemgr.countCookiesFromHost(uri.host), expected[1]);
// without channel, from http
Services.cookies.setCookieStringFromHttp(
uri,
null,
"cheez=burger" + suffix,
null
);
Services.cookies.setCookieStringFromHttp(uri, "cheez=burger" + suffix, null);
Assert.equal(Services.cookiemgr.countCookiesFromHost(uri.host), expected[2]);
// with channel, from http
Services.cookies.setCookieStringFromHttp(
uri,
null,
"hot=dog" + suffix,
channel
);
Services.cookies.setCookieStringFromHttp(uri, "hot=dog" + suffix, channel);
Assert.equal(Services.cookiemgr.countCookiesFromHost(uri.host), expected[3]);
}

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

@ -10,36 +10,11 @@ function run_test() {
var cookieService = Cc["@mozilla.org/cookieService;1"].getService(
Ci.nsICookieService
);
cookieService.setCookieStringFromHttp(
cookieURI,
cookieURI,
"BadCookie1=\x01",
null
);
cookieService.setCookieStringFromHttp(
cookieURI,
cookieURI,
"BadCookie2=\v",
null
);
cookieService.setCookieStringFromHttp(
cookieURI,
cookieURI,
"Bad\x07Name=illegal",
null
);
cookieService.setCookieStringFromHttp(
cookieURI,
cookieURI,
GOOD_COOKIE,
null
);
cookieService.setCookieStringFromHttp(
cookieURI,
cookieURI,
SPACEY_COOKIE,
null
);
cookieService.setCookieStringFromHttp(cookieURI, "BadCookie1=\x01", null);
cookieService.setCookieStringFromHttp(cookieURI, "BadCookie2=\v", null);
cookieService.setCookieStringFromHttp(cookieURI, "Bad\x07Name=illegal", null);
cookieService.setCookieStringFromHttp(cookieURI, GOOD_COOKIE, null);
cookieService.setCookieStringFromHttp(cookieURI, SPACEY_COOKIE, null);
const principal = Services.scriptSecurityManager.createContentPrincipal(
cookieURI,

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

@ -48,7 +48,7 @@ function* do_run_test() {
Assert.equal(Services.cookies.getCookieStringForPrincipal(principal), "");
Assert.equal(Services.cookies.getCookieStringFromHttp(uri, null), "");
Services.cookies.setCookieString(uri, "oh2=hai", null);
Services.cookies.setCookieStringFromHttp(uri, null, "oh3=hai", null);
Services.cookies.setCookieStringFromHttp(uri, "oh3=hai", null);
Assert.equal(Services.cookies.getCookieStringForPrincipal(principal), "");
do_check_throws(function() {