Backed out 5 changesets (bug 1551798) for failures on test_rawSameSite.js. CLOSED TREE

Backed out changeset 11ddc433b632 (bug 1551798)
Backed out changeset f2ac8efb023d (bug 1551798)
Backed out changeset 0f6e797b434f (bug 1551798)
Backed out changeset eae7f88660c8 (bug 1551798)
Backed out changeset 2ba747afb3d0 (bug 1551798)
This commit is contained in:
Csoregi Natalia 2019-05-30 10:17:01 +03:00
Родитель 99eb67df5d
Коммит a51ae3670f
15 изменённых файлов: 30 добавлений и 368 удалений

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

@ -1,24 +0,0 @@
const BODY = `
<script>
opener.postMessage("ok!", "*");
close();
</script>`;
function handleRequest(request, response) {
// avoid confusing cache behaviors
response.setHeader("Cache-Control", "no-cache", false);
if (request.queryString.includes("unset")) {
response.setHeader("Set-Cookie", "test=wow", true);
}
if (request.queryString.includes("none")) {
response.setHeader("Set-Cookie", "test2=wow2; samesite=none", true);
}
if (request.queryString.includes("lax")) {
response.setHeader("Set-Cookie", "test3=wow3; samesite=lax", true);
}
response.write(BODY);
}

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

@ -44,5 +44,3 @@ skip-if = toolkit == 'android'
[test_same_site_cookies_about.html]
[test_assert_about_page_no_csp.html]
skip-if = !debug || toolkit == 'android'
[test_same_site_cookies_laxByDefault.html]
support-files = closeWindow.sjs

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

@ -1,86 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Bug 1551798 - SameSite=lax by default</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<script class="testbody" type="text/javascript">
const CROSS_ORIGIN = "http://example.com/";
const PATH = "tests/dom/security/test/general/closeWindow.sjs";
async function realTest(noneRequiresSecure) {
let types = ["unset", "lax", "none"];
for (let i = 0; i < types.length; ++i) {
info("Loading a new top-level page (" + types[i] + ")");
await new Promise(resolve => {
window.addEventListener("message", _ => {
resolve();
}, { once: true });
window.open(CROSS_ORIGIN + PATH + "?" + types[i]);
});
}
info("Check cookies");
let chromeScript = SpecialPowers.loadChromeScript(() => {
const {sendAsyncMessage} = this;
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
let cookies = { test: null, test2: null, test3: null };
for (let cookie of Services.cookies.enumerator) {
if (cookie.host != "example.com") continue;
if (cookie.name == "test" && cookie.value == "wow") {
cookies.test = cookie.sameSite == Ci.nsICookie2.SAMESITE_LAX ? 'lax' : 'none';
}
if (cookie.name == "test2" && cookie.value == "wow2") {
cookies.test2 = cookie.sameSite == Ci.nsICookie2.SAMESITE_LAX ? 'lax' : 'none';
}
if (cookie.name == "test3" && cookie.value == "wow3") {
cookies.test3 = cookie.sameSite == Ci.nsICookie2.SAMESITE_LAX ? 'lax' : 'none';
}
}
Services.cookies.removeAll();
sendAsyncMessage('result', cookies);
});
let cookies = await new Promise(resolve => {
chromeScript.addMessageListener('result', cookies => {
chromeScript.destroy();
resolve(cookies);
});
});
is(cookies.test, "lax", "Cookie set without samesite is lax by default");
if (noneRequiresSecure) {
is(cookies.test2, null, "Cookie set with samesite none, but not secure");
} else {
is(cookies.test2, "none", "Cookie set with samesite none");
}
is(cookies.test3, "lax", "Cookie set with samesite lax");
}
SpecialPowers.pushPrefEnv({"set": [
["network.cookie.sameSite.laxByDefault", true],
["network.cookie.sameSite.noneRequiresSecure", false],
]}).then(_ => {
return realTest(false);
}).then(_ => {
return SpecialPowers.pushPrefEnv({"set": [
["network.cookie.sameSite.laxByDefault", true],
["network.cookie.sameSite.noneRequiresSecure", true]]});
}).then(_ => {
return realTest(true);
}).then(SimpleTest.finish);
SimpleTest.waitForExplicitFinish();
</script>
</body>
</html>

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

