Skip to content

Commit

Permalink
Bug 1551798 - Rename nsICookie2.SAMESITE_UNSET to nsICookie2.SAMESITE…
Browse files Browse the repository at this point in the history
…_NONE, r=Ehsan

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

--HG--
extra : moz-landing-system : lando
  • Loading branch information
bakulf committed May 24, 2019
1 parent a9eedef commit e9bbb85
Show file tree
Hide file tree
Showing 42 changed files with 79 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ add_task(async function subDomains() {

Services.cookies.add(uriA.host, "/test", "a", "b",
false, false, false, Date.now() + 24000 * 60 * 60, {},
Ci.nsICookie2.SAMESITE_UNSET);
Ci.nsICookie2.SAMESITE_NONE);

await createIndexedDB(uriA.host, {});

Expand All @@ -31,7 +31,7 @@ add_task(async function subDomains() {

Services.cookies.add(uriB.host, "/test", "c", "d",
false, false, false, Date.now() + 24000 * 60 * 60, {},
Ci.nsICookie2.SAMESITE_UNSET);
Ci.nsICookie2.SAMESITE_NONE);

await createIndexedDB(uriB.host, {});

Expand Down Expand Up @@ -76,15 +76,15 @@ add_task(async function subDomains() {

Services.cookies.add(uriA.host, "/test", "a", "b",
false, false, false, Date.now() + 24000 * 60 * 60, {},
Ci.nsICookie2.SAMESITE_UNSET);
Ci.nsICookie2.SAMESITE_NONE);

await createIndexedDB(uriA.host, {});

let uriB = Services.io.newURI("https://www.mozilla.org");

Services.cookies.add(uriB.host, "/test", "c", "d",
false, false, false, Date.now() + 24000 * 60 * 60, {},
Ci.nsICookie2.SAMESITE_UNSET);
Ci.nsICookie2.SAMESITE_NONE);

await createIndexedDB(uriB.host, {});

Expand Down
4 changes: 2 additions & 2 deletions browser/base/content/test/sanitize/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ function checkIndexedDB(host, originAttributes) {
function createHostCookie(host, originAttributes) {
Services.cookies.add(host, "/test", "foo", "bar",
false, false, false, Date.now() + 24000 * 60 * 60, originAttributes,
Ci.nsICookie2.SAMESITE_UNSET);
Ci.nsICookie2.SAMESITE_NONE);
}

function createDomainCookie(host, originAttributes) {
Services.cookies.add("." + host, "/test", "foo", "bar",
false, false, false, Date.now() + 24000 * 60 * 60, originAttributes,
Ci.nsICookie2.SAMESITE_UNSET);
Ci.nsICookie2.SAMESITE_NONE);
}

function checkCookie(host, originAttributes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ const ORIGIN_DOMAIN = "browser_policy_clear_blocked_cookies.org";

add_task(async function setup() {
const expiry = Date.now() + 24 * 60 * 60;
Services.cookies.add(HOSTNAME_DOMAIN, "/", "secure", "true", true, false, false, expiry, {}, Ci.nsICookie2.SAMESITE_UNSET);
Services.cookies.add(HOSTNAME_DOMAIN, "/", "insecure", "true", false, false, false, expiry, {}, Ci.nsICookie2.SAMESITE_UNSET);
Services.cookies.add(ORIGIN_DOMAIN, "/", "secure", "true", true, false, false, expiry, {}, Ci.nsICookie2.SAMESITE_UNSET);
Services.cookies.add(ORIGIN_DOMAIN, "/", "insecure", "true", false, false, false, expiry, {}, Ci.nsICookie2.SAMESITE_UNSET);
Services.cookies.add("example.net", "/", "secure", "true", true, false, false, expiry, {}, Ci.nsICookie2.SAMESITE_UNSET);
Services.cookies.add(HOSTNAME_DOMAIN, "/", "secure", "true", true, false, false, expiry, {}, Ci.nsICookie2.SAMESITE_NONE);
Services.cookies.add(HOSTNAME_DOMAIN, "/", "insecure", "true", false, false, false, expiry, {}, Ci.nsICookie2.SAMESITE_NONE);
Services.cookies.add(ORIGIN_DOMAIN, "/", "secure", "true", true, false, false, expiry, {}, Ci.nsICookie2.SAMESITE_NONE);
Services.cookies.add(ORIGIN_DOMAIN, "/", "insecure", "true", false, false, false, expiry, {}, Ci.nsICookie2.SAMESITE_NONE);
Services.cookies.add("example.net", "/", "secure", "true", true, false, false, expiry, {}, Ci.nsICookie2.SAMESITE_NONE);
await setupPolicyEngineWithJson({
"policies": {
"Cookies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const COOKIE_ORG = {
let since, oldCookie;

function addCookie(cookie) {
Services.cookies.add(cookie.host, cookie.path, cookie.name, "test", false, false, false, Date.now() / 1000 + 10000, {}, Ci.nsICookie2.SAMESITE_UNSET);
Services.cookies.add(cookie.host, cookie.path, cookie.name, "test", false, false, false, Date.now() / 1000 + 10000, {}, Ci.nsICookie2.SAMESITE_NONE);
ok(Services.cookies.cookieExists(cookie.host, cookie.path, cookie.name, {}), `Cookie ${cookie.name} was created.`);
}

Expand Down
2 changes: 1 addition & 1 deletion browser/components/migration/ChromeProfileMigrator.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ async function GetCookiesResource(aProfileFolder) {
false,
parseInt(expiresUtc),
{},
Ci.nsICookie2.SAMESITE_UNSET);
Ci.nsICookie2.SAMESITE_NONE);
} catch (e) {
Cu.reportError(e);
}
Expand Down
2 changes: 1 addition & 1 deletion browser/components/migration/MSMigrationUtils.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ Cookies.prototype = {
false, // session
expireTime,
{},
Ci.nsICookie2.SAMESITE_UNSET);
Ci.nsICookie2.SAMESITE_NONE);
}
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def createCookie(self):
// Expire in 15 minutes:
let expireTime = Math.floor(Date.now() / 1000) + 15 * 60;
Services.cookies.add(arguments[0], arguments[1], arguments[2], arguments[3],
true, false, false, expireTime, {}, Ci.nsICookie2.SAMESITE_UNSET);
true, false, false, expireTime, {}, Ci.nsICookie2.SAMESITE_NONE);
""", script_args=(self._cookieHost, self._cookiePath, self._cookieName, self._cookieValue))

def createSession(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,18 @@ add_task(async function() {
let uri2 = Services.io.newURI("https://example.org");
Services.cookies.add(uri.host, uri.pathQueryRef, "test1", "1",
false, false, false, Date.now() + 1000 * 60 * 60, {},
Ci.nsICookie2.SAMESITE_UNSET);
Ci.nsICookie2.SAMESITE_NONE);
Services.cookies.add(uri.host, uri.pathQueryRef, "test2", "2",
false, false, false, Date.now() + 1000 * 60 * 60, {},
Ci.nsICookie2.SAMESITE_UNSET);
Ci.nsICookie2.SAMESITE_NONE);
Services.cookies.add(uri2.host, uri2.pathQueryRef, "test1", "1",
false, false, false, Date.now() + 1000 * 60 * 60, {},
Ci.nsICookie2.SAMESITE_UNSET);
Ci.nsICookie2.SAMESITE_NONE);

// Ensure that private browsing cookies are ignored.
Services.cookies.add(uri.host, uri.pathQueryRef, "test3", "3",
false, false, false, Date.now() + 1000 * 60 * 60, { privateBrowsingId: 1 },
Ci.nsICookie2.SAMESITE_UNSET);
Ci.nsICookie2.SAMESITE_NONE);

// Get the exact creation date from the cookies (to avoid intermittents
// from minimal time differences, since we round up to minutes).
Expand Down
2 changes: 1 addition & 1 deletion browser/components/sessionstore/SessionCookies.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ var SessionCookiesInternal = {
cookie.value, !!cookie.secure, !!cookie.httponly,
/* isSession = */ true, expiry,
cookie.originAttributes || {},
Ci.nsICookie2.SAMESITE_UNSET);
Ci.nsICookie2.SAMESITE_NONE);
} catch (ex) {
Cu.reportError(`nsCookieService::Add failed with error '${ex}' for cookie ${JSON.stringify(cookie)}.`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function addCookie(scheme, secure = false) {
cookie.secure, /* isHttpOnly = */ false,
/* isSession = */ true, MAX_EXPIRY,
/* originAttributes = */ {},
Ci.nsICookie2.SAMESITE_UNSET);
Ci.nsICookie2.SAMESITE_NONE);
return cookie;
}

Expand Down
2 changes: 1 addition & 1 deletion devtools/server/actors/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ StorageActors.createActor({
case cookie.SAMESITE_STRICT:
return COOKIE_SAMESITE.STRICT;
}
// cookie.SAMESITE_UNSET
// cookie.SAMESITE_NONE
return COOKIE_SAMESITE.UNSET;
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

function addCookie(cookie) {
let expiry = Date.now() / 1000 + 10000;
Services.cookies.add(cookie.host, cookie.path, cookie.name, "test", false, false, false, expiry, {}, Ci.nsICookie2.SAMESITE_UNSET);
Services.cookies.add(cookie.host, cookie.path, cookie.name, "test", false, false, false, expiry, {}, Ci.nsICookie2.SAMESITE_NONE);
ok(Services.cookies.cookieExists(cookie.host, cookie.path, cookie.name, {}), `Cookie ${cookie.name} was created.`);
}

Expand Down
6 changes: 3 additions & 3 deletions netwerk/cookie/nsCookieService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2871,7 +2871,7 @@ nsCookieService::ImportCookies(nsIFile* aCookieFile) {
nsCookie::GenerateUniqueCreationTime(currentTimeInUsec), false,
Substring(buffer, secureIndex, expiresIndex - secureIndex - 1)
.EqualsLiteral(kTrue),
isHttpOnly, key.mOriginAttributes, nsICookie2::SAMESITE_UNSET);
isHttpOnly, key.mOriginAttributes, nsICookie2::SAMESITE_NONE);
if (!newCookie) {
return NS_ERROR_OUT_OF_MEMORY;
}
Expand Down Expand Up @@ -3318,7 +3318,7 @@ bool nsCookieService::CanSetCookie(nsIURI* aHostURI, const nsCookieKey& aKey,

// If the new cookie is same-site but in a cross site context,
// browser must ignore the cookie.
if ((aCookieAttributes.sameSite != nsICookie2::SAMESITE_UNSET) &&
if ((aCookieAttributes.sameSite != nsICookie2::SAMESITE_NONE) &&
aThirdPartyUtil) {
// Do not treat loads triggered by web extensions as foreign
bool addonAllowsLoad = false;
Expand Down Expand Up @@ -3761,7 +3761,7 @@ bool nsCookieService::ParseAttributes(nsDependentCString& aCookieHeader,

aCookieAttributes.isSecure = false;
aCookieAttributes.isHttpOnly = false;
aCookieAttributes.sameSite = nsICookie2::SAMESITE_UNSET;
aCookieAttributes.sameSite = nsICookie2::SAMESITE_NONE;

nsDependentCSubstring tokenString(cookieStart, cookieStart);
nsDependentCSubstring tokenValue(cookieStart, cookieStart);
Expand Down
4 changes: 2 additions & 2 deletions netwerk/cookie/nsICookie2.idl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
[builtinclass, scriptable, uuid(be205dae-4f4c-11e6-80ba-ea5cd310c1a8)]
interface nsICookie2 : nsICookie
{
const uint32_t SAMESITE_UNSET = 0;
const uint32_t SAMESITE_NONE = 0;
const uint32_t SAMESITE_LAX = 1;
const uint32_t SAMESITE_STRICT = 2;

Expand Down Expand Up @@ -68,7 +68,7 @@ interface nsICookie2 : nsICookie
* https://tools.ietf.org/html/draft-west-first-party-cookies-07
*
* This should be one of:
* - SAMESITE_UNSET - the SameSite attribute is not present
* - SAMESITE_NONE - the SameSite attribute is not present
* - SAMESITE_LAX - the SameSite attribute is present, but not strict
* - SAMESITE_STRICT - the SameSite attribute is present and strict
*/
Expand Down
16 changes: 8 additions & 8 deletions netwerk/test/TestCookie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ TEST(TestCookie, TestCookieMain)
true, // is session
INT64_MAX, // expiry time
&attrs, // originAttributes
nsICookie2::SAMESITE_UNSET)));
nsICookie2::SAMESITE_NONE)));
EXPECT_TRUE(NS_SUCCEEDED(
cookieMgr2->AddNative(NS_LITERAL_CSTRING("cookiemgr.test"), // domain
NS_LITERAL_CSTRING("/foo"), // path
Expand All @@ -868,7 +868,7 @@ TEST(TestCookie, TestCookieMain)
true, // is session
PR_Now() / PR_USEC_PER_SEC + 2, // expiry time
&attrs, // originAttributes
nsICookie2::SAMESITE_UNSET)));
nsICookie2::SAMESITE_NONE)));
EXPECT_TRUE(NS_SUCCEEDED(
cookieMgr2->AddNative(NS_LITERAL_CSTRING("new.domain"), // domain
NS_LITERAL_CSTRING("/rabbit"), // path
Expand All @@ -879,7 +879,7 @@ TEST(TestCookie, TestCookieMain)
true, // is session
INT64_MAX, // expiry time
&attrs, // originAttributes
nsICookie2::SAMESITE_UNSET)));
nsICookie2::SAMESITE_NONE)));
// confirm using enumerator
nsCOMPtr<nsISimpleEnumerator> enumerator;
EXPECT_TRUE(
Expand Down Expand Up @@ -941,7 +941,7 @@ TEST(TestCookie, TestCookieMain)
true, // is session
INT64_MIN, // expiry time
&attrs, // originAttributes
nsICookie2::SAMESITE_UNSET)));
nsICookie2::SAMESITE_NONE)));
EXPECT_TRUE(NS_SUCCEEDED(cookieMgr2->CookieExistsNative(
NS_LITERAL_CSTRING("new.domain"), NS_LITERAL_CSTRING("/rabbit"),
NS_LITERAL_CSTRING("test3"), &attrs, &found)));
Expand Down Expand Up @@ -1079,13 +1079,13 @@ TEST(TestCookie, TestCookieMain)
int32_t sameSiteAttr;
cookie2->GetSameSite(&sameSiteAttr);
if (name.EqualsLiteral("unset")) {
EXPECT_TRUE(sameSiteAttr == nsICookie2::SAMESITE_UNSET);
EXPECT_TRUE(sameSiteAttr == nsICookie2::SAMESITE_NONE);
} else if (name.EqualsLiteral("unspecified")) {
EXPECT_TRUE(sameSiteAttr == nsICookie2::SAMESITE_UNSET);
EXPECT_TRUE(sameSiteAttr == nsICookie2::SAMESITE_NONE);
} else if (name.EqualsLiteral("empty")) {
EXPECT_TRUE(sameSiteAttr == nsICookie2::SAMESITE_UNSET);
EXPECT_TRUE(sameSiteAttr == nsICookie2::SAMESITE_NONE);
} else if (name.EqualsLiteral("bogus")) {
EXPECT_TRUE(sameSiteAttr == nsICookie2::SAMESITE_UNSET);
EXPECT_TRUE(sameSiteAttr == nsICookie2::SAMESITE_NONE);
} else if (name.EqualsLiteral("strict")) {
EXPECT_TRUE(sameSiteAttr == nsICookie2::SAMESITE_STRICT);
} else if (name.EqualsLiteral("lax")) {
Expand Down
2 changes: 1 addition & 1 deletion netwerk/test/mochitests/file_testloadflags_chromescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ addMessageListener("init", ({ domain }) => {

cs.removeAll();
cs.add(domain, "", "oh", "hai", false, false, true, Math.pow(2, 62), {},
Ci.nsICookie2.SAMESITE_UNSET);
Ci.nsICookie2.SAMESITE_NONE);
is(cs.countCookiesFromHost(domain), 1, "number of cookies for domain " + domain);

gObs = new obs();
Expand Down
2 changes: 1 addition & 1 deletion netwerk/test/unit/test_bug411952.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function run_test() {
Assert.notEqual(cm, null, "Retrieving the cookie manager failed");

const time = (new Date("Jan 1, 2030")).getTime() / 1000;
cm.add("example.com", "/", "C", "V", false, true, false, time, {}, Ci.nsICookie2.SAMESITE_UNSET);
cm.add("example.com", "/", "C", "V", false, true, false, time, {}, Ci.nsICookie2.SAMESITE_NONE);
const now = Math.floor((new Date()).getTime() / 1000);

var found = false;
Expand Down
14 changes: 7 additions & 7 deletions netwerk/test/unit/test_bug526789.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function run_test() {
// test that variants of 'baz.com' get normalized appropriately, but that
// malformed hosts are rejected
cm.add("baz.com", "/", "foo", "bar", false, false, true, expiry, {},
Ci.nsICookie2.SAMESITE_UNSET);
Ci.nsICookie2.SAMESITE_NONE);
Assert.equal(cm.countCookiesFromHost("baz.com"), 1);
Assert.equal(cm.countCookiesFromHost("BAZ.com"), 1);
Assert.equal(cm.countCookiesFromHost(".baz.com"), 1);
Expand All @@ -36,7 +36,7 @@ function run_test() {

// Test that 'baz.com' and 'baz.com.' are treated differently
cm.add("baz.com.", "/", "foo", "bar", false, false, true, expiry, {},
Ci.nsICookie2.SAMESITE_UNSET);
Ci.nsICookie2.SAMESITE_NONE);
Assert.equal(cm.countCookiesFromHost("baz.com"), 0);
Assert.equal(cm.countCookiesFromHost("BAZ.com"), 0);
Assert.equal(cm.countCookiesFromHost(".baz.com"), 0);
Expand All @@ -50,7 +50,7 @@ function run_test() {
// test that domain cookies are illegal for IP addresses, aliases such as
// 'localhost', and eTLD's such as 'co.uk'
cm.add("192.168.0.1", "/", "foo", "bar", false, false, true, expiry, {},
Ci.nsICookie2.SAMESITE_UNSET);
Ci.nsICookie2.SAMESITE_NONE);
Assert.equal(cm.countCookiesFromHost("192.168.0.1"), 1);
Assert.equal(cm.countCookiesFromHost("192.168.0.1."), 0);
do_check_throws(function() {
Expand All @@ -61,7 +61,7 @@ function run_test() {
}, Cr.NS_ERROR_ILLEGAL_VALUE);

cm.add("localhost", "/", "foo", "bar", false, false, true, expiry, {},
Ci.nsICookie2.SAMESITE_UNSET);
Ci.nsICookie2.SAMESITE_NONE);
Assert.equal(cm.countCookiesFromHost("localhost"), 1);
Assert.equal(cm.countCookiesFromHost("localhost."), 0);
do_check_throws(function() {
Expand All @@ -72,7 +72,7 @@ function run_test() {
}, Cr.NS_ERROR_ILLEGAL_VALUE);

cm.add("co.uk", "/", "foo", "bar", false, false, true, expiry, {},
Ci.nsICookie2.SAMESITE_UNSET);
Ci.nsICookie2.SAMESITE_NONE);
Assert.equal(cm.countCookiesFromHost("co.uk"), 1);
Assert.equal(cm.countCookiesFromHost("co.uk."), 0);
do_check_throws(function() {
Expand Down Expand Up @@ -160,11 +160,11 @@ function run_test() {
// test that an empty host to add() or remove() works,
// but a host of '.' doesn't
cm.add("", "/", "foo2", "bar", false, false, true, expiry, {},
Ci.nsICookie2.SAMESITE_UNSET);
Ci.nsICookie2.SAMESITE_NONE);
Assert.equal(getCookieCount(), 1);
do_check_throws(function() {
cm.add(".", "/", "foo3", "bar", false, false, true, expiry, {},
Ci.nsICookie2.SAMESITE_UNSET);
Ci.nsICookie2.SAMESITE_NONE);
}, Cr.NS_ERROR_ILLEGAL_VALUE);
Assert.equal(getCookieCount(), 1);

Expand Down
2 changes: 1 addition & 1 deletion netwerk/test/unit/test_bug650522.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function run_test() {

// Test our handling of host names with a single character at the beginning
// followed by a dot.
cm.add("e.mail.com", "/", "foo", "bar", false, false, true, expiry, {}, Ci.nsICookie2.SAMESITE_UNSET);
cm.add("e.mail.com", "/", "foo", "bar", false, false, true, expiry, {}, Ci.nsICookie2.SAMESITE_NONE);
Assert.equal(cm.countCookiesFromHost("e.mail.com"), 1);
Assert.equal(cs.getCookieString(NetUtil.newURI("http://e.mail.com"), null), "foo=bar");
}
2 changes: 1 addition & 1 deletion netwerk/test/unit/test_bug667087.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function run_test() {

// Test our handling of host names with a single character consisting only
// of a single character
cm.add("a", "/", "foo", "bar", false, false, true, expiry, {}, Ci.nsICookie2.SAMESITE_UNSET);
cm.add("a", "/", "foo", "bar", false, false, true, expiry, {}, Ci.nsICookie2.SAMESITE_NONE);
Assert.equal(cm.countCookiesFromHost("a"), 1);
Assert.equal(cs.getCookieString(NetUtil.newURI("http://a"), null), "foo=bar");
}
2 changes: 1 addition & 1 deletion netwerk/test/unit/test_cookies_async_failure.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ function* run_test_1(generator)
// Attempt to insert a cookie with the same (name, host, path) triplet.
Services.cookiemgr.add(cookie.host, cookie.path, cookie.name, "hallo",
cookie.isSecure, cookie.isHttpOnly, cookie.isSession, cookie.expiry, {},
Ci.nsICookie2.SAMESITE_UNSET);
Ci.nsICookie2.SAMESITE_NONE);

// Check that the cookie service accepted the new cookie.
Assert.equal(Services.cookiemgr.countCookiesFromHost(cookie.host), 1);
Expand Down
2 changes: 1 addition & 1 deletion netwerk/test/unit/test_cookies_profile_close.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function* do_run_test() {

do_check_throws(function() {
Services.cookiemgr.add("foo.com", "", "oh4", "hai", false, false, false, 0, {},
Ci.nsICookie2.SAMESITE_UNSET);
Ci.nsICookie2.SAMESITE_NONE);
}, Cr.NS_ERROR_NOT_AVAILABLE);

do_check_throws(function() {
Expand Down
Loading

0 comments on commit e9bbb85

Please sign in to comment.