@ -5435,20 +5435,6 @@ VARCACHE_PREF(
RelaxedAtomicInt32, 0
)
VARCACHE_PREF(
Live,
"network.cookie.sameSite.laxByDefault",
network_cookie_sameSite_laxByDefault,
bool, false
)
VARCACHE_PREF(
Live,
"network.cookie.sameSite.noneRequiresSecure",
network_cookie_sameSite_noneRequiresSecure,
bool, false
)
// Enables the predictive service.
VARCACHE_PREF(
Live,

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

@ -115,8 +115,7 @@ void CookieServiceChild::MoveCookies() {
cookie->Name(), cookie->Value(), cookie->Host(), cookie->Path(),
cookie->Expiry(), cookie->LastAccessed(), cookie->CreationTime(),
cookie->IsSession(), cookie->IsSecure(), cookie->IsHttpOnly(),
cookie->OriginAttributesRef(), cookie->SameSite(),
cookie->RawSameSite());
cookie->OriginAttributesRef(), cookie->SameSite());
newCookiesList.AppendElement(newCookie);
}
cookiesList->SwapElements(newCookiesList);
@ -224,7 +223,7 @@ mozilla::ipc::IPCResult CookieServiceChild::RecvAddCookie(
aCookie.name(), aCookie.value(), aCookie.host(), aCookie.path(),
aCookie.expiry(), aCookie.lastAccessed(), aCookie.creationTime(),
aCookie.isSession(), aCookie.isSecure(), aCookie.isHttpOnly(), aAttrs,
aCookie.sameSite(), aCookie.rawSameSite());
aCookie.sameSite());
RecordDocumentCookie(cookie, aAttrs);
return IPC_OK();
}
@ -248,7 +247,7 @@ mozilla::ipc::IPCResult CookieServiceChild::RecvTrackCookiesLoad(
aCookiesList[i].path(), aCookiesList[i].expiry(),
aCookiesList[i].lastAccessed(), aCookiesList[i].creationTime(),
aCookiesList[i].isSession(), aCookiesList[i].isSecure(), false, aAttrs,
aCookiesList[i].sameSite(), aCookiesList[i].rawSameSite());
aCookiesList[i].sameSite());
RecordDocumentCookie(cookie, aAttrs);
}
@ -405,8 +404,7 @@ void CookieServiceChild::SetCookieInternal(
aCookieAttributes.path, aCookieAttributes.expiryTime, currentTimeInUsec,
nsCookie::GenerateUniqueCreationTime(currentTimeInUsec),
aCookieAttributes.isSession, aCookieAttributes.isSecure,
aCookieAttributes.isHttpOnly, aAttrs, aCookieAttributes.sameSite,
aCookieAttributes.rawSameSite);
aCookieAttributes.isHttpOnly, aAttrs, aCookieAttributes.sameSite);
RecordDocumentCookie(cookie, aAttrs);
}

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

@ -70,7 +70,6 @@ void GetInfoFromCookie(nsCookie* aCookie, CookieStruct& aCookieStruct) {
aCookieStruct.isSecure() = aCookie->IsSecure();
aCookieStruct.isHttpOnly() = aCookie->IsHttpOnly();
aCookieStruct.sameSite() = aCookie->SameSite();
aCookieStruct.rawSameSite() = aCookie->RawSameSite();
}
void CookieServiceParent::RemoveBatchDeletedCookies(nsIArray* aCookieList) {
@ -179,7 +178,6 @@ void CookieServiceParent::SerialializeCookieList(
cookieStruct->isSession() = cookie->IsSession();
cookieStruct->isSecure() = cookie->IsSecure();
cookieStruct->sameSite() = cookie->SameSite();
cookieStruct->rawSameSite() = cookie->RawSameSite();
}
}

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

@ -80,8 +80,7 @@ already_AddRefed<nsCookie> nsCookie::Create(
const nsACString& aName, const nsACString& aValue, const nsACString& aHost,
const nsACString& aPath, int64_t aExpiry, int64_t aLastAccessed,
int64_t aCreationTime, bool aIsSession, bool aIsSecure, bool aIsHttpOnly,
const OriginAttributes& aOriginAttributes, int32_t aSameSite,
int32_t aRawSameSite) {
const OriginAttributes& aOriginAttributes, int32_t aSameSite) {
// Ensure mValue contains a valid UTF-8 sequence. Otherwise XPConnect will
// truncate the string after the first invalid octet.
nsAutoCString aUTF8Value;
@ -110,16 +109,10 @@ already_AddRefed<nsCookie> nsCookie::Create(
aSameSite = nsICookie2::SAMESITE_STRICT;
}
// If aRawSameSite is not a sensible value, assume strict
if (aRawSameSite < 0 || aRawSameSite > nsICookie2::SAMESITE_STRICT) {
aRawSameSite = nsICookie2::SAMESITE_STRICT;
}
// construct the cookie. placement new, oh yeah!
RefPtr<nsCookie> cookie =
new (place) nsCookie(name, value, host, path, end, aExpiry, aLastAccessed,
aCreationTime, aIsSession, aIsSecure, aIsHttpOnly,
aOriginAttributes, aSameSite, aRawSameSite);
RefPtr<nsCookie> cookie = new (place) nsCookie(
name, value, host, path, end, aExpiry, aLastAccessed, aCreationTime,
aIsSession, aIsSecure, aIsHttpOnly, aOriginAttributes, aSameSite);
return cookie.forget();
}

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

@ -39,8 +39,7 @@ class nsCookie final : public nsICookie2 {
const char* aPath, const char* aEnd, int64_t aExpiry,
int64_t aLastAccessed, int64_t aCreationTime, bool aIsSession,
bool aIsSecure, bool aIsHttpOnly,
const OriginAttributes& aOriginAttributes, int32_t aSameSite,
int32_t aRawSameSite)
const OriginAttributes& aOriginAttributes, int32_t aSameSite)
: mName(aName),
mValue(aValue),
mHost(aHost),
@ -53,8 +52,7 @@ class nsCookie final : public nsICookie2 {
mIsSecure(aIsSecure),
mIsHttpOnly(aIsHttpOnly),
mOriginAttributes(aOriginAttributes),
mSameSite(aSameSite),
mRawSameSite(aRawSameSite) {}
mSameSite(aSameSite) {}
public:
// Generate a unique and monotonically increasing creation time. See comment
@ -67,8 +65,7 @@ class nsCookie final : public nsICookie2 {
const nsACString& aHost, const nsACString& aPath, int64_t aExpiry,
int64_t aLastAccessed, int64_t aCreationTime, bool aIsSession,
bool aIsSecure, bool aIsHttpOnly,
const OriginAttributes& aOriginAttributes, int32_t aSameSite,
int32_t aRawSameSite);
const OriginAttributes& aOriginAttributes, int32_t aSameSite);
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
@ -103,7 +100,6 @@ class nsCookie final : public nsICookie2 {
return mOriginAttributes;
}
inline int32_t SameSite() const { return mSameSite; }
inline int32_t RawSameSite() const { return mRawSameSite; }
// setters
inline void SetExpiry(int64_t aExpiry) { mExpiry = aExpiry; }
@ -139,9 +135,6 @@ class nsCookie final : public nsICookie2 {
bool mIsHttpOnly;
mozilla::OriginAttributes mOriginAttributes;
int32_t mSameSite;
// This will be removed, together with all the rest, in bug 1554377.
int32_t mRawSameSite;
};
// Comparator class for sorting cookies before sending to a server.

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

@ -87,7 +87,7 @@ static StaticRefPtr<nsCookieService> gCookieService;
#define HTTP_ONLY_PREFIX "#HttpOnly_"
#define COOKIES_FILE "cookies.sqlite"
#define COOKIES_SCHEMA_VERSION 10
#define COOKIES_SCHEMA_VERSION 9
// parameter indexes; see |Read|
#define IDX_NAME 0
@ -102,7 +102,6 @@ static StaticRefPtr<nsCookieService> gCookieService;
#define IDX_BASE_DOMAIN 9
#define IDX_ORIGIN_ATTRIBUTES 10
#define IDX_SAME_SITE 11
#define IDX_RAW_SAME_SITE 12
#define TOPIC_CLEAR_ORIGIN_DATA "clear-origin-attributes-data"
@ -1233,24 +1232,7 @@ OpenDBResult nsCookieService::TryInitDB(bool aRecreateDB) {
NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
// Create a new_moz_cookies table without the appId field.
rv = mDefaultDBState->syncConn->ExecuteSimpleSQL(
NS_LITERAL_CSTRING("CREATE TABLE new_moz_cookies("
"id INTEGER PRIMARY KEY, "
"baseDomain TEXT, "
"originAttributes TEXT NOT NULL DEFAULT '', "
"name TEXT, "
"value TEXT, "
"host TEXT, "
"path TEXT, "
"expiry INTEGER, "
"lastAccessed INTEGER, "
"creationTime INTEGER, "
"isSecure INTEGER, "
"isHttpOnly INTEGER, "
"inBrowserElement INTEGER DEFAULT 0, "
"CONSTRAINT moz_uniqueid UNIQUE (name, host, "
"path, originAttributes)"
")"));
rv = CreateTableWorker("new_moz_cookies");
NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
// Move the data over.
@ -1309,27 +1291,15 @@ OpenDBResult nsCookieService::TryInitDB(bool aRecreateDB) {
// Add the sameSite column to the table.
rv = mDefaultDBState->syncConn->ExecuteSimpleSQL(
NS_LITERAL_CSTRING("ALTER TABLE moz_cookies ADD sameSite INTEGER"));
NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
COOKIE_LOGSTRING(LogLevel::Debug,
("Upgraded database to schema version 9"));
}
MOZ_FALLTHROUGH;
case 9: {
// Add the rawSameSite column to the table.
rv = mDefaultDBState->syncConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
"ALTER TABLE moz_cookies ADD rawSameSite INTEGER"));
NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
COOKIE_LOGSTRING(LogLevel::Debug,
("Upgraded database to schema version 10"));
// No more upgrades. Update the schema version.
rv =
mDefaultDBState->syncConn->SetSchemaVersion(COOKIES_SCHEMA_VERSION);
NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
}
MOZ_FALLTHROUGH;
case COOKIES_SCHEMA_VERSION:
@ -1373,8 +1343,7 @@ OpenDBResult nsCookieService::TryInitDB(bool aRecreateDB) {
"creationTime, "
"isSecure, "
"isHttpOnly, "
"sameSite, "
"rawSameSite "
"sameSite "
"FROM moz_cookies"),
getter_AddRefs(stmt));
if (NS_SUCCEEDED(rv)) break;
@ -1444,7 +1413,7 @@ void nsCookieService::InitDBConn() {
tuple.cookie->path, tuple.cookie->expiry, tuple.cookie->lastAccessed,
tuple.cookie->creationTime, false, tuple.cookie->isSecure,
tuple.cookie->isHttpOnly, tuple.cookie->originAttributes,
tuple.cookie->sameSite, tuple.cookie->rawSameSite);
tuple.cookie->sameSite);
AddCookieToList(tuple.key, cookie, mDefaultDBState, nullptr, false);
}
@ -1518,8 +1487,7 @@ nsresult nsCookieService::InitDBConnInternal() {
"creationTime, "
"isSecure, "
"isHttpOnly, "
"sameSite, "
"rawSameSite "
"sameSite "
") VALUES ("
":baseDomain, "
":originAttributes, "
@ -1532,8 +1500,7 @@ nsresult nsCookieService::InitDBConnInternal() {
":creationTime, "
":isSecure, "
":isHttpOnly, "
":sameSite, "
":rawSameSite "
":sameSite"
")"),
getter_AddRefs(mDefaultDBState->stmtInsert));
NS_ENSURE_SUCCESS(rv, rv);
@ -1577,7 +1544,6 @@ nsresult nsCookieService::CreateTableWorker(const char* aName) {
"isHttpOnly INTEGER, "
"inBrowserElement INTEGER DEFAULT 0, "
"sameSite INTEGER DEFAULT 0, "
"rawSameSite INTEGER DEFAULT 0, "
"CONSTRAINT moz_uniqueid UNIQUE (name, host, path, originAttributes)"
")");
return mDefaultDBState->syncConn->ExecuteSimpleSQL(command);
@ -2528,7 +2494,7 @@ nsCookieService::AddNative(const nsACString& aHost, const nsACString& aPath,
RefPtr<nsCookie> cookie = nsCookie::Create(
aName, aValue, host, aPath, aExpiry, currentTimeInUsec,
nsCookie::GenerateUniqueCreationTime(currentTimeInUsec), aIsSession,
aIsSecure, aIsHttpOnly, key.mOriginAttributes, aSameSite, aSameSite);
aIsSecure, aIsHttpOnly, key.mOriginAttributes, aSameSite);
if (!cookie) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -2646,12 +2612,11 @@ mozilla::UniquePtr<ConstCookie> nsCookieService::GetCookieFromRow(
bool isSecure = 0 != aRow->AsInt32(IDX_SECURE);
bool isHttpOnly = 0 != aRow->AsInt32(IDX_HTTPONLY);
int32_t sameSite = aRow->AsInt32(IDX_SAME_SITE);
int32_t rawSameSite = aRow->AsInt32(IDX_RAW_SAME_SITE);
// Create a new constCookie and assign the data.
return mozilla::MakeUnique<ConstCookie>(
name, value, host, path, expiry, lastAccessed, creationTime, isSecure,
isHttpOnly, aOriginAttributes, sameSite, rawSameSite);
isHttpOnly, aOriginAttributes, sameSite);
}
void nsCookieService::EnsureReadComplete(bool aInitDBConn) {
@ -2726,8 +2691,7 @@ OpenDBResult nsCookieService::Read() {
"isHttpOnly, "
"baseDomain, "
"originAttributes, "
"sameSite, "
"rawSameSite "
"sameSite "
"FROM moz_cookies "
"WHERE baseDomain NOTNULL"),
getter_AddRefs(stmt));
@ -2907,8 +2871,7 @@ nsCookieService::ImportCookies(nsIFile* aCookieFile) {
nsCookie::GenerateUniqueCreationTime(currentTimeInUsec), false,
Substring(buffer, secureIndex, expiresIndex - secureIndex - 1)
.EqualsLiteral(kTrue),
isHttpOnly, key.mOriginAttributes, nsICookie2::SAMESITE_NONE,
nsICookie2::SAMESITE_NONE);
isHttpOnly, key.mOriginAttributes, nsICookie2::SAMESITE_NONE);
if (!newCookie) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -3230,12 +3193,7 @@ bool nsCookieService::CanSetCookie(nsIURI* aHostURI, const nsCookieKey& aKey,
// newCookie says whether there are multiple cookies in the header;
// so we can handle them separately.
bool acceptedByParser = false;
bool newCookie =
ParseAttributes(aCookieHeader, aCookieAttributes, acceptedByParser);
if (!acceptedByParser) {
return newCookie;
}
bool newCookie = ParseAttributes(aCookieHeader, aCookieAttributes);
// Collect telemetry on how often secure cookies are set from non-secure
// origins, and vice-versa.
@ -3418,7 +3376,7 @@ bool nsCookieService::SetCookieInternal(nsIURI* aHostURI,
nsCookie::GenerateUniqueCreationTime(currentTimeInUsec),
cookieAttributes.isSession, cookieAttributes.isSecure,
cookieAttributes.isHttpOnly, aKey.mOriginAttributes,
cookieAttributes.sameSite, cookieAttributes.rawSameSite);
cookieAttributes.sameSite);
if (!cookie) return newCookie;
// check permissions from site permission list, or ask the user,
@ -3785,10 +3743,7 @@ bool nsCookieService::GetTokenValue(nsACString::const_char_iterator& aIter,
// folded into the cookie struct here, because we don't know which one to use
// until we've parsed the header.
bool nsCookieService::ParseAttributes(nsDependentCString& aCookieHeader,
nsCookieAttributes& aCookieAttributes,
bool& aAcceptedByParser) {
aAcceptedByParser = false;
nsCookieAttributes& aCookieAttributes) {
static const char kPath[] = "path";
static const char kDomain[] = "domain";
static const char kExpires[] = "expires";
@ -3797,7 +3752,6 @@ bool nsCookieService::ParseAttributes(nsDependentCString& aCookieHeader,
static const char kHttpOnly[] = "httponly";
static const char kSameSite[] = "samesite";
static const char kSameSiteLax[] = "lax";
static const char kSameSiteNone[] = "none";
static const char kSameSiteStrict[] = "strict";
nsACString::const_char_iterator tempBegin, tempEnd;
@ -3808,11 +3762,6 @@ bool nsCookieService::ParseAttributes(nsDependentCString& aCookieHeader,
aCookieAttributes.isSecure = false;
aCookieAttributes.isHttpOnly = false;
aCookieAttributes.sameSite = nsICookie2::SAMESITE_NONE;
aCookieAttributes.rawSameSite = nsICookie2::SAMESITE_NONE;
if (StaticPrefs::network_cookie_sameSite_laxByDefault()) {
aCookieAttributes.sameSite = nsICookie2::SAMESITE_LAX;
}
nsDependentCSubstring tokenString(cookieStart, cookieStart);
nsDependentCSubstring tokenValue(cookieStart, cookieStart);
@ -3867,29 +3816,14 @@ bool nsCookieService::ParseAttributes(nsDependentCString& aCookieHeader,
else if (tokenString.LowerCaseEqualsLiteral(kSameSite)) {
if (tokenValue.LowerCaseEqualsLiteral(kSameSiteLax)) {
aCookieAttributes.sameSite = nsICookie2::SAMESITE_LAX;
aCookieAttributes.rawSameSite = nsICookie2::SAMESITE_LAX;
} else if (tokenValue.LowerCaseEqualsLiteral(kSameSiteStrict)) {
aCookieAttributes.sameSite = nsICookie2::SAMESITE_STRICT;
aCookieAttributes.rawSameSite = nsICookie2::SAMESITE_STRICT;
} else if (tokenValue.LowerCaseEqualsLiteral(kSameSiteNone)) {
aCookieAttributes.sameSite = nsICookie2::SAMESITE_NONE;
aCookieAttributes.rawSameSite = nsICookie2::SAMESITE_NONE;
}
}
}
// If same-site is set to 'none' but this is not a secure context, let's abort
// the parsing.
if (StaticPrefs::network_cookie_sameSite_laxByDefault() &&
StaticPrefs::network_cookie_sameSite_noneRequiresSecure() &&
!aCookieAttributes.isSecure &&
aCookieAttributes.sameSite == nsICookie2::SAMESITE_NONE) {
return newCookie;
}
// rebind aCookieHeader, in case we need to process another cookie
aCookieHeader.Rebind(cookieStart, cookieEnd);
aAcceptedByParser = true;
return newCookie;
}
@ -5052,10 +4986,6 @@ void bindCookieParameters(mozIStorageBindingParamsArray* aParamsArray,
aCookie->SameSite());
NS_ASSERT_SUCCESS(rv);
rv = params->BindInt32ByName(NS_LITERAL_CSTRING("rawSameSite"),
aCookie->RawSameSite());
NS_ASSERT_SUCCESS(rv);
// Bind the params to the array.
rv = aParamsArray->AddParams(params);
NS_ASSERT_SUCCESS(rv);

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

@ -94,7 +94,7 @@ struct ConstCookie {
const nsCString& aHost, const nsCString& aPath, int64_t aExpiry,
int64_t aLastAccessed, int64_t aCreationTime, bool aIsSecure,
bool aIsHttpOnly, const OriginAttributes& aOriginAttributes,
int32_t aSameSite, int32_t aRawSameSite)
int32_t aSameSite)
: name(aName),
value(aValue),
host(aHost),
@ -105,8 +105,7 @@ struct ConstCookie {
isSecure(aIsSecure),
isHttpOnly(aIsHttpOnly),
originAttributes(aOriginAttributes),
sameSite(aSameSite),
rawSameSite(aRawSameSite) {}
sameSite(aSameSite) {}
const nsCString name;
const nsCString value;
@ -119,7 +118,6 @@ struct ConstCookie {
const bool isHttpOnly;
const OriginAttributes originAttributes;
const int32_t sameSite;
const int32_t rawSameSite;
};
// encapsulates a (key, nsCookie) tuple for temporary storage purposes.
@ -214,15 +212,6 @@ struct nsCookieAttributes {
bool isSecure;
bool isHttpOnly;
int8_t sameSite;
int8_t rawSameSite;
nsCookieAttributes()
: expiryTime(0),
isSession(false),
isSecure(false),
isHttpOnly(false),
sameSite(nsICookie2::SAMESITE_NONE),
rawSameSite(nsICookie2::SAMESITE_NONE) {}
};
class nsCookieService final : public nsICookieService,
@ -355,8 +344,7 @@ class nsCookieService final : public nsICookieService,
nsDependentCSubstring& aTokenValue,
bool& aEqualsFound);
static bool ParseAttributes(nsDependentCString& aCookieHeader,
nsCookieAttributes& aCookie,
bool& aAcceptedByParser);
nsCookieAttributes& aCookie);
bool RequireThirdPartyCheck();
static bool CheckDomain(nsCookieAttributes& aCookie, nsIURI* aHostURI,
const nsCString& aBaseDomain, bool aRequireHostMatch);

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

@ -49,7 +49,7 @@ conn.executeSimpleSQL("INSERT INTO moz_cookies(" +
// Get sessionEnumerator to wait for the initialization in cookie thread
const enumerator = Services.cookies.sessionEnumerator;
Assert.equal(conn.schemaVersion, 10);
Assert.equal(conn.schemaVersion, 9);
let stmt = conn.createStatement("SELECT sql FROM sqlite_master " +
"WHERE type = 'table' AND " +
" name = 'moz_cookies'");

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

@ -1,110 +0,0 @@
const {NetUtil} = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
function inChildProcess() {
return Services.appinfo.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
}
function run_test() {
do_get_profile();
let dbFile = Services.dirsvc.get("ProfD", Ci.nsIFile);
dbFile.append("cookies.sqlite");
let storage = Services.storage;
let properties = Cc["@mozilla.org/hash-property-bag;1"].
createInstance(Ci.nsIWritablePropertyBag);
properties.setProperty("shared", true);
let conn = storage.openDatabase(dbFile);
conn.schemaVersion = 9;
conn.executeSimpleSQL("DROP TABLE IF EXISTS moz_cookies");
conn.executeSimpleSQL("CREATE TABLE moz_cookies (" +
"id INTEGER PRIMARY KEY, " +
"baseDomain TEXT, " +
"originAttributes TEXT NOT NULL DEFAULT '', " +
"name TEXT, " +
"value TEXT, " +
"host TEXT, " +
"path TEXT, " +
"expiry INTEGER, " +
"lastAccessed INTEGER, " +
"creationTime INTEGER, " +
"isSecure INTEGER, " +
"isHttpOnly INTEGER, " +
"inBrowserElement INTEGER DEFAULT 0, " +
"sameSite INTEGER DEFAULT 0, " +
"CONSTRAINT moz_uniqueid UNIQUE (name, host, path, originAttributes)" +
")");
conn.close();
// Allow all cookies if the pref service is available in this process.
if (!inChildProcess()) {
Services.prefs.setIntPref("network.cookie.cookieBehavior", 0);
Services.prefs.setBoolPref("network.cookieSettings.unblocked_for_testing", true);
Services.prefs.setBoolPref("network.cookie.sameSite.laxByDefault", true);
Services.prefs.setBoolPref("network.cookie.sameSite.noneRequiresSecure", true);
}
let cs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService);
let uri = NetUtil.newURI("http://example.org/");
let principal = Services.scriptSecurityManager.createCodebasePrincipal(uri, {});
let channel = NetUtil.newChannel({
uri,
loadingPrincipal: principal,
securityFlags: Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER,
});
let tests = [
{ cookie: "foo=b;max-age=3600, c=d;path=/; sameSite=strict",
success: true,
sameSite: 2,
rawSameSite: 2,
},
{ cookie: "foo=b;max-age=3600, c=d;path=/; sameSite=lax",
success: true,
sameSite: 1,
rawSameSite: 1,
},
{ cookie: "foo=b;max-age=3600, c=d;path=/; sameSite=none",
success: false,
sameSite: 1,
rawSameSite: 0,
},
{ cookie: "foo=b;max-age=3600, c=d;path=/",
success: true,
sameSite: 1,
rawSameSite: 0,
},
];
tests.forEach(test => {
cs.setCookieStringFromHttp(uri, null, null, test.cookie, null, channel);
conn = storage.openDatabase(dbFile);
Assert.equal(conn.schemaVersion, 10);
let stmt = conn.createStatement("SELECT sameSite, rawSameSite FROM moz_cookies");
let success = stmt.executeStep();
Assert.equal(success, test.success);
if (test.success) {
let sameSite = stmt.getInt32(0);
let rawSameSite = stmt.getInt32(1);
stmt.finalize();
Assert.equal(sameSite, test.sameSite);
Assert.equal(rawSameSite, test.rawSameSite);
}
Services.cookies.removeAll();
stmt.finalize();
conn.close();
});
}

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

@ -7,4 +7,3 @@ head =
[test_parser_0001.js]
[test_parser_0019.js]
[test_eviction.js]
[test_rawSameSite.js]

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

@ -332,7 +332,6 @@ struct CookieStruct
bool isSession;
bool isSecure;
int8_t sameSite;
int8_t rawSameSite;
};
} // namespace ipc

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

@ -18,7 +18,7 @@
// c) Schema 3: the 'creationTime' column already exists; or the
// 'moz_uniqueid' index already exists.
var COOKIE_DATABASE_SCHEMA_CURRENT = 10;
var COOKIE_DATABASE_SCHEMA_CURRENT = 9;
var test_generator = do_run_test();