зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 4cf57a5a3143 (bug 1609176
) for test_cookies_async_failure.js related failures CLOSED TREE
This commit is contained in:
Родитель
6ff9201394
Коммит
c9467840cd
|
@ -67,6 +67,12 @@ using namespace mozilla;
|
|||
using namespace mozilla::dom;
|
||||
using namespace mozilla::net;
|
||||
|
||||
// Create key from baseDomain that will access the default cookie namespace.
|
||||
// TODO: When we figure out what the API will look like for nsICookieManager{2}
|
||||
// on content processes (see bug 777620), change to use the appropriate app
|
||||
// namespace. For now those IDLs aren't supported on child processes.
|
||||
#define DEFAULT_APP_KEY(baseDomain) nsCookieKey(baseDomain, OriginAttributes())
|
||||
|
||||
/******************************************************************************
|
||||
* nsCookieService impl:
|
||||
* useful types & constants
|
||||
|
@ -79,7 +85,7 @@ static StaticRefPtr<nsCookieService> gCookieService;
|
|||
#define HTTP_ONLY_PREFIX "#HttpOnly_"
|
||||
|
||||
#define COOKIES_FILE "cookies.sqlite"
|
||||
#define COOKIES_SCHEMA_VERSION 11
|
||||
#define COOKIES_SCHEMA_VERSION 10
|
||||
|
||||
// parameter indexes; see |Read|
|
||||
#define IDX_NAME 0
|
||||
|
@ -91,9 +97,10 @@ static StaticRefPtr<nsCookieService> gCookieService;
|
|||
#define IDX_CREATION_TIME 6
|
||||
#define IDX_SECURE 7
|
||||
#define IDX_HTTPONLY 8
|
||||
#define IDX_ORIGIN_ATTRIBUTES 9
|
||||
#define IDX_SAME_SITE 10
|
||||
#define IDX_RAW_SAME_SITE 11
|
||||
#define IDX_BASE_DOMAIN 9
|
||||
#define IDX_ORIGIN_ATTRIBUTES 10
|
||||
#define IDX_SAME_SITE 11
|
||||
#define IDX_RAW_SAME_SITE 12
|
||||
|
||||
static const int64_t kCookiePurgeAge =
|
||||
int64_t(30 * 24 * 60 * 60) * PR_USEC_PER_SEC; // 30 days in microseconds
|
||||
|
@ -1240,9 +1247,7 @@ OpenDBResult nsCookieService::TryInitDB(bool aRecreateDB) {
|
|||
NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
|
||||
|
||||
// Recreate our index.
|
||||
rv = mDefaultDBState->syncConn->ExecuteSimpleSQL(
|
||||
NS_LITERAL_CSTRING("CREATE INDEX moz_basedomain ON moz_cookies "
|
||||
"(baseDomain, originAttributes)"));
|
||||
rv = CreateIndex();
|
||||
NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
|
||||
|
||||
COOKIE_LOGSTRING(LogLevel::Debug,
|
||||
|
@ -1274,86 +1279,6 @@ OpenDBResult nsCookieService::TryInitDB(bool aRecreateDB) {
|
|||
|
||||
COOKIE_LOGSTRING(LogLevel::Debug,
|
||||
("Upgraded database to schema version 10"));
|
||||
}
|
||||
[[fallthrough]];
|
||||
|
||||
case 10: {
|
||||
// Rename existing table
|
||||
rv = mDefaultDBState->syncConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"ALTER TABLE moz_cookies RENAME TO moz_cookies_old"));
|
||||
NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
|
||||
|
||||
// Create a new moz_cookies table without the baseDomain field.
|
||||
rv = mDefaultDBState->syncConn->ExecuteSimpleSQL(
|
||||
NS_LITERAL_CSTRING("CREATE TABLE moz_cookies("
|
||||
"id INTEGER PRIMARY KEY, "
|
||||
"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, "
|
||||
"rawSameSite INTEGER DEFAULT 0, "
|
||||
"CONSTRAINT moz_uniqueid UNIQUE (name, host, "
|
||||
"path, originAttributes)"
|
||||
")"));
|
||||
NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
|
||||
|
||||
// Move the data over.
|
||||
rv = mDefaultDBState->syncConn->ExecuteSimpleSQL(
|
||||
NS_LITERAL_CSTRING("INSERT INTO moz_cookies ("
|
||||
"id, "
|
||||
"originAttributes, "
|
||||
"name, "
|
||||
"value, "
|
||||
"host, "
|
||||
"path, "
|
||||
"expiry, "
|
||||
"lastAccessed, "
|
||||
"creationTime, "
|
||||
"isSecure, "
|
||||
"isHttpOnly, "
|
||||
"inBrowserElement, "
|
||||
"sameSite, "
|
||||
"rawSameSite "
|
||||
") SELECT "
|
||||
"id, "
|
||||
"originAttributes, "
|
||||
"name, "
|
||||
"value, "
|
||||
"host, "
|
||||
"path, "
|
||||
"expiry, "
|
||||
"lastAccessed, "
|
||||
"creationTime, "
|
||||
"isSecure, "
|
||||
"isHttpOnly, "
|
||||
"inBrowserElement, "
|
||||
"sameSite, "
|
||||
"rawSameSite "
|
||||
"FROM moz_cookies_old "
|
||||
"WHERE baseDomain NOTNULL;"));
|
||||
NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
|
||||
|
||||
// Drop the old table
|
||||
rv = mDefaultDBState->syncConn->ExecuteSimpleSQL(
|
||||
NS_LITERAL_CSTRING("DROP TABLE moz_cookies_old;"));
|
||||
NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
|
||||
|
||||
// Drop the moz_basedomain index from the database (if it hasn't been
|
||||
// removed already by removing the table).
|
||||
rv = mDefaultDBState->syncConn->ExecuteSimpleSQL(
|
||||
NS_LITERAL_CSTRING("DROP INDEX IF EXISTS moz_basedomain;"));
|
||||
NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
|
||||
|
||||
COOKIE_LOGSTRING(LogLevel::Debug,
|
||||
("Upgraded database to schema version 11"));
|
||||
|
||||
// No more upgrades. Update the schema version.
|
||||
rv =
|
||||
|
@ -1392,6 +1317,7 @@ OpenDBResult nsCookieService::TryInitDB(bool aRecreateDB) {
|
|||
rv = mDefaultDBState->syncConn->CreateStatement(
|
||||
NS_LITERAL_CSTRING("SELECT "
|
||||
"id, "
|
||||
"baseDomain, "
|
||||
"originAttributes, "
|
||||
"name, "
|
||||
"value, "
|
||||
|
@ -1539,6 +1465,7 @@ nsresult nsCookieService::InitDBConnInternal() {
|
|||
// cache frequently used statements (for insertion, deletion, and updating)
|
||||
rv = mDefaultDBState->dbConn->CreateAsyncStatement(
|
||||
NS_LITERAL_CSTRING("INSERT INTO moz_cookies ("
|
||||
"baseDomain, "
|
||||
"originAttributes, "
|
||||
"name, "
|
||||
"value, "
|
||||
|
@ -1552,6 +1479,7 @@ nsresult nsCookieService::InitDBConnInternal() {
|
|||
"sameSite, "
|
||||
"rawSameSite "
|
||||
") VALUES ("
|
||||
":baseDomain, "
|
||||
":originAttributes, "
|
||||
":name, "
|
||||
":value, "
|
||||
|
@ -1594,6 +1522,7 @@ nsresult nsCookieService::CreateTableWorker(const char* aName) {
|
|||
command.AppendLiteral(
|
||||
" ("
|
||||
"id INTEGER PRIMARY KEY, "
|
||||
"baseDomain TEXT, "
|
||||
"originAttributes TEXT NOT NULL DEFAULT '', "
|
||||
"name TEXT, "
|
||||
"value TEXT, "
|
||||
|
@ -1622,7 +1551,14 @@ nsresult nsCookieService::CreateTable() {
|
|||
rv = CreateTableWorker("moz_cookies");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
return CreateIndex();
|
||||
}
|
||||
|
||||
nsresult nsCookieService::CreateIndex() {
|
||||
// Create an index on baseDomain.
|
||||
return mDefaultDBState->syncConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"CREATE INDEX moz_basedomain ON moz_cookies (baseDomain, "
|
||||
"originAttributes)"));
|
||||
}
|
||||
|
||||
// Sets the schema version and creates the moz_cookies table.
|
||||
|
@ -2597,6 +2533,7 @@ nsCookieService::RemoveNative(const nsACString& aHost, const nsACString& aName,
|
|||
// Extract data from a single result row and create an nsCookie.
|
||||
mozilla::UniquePtr<CookieStruct> nsCookieService::GetCookieFromRow(
|
||||
mozIStorageStatement* aRow) {
|
||||
// Skip reading 'baseDomain' -- up to the caller.
|
||||
nsCString name, value, host, path;
|
||||
DebugOnly<nsresult> rv = aRow->GetUTF8String(IDX_NAME, name);
|
||||
NS_ASSERT_SUCCESS(rv);
|
||||
|
@ -2669,10 +2606,18 @@ void nsCookieService::EnsureReadComplete(bool aInitDBConn) {
|
|||
OpenDBResult nsCookieService::Read() {
|
||||
MOZ_ASSERT(NS_GetCurrentThread() == mThread);
|
||||
|
||||
// Set up a statement to delete any rows with a nullptr 'baseDomain'
|
||||
// column. This takes care of any cookies set by browsers that don't
|
||||
// understand the 'baseDomain' column, where the database schema version
|
||||
// is from one that does. (This would occur when downgrading.)
|
||||
nsresult rv = mDefaultDBState->syncConn->ExecuteSimpleSQL(
|
||||
NS_LITERAL_CSTRING("DELETE FROM moz_cookies WHERE baseDomain ISNULL"));
|
||||
NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
|
||||
|
||||
// Read in the data synchronously.
|
||||
// see IDX_NAME, etc. for parameter indexes
|
||||
nsCOMPtr<mozIStorageStatement> stmt;
|
||||
nsresult rv = mDefaultDBState->syncConn->CreateStatement(
|
||||
rv = mDefaultDBState->syncConn->CreateStatement(
|
||||
NS_LITERAL_CSTRING("SELECT "
|
||||
"name, "
|
||||
"value, "
|
||||
|
@ -2683,10 +2628,12 @@ OpenDBResult nsCookieService::Read() {
|
|||
"creationTime, "
|
||||
"isSecure, "
|
||||
"isHttpOnly, "
|
||||
"baseDomain, "
|
||||
"originAttributes, "
|
||||
"sameSite, "
|
||||
"rawSameSite "
|
||||
"FROM moz_cookies"),
|
||||
"FROM moz_cookies "
|
||||
"WHERE baseDomain NOTNULL"),
|
||||
getter_AddRefs(stmt));
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
|
||||
|
@ -2707,6 +2654,8 @@ OpenDBResult nsCookieService::Read() {
|
|||
|
||||
if (!hasResult) break;
|
||||
|
||||
// IDX_BASE_DOMAIN cannot be used, because updates to the public suffix list
|
||||
// may invalidate the value of the stored baseDomain.
|
||||
stmt->GetUTF8String(IDX_HOST, host);
|
||||
|
||||
rv = GetBaseDomainFromHost(mTLDService, host, baseDomain);
|
||||
|
@ -2859,7 +2808,7 @@ nsCookieService::ImportCookies(nsIFile* aCookieFile) {
|
|||
|
||||
// pre-existing cookies have inIsolatedMozBrowser=false set by default
|
||||
// constructor of OriginAttributes().
|
||||
nsCookieKey key(baseDomain, OriginAttributes());
|
||||
nsCookieKey key = DEFAULT_APP_KEY(baseDomain);
|
||||
|
||||
// Create a new nsCookie and assign the data. We don't know the cookie
|
||||
// creation time, so just use the current time to generate a unique one.
|
||||
|
@ -4582,7 +4531,7 @@ nsCookieService::CountCookiesFromHost(const nsACString& aHost,
|
|||
rv = GetBaseDomainFromHost(mTLDService, host, baseDomain);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCookieKey key(baseDomain, OriginAttributes());
|
||||
nsCookieKey key = DEFAULT_APP_KEY(baseDomain);
|
||||
|
||||
// Return a count of all cookies, including expired.
|
||||
nsCookieEntry* entry = mDBState->hostTable.GetEntry(key);
|
||||
|
@ -5047,6 +4996,11 @@ void bindCookieParameters(mozIStorageBindingParamsArray* aParamsArray,
|
|||
aParamsArray->NewBindingParams(getter_AddRefs(params));
|
||||
NS_ASSERT_SUCCESS(rv);
|
||||
|
||||
// Bind our values to params
|
||||
rv = params->BindUTF8StringByName(NS_LITERAL_CSTRING("baseDomain"),
|
||||
aKey.mBaseDomain);
|
||||
NS_ASSERT_SUCCESS(rv);
|
||||
|
||||
nsAutoCString suffix;
|
||||
aKey.mOriginAttributes.CreateSuffix(suffix);
|
||||
rv = params->BindUTF8StringByName(NS_LITERAL_CSTRING("originAttributes"),
|
||||
|
|
|
@ -243,6 +243,7 @@ class nsCookieService final : public nsICookieService,
|
|||
void InitDBConn();
|
||||
nsresult InitDBConnInternal();
|
||||
nsresult CreateTableWorker(const char* aName);
|
||||
nsresult CreateIndex();
|
||||
nsresult CreateTable();
|
||||
nsresult CreateTableForSchemaVersion6();
|
||||
nsresult CreateTableForSchemaVersion5();
|
||||
|
|
|
@ -61,7 +61,7 @@ conn.executeSimpleSQL(
|
|||
// Get sessionCookies to wait for the initialization in cookie thread
|
||||
const cookies = Services.cookies.sessionCookies;
|
||||
|
||||
Assert.equal(conn.schemaVersion, 11);
|
||||
Assert.equal(conn.schemaVersion, 10);
|
||||
let stmt = conn.createStatement(
|
||||
"SELECT sql FROM sqlite_master " +
|
||||
"WHERE type = 'table' AND " +
|
||||
|
@ -77,7 +77,8 @@ try {
|
|||
|
||||
stmt = conn.createStatement(
|
||||
"SELECT * FROM moz_cookies " +
|
||||
"WHERE host = '.foo.com' AND " +
|
||||
"WHERE baseDomain = 'foo.com' AND " +
|
||||
" host = '.foo.com' AND " +
|
||||
" name = 'foo' AND " +
|
||||
" value = 'bar=baz' AND " +
|
||||
" path = '/' AND " +
|
||||
|
|
|
@ -102,7 +102,7 @@ add_task(async _ => {
|
|||
await promise;
|
||||
|
||||
conn = storage.openDatabase(dbFile);
|
||||
Assert.equal(conn.schemaVersion, 11);
|
||||
Assert.equal(conn.schemaVersion, 10);
|
||||
|
||||
let stmt = conn.createStatement(
|
||||
"SELECT sameSite, rawSameSite FROM moz_cookies"
|
||||
|
|
Двоичные данные
netwerk/test/unit/data/cookies_v10.sqlite
Двоичные данные
netwerk/test/unit/data/cookies_v10.sqlite
Двоичный файл не отображается.
|
@ -164,11 +164,7 @@ function Cookie(
|
|||
creationTime,
|
||||
isSession,
|
||||
isSecure,
|
||||
isHttpOnly,
|
||||
inBrowserElement = false,
|
||||
originAttributes = {},
|
||||
sameSite = Ci.nsICookie.SAMESITE_NONE,
|
||||
rawSameSite = Ci.nsICookie.SAMESITE_NONE
|
||||
isHttpOnly
|
||||
) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
|
@ -180,10 +176,6 @@ function Cookie(
|
|||
this.isSession = isSession;
|
||||
this.isSecure = isSecure;
|
||||
this.isHttpOnly = isHttpOnly;
|
||||
this.inBrowserElement = inBrowserElement;
|
||||
this.originAttributes = originAttributes;
|
||||
this.sameSite = sameSite;
|
||||
this.rawSameSite = rawSameSite;
|
||||
|
||||
let strippedHost = host.charAt(0) == "." ? host.slice(1) : host;
|
||||
|
||||
|
@ -426,155 +418,6 @@ function CookieDatabaseConnection(file, schema) {
|
|||
break;
|
||||
}
|
||||
|
||||
case 10: {
|
||||
if (!exists) {
|
||||
this.db.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, \
|
||||
rawSameSite INTEGER DEFAULT 0, \
|
||||
CONSTRAINT moz_uniqueid UNIQUE (name, host, path, originAttributes))"
|
||||
);
|
||||
|
||||
this.db.executeSimpleSQL(
|
||||
"CREATE INDEX moz_basedomain ON moz_cookies (baseDomain)"
|
||||
);
|
||||
|
||||
this.db.executeSimpleSQL("PRAGMA journal_mode = WAL");
|
||||
this.db.executeSimpleSQL("PRAGMA wal_autocheckpoint = 16");
|
||||
}
|
||||
|
||||
this.stmtInsert = this.db.createStatement(
|
||||
"INSERT INTO moz_cookies ( \
|
||||
name, \
|
||||
value, \
|
||||
host, \
|
||||
baseDomain, \
|
||||
path, \
|
||||
expiry, \
|
||||
lastAccessed, \
|
||||
creationTime, \
|
||||
isSecure, \
|
||||
isHttpOnly, \
|
||||
inBrowserElement, \
|
||||
originAttributes, \
|
||||
sameSite, \
|
||||
rawSameSite \
|
||||
) VALUES ( \
|
||||
:name, \
|
||||
:value, \
|
||||
:host, \
|
||||
:baseDomain, \
|
||||
:path, \
|
||||
:expiry, \
|
||||
:lastAccessed, \
|
||||
:creationTime, \
|
||||
:isSecure, \
|
||||
:isHttpOnly, \
|
||||
:inBrowserElement, \
|
||||
:originAttributes, \
|
||||
:sameSite, \
|
||||
:rawSameSite)"
|
||||
);
|
||||
|
||||
this.stmtDelete = this.db.createStatement(
|
||||
"DELETE FROM moz_cookies \
|
||||
WHERE name = :name AND host = :host AND path = :path AND \
|
||||
originAttributes = :originAttributes"
|
||||
);
|
||||
|
||||
this.stmtUpdate = this.db.createStatement(
|
||||
"UPDATE moz_cookies SET lastAccessed = :lastAccessed \
|
||||
WHERE name = :name AND host = :host AND path = :path AND \
|
||||
originAttributes = :originAttributes"
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 11: {
|
||||
if (!exists) {
|
||||
this.db.executeSimpleSQL(
|
||||
"CREATE TABLE moz_cookies ( \
|
||||
id INTEGER PRIMARY KEY, \
|
||||
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, \
|
||||
rawSameSite INTEGER DEFAULT 0, \
|
||||
CONSTRAINT moz_uniqueid UNIQUE (name, host, path, originAttributes))"
|
||||
);
|
||||
|
||||
this.db.executeSimpleSQL("PRAGMA journal_mode = WAL");
|
||||
this.db.executeSimpleSQL("PRAGMA wal_autocheckpoint = 16");
|
||||
}
|
||||
|
||||
this.stmtInsert = this.db.createStatement(
|
||||
"INSERT INTO moz_cookies ( \
|
||||
name, \
|
||||
value, \
|
||||
host, \
|
||||
path, \
|
||||
expiry, \
|
||||
lastAccessed, \
|
||||
creationTime, \
|
||||
isSecure, \
|
||||
isHttpOnly, \
|
||||
inBrowserElement, \
|
||||
originAttributes, \
|
||||
sameSite, \
|
||||
rawSameSite \
|
||||
) VALUES ( \
|
||||
:name, \
|
||||
:value, \
|
||||
:host, \
|
||||
:path, \
|
||||
:expiry, \
|
||||
:lastAccessed, \
|
||||
:creationTime, \
|
||||
:isSecure, \
|
||||
:isHttpOnly, \
|
||||
:inBrowserElement, \
|
||||
:originAttributes, \
|
||||
:sameSite, \
|
||||
:rawSameSite)"
|
||||
);
|
||||
|
||||
this.stmtDelete = this.db.createStatement(
|
||||
"DELETE FROM moz_cookies \
|
||||
WHERE name = :name AND host = :host AND path = :path AND \
|
||||
originAttributes = :originAttributes"
|
||||
);
|
||||
|
||||
this.stmtUpdate = this.db.createStatement(
|
||||
"UPDATE moz_cookies SET lastAccessed = :lastAccessed \
|
||||
WHERE name = :name AND host = :host AND path = :path AND \
|
||||
originAttributes = :originAttributes"
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
do_throw("unrecognized schemaVersion!");
|
||||
}
|
||||
|
@ -636,45 +479,6 @@ CookieDatabaseConnection.prototype = {
|
|||
this.stmtInsert.bindByName("isHttpOnly", cookie.isHttpOnly);
|
||||
break;
|
||||
|
||||
case 10:
|
||||
this.stmtInsert.bindByName("name", cookie.name);
|
||||
this.stmtInsert.bindByName("value", cookie.value);
|
||||
this.stmtInsert.bindByName("host", cookie.host);
|
||||
this.stmtInsert.bindByName("baseDomain", cookie.baseDomain);
|
||||
this.stmtInsert.bindByName("path", cookie.path);
|
||||
this.stmtInsert.bindByName("expiry", cookie.expiry);
|
||||
this.stmtInsert.bindByName("lastAccessed", cookie.lastAccessed);
|
||||
this.stmtInsert.bindByName("creationTime", cookie.creationTime);
|
||||
this.stmtInsert.bindByName("isSecure", cookie.isSecure);
|
||||
this.stmtInsert.bindByName("isHttpOnly", cookie.isHttpOnly);
|
||||
this.stmtInsert.bindByName("inBrowserElement", cookie.inBrowserElement);
|
||||
this.stmtInsert.bindByName(
|
||||
"originAttributes",
|
||||
ChromeUtils.originAttributesToSuffix(cookie.originAttributes)
|
||||
);
|
||||
this.stmtInsert.bindByName("sameSite", cookie.sameSite);
|
||||
this.stmtInsert.bindByName("rawSameSite", cookie.rawSameSite);
|
||||
break;
|
||||
|
||||
case 11:
|
||||
this.stmtInsert.bindByName("name", cookie.name);
|
||||
this.stmtInsert.bindByName("value", cookie.value);
|
||||
this.stmtInsert.bindByName("host", cookie.host);
|
||||
this.stmtInsert.bindByName("path", cookie.path);
|
||||
this.stmtInsert.bindByName("expiry", cookie.expiry);
|
||||
this.stmtInsert.bindByName("lastAccessed", cookie.lastAccessed);
|
||||
this.stmtInsert.bindByName("creationTime", cookie.creationTime);
|
||||
this.stmtInsert.bindByName("isSecure", cookie.isSecure);
|
||||
this.stmtInsert.bindByName("isHttpOnly", cookie.isHttpOnly);
|
||||
this.stmtInsert.bindByName("inBrowserElement", cookie.inBrowserElement);
|
||||
this.stmtInsert.bindByName(
|
||||
"originAttributes",
|
||||
ChromeUtils.originAttributesToSuffix(cookie.originAttributes)
|
||||
);
|
||||
this.stmtInsert.bindByName("sameSite", cookie.sameSite);
|
||||
this.stmtInsert.bindByName("rawSameSite", cookie.rawSameSite);
|
||||
break;
|
||||
|
||||
default:
|
||||
do_throw("unrecognized schemaVersion!");
|
||||
}
|
||||
|
@ -700,17 +504,6 @@ CookieDatabaseConnection.prototype = {
|
|||
this.stmtDelete.bindByName("path", cookie.path);
|
||||
break;
|
||||
|
||||
case 10:
|
||||
case 11:
|
||||
this.stmtDelete.bindByName("name", cookie.name);
|
||||
this.stmtDelete.bindByName("host", cookie.host);
|
||||
this.stmtDelete.bindByName("path", cookie.path);
|
||||
this.stmtDelete.bindByName(
|
||||
"originAttributes",
|
||||
ChromeUtils.originAttributesToSuffix(cookie.originAttributes)
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
do_throw("unrecognized schemaVersion!");
|
||||
}
|
||||
|
@ -737,28 +530,6 @@ CookieDatabaseConnection.prototype = {
|
|||
this.stmtDelete.bindByName("name", cookie.name);
|
||||
this.stmtDelete.bindByName("host", cookie.host);
|
||||
this.stmtDelete.bindByName("path", cookie.path);
|
||||
this.stmtUpdate.bindByName("name", cookie.name);
|
||||
this.stmtUpdate.bindByName("host", cookie.host);
|
||||
this.stmtUpdate.bindByName("path", cookie.path);
|
||||
this.stmtUpdate.bindByName("lastAccessed", cookie.lastAccessed);
|
||||
break;
|
||||
|
||||
case 10:
|
||||
case 11:
|
||||
this.stmtDelete.bindByName("name", cookie.name);
|
||||
this.stmtDelete.bindByName("host", cookie.host);
|
||||
this.stmtDelete.bindByName("path", cookie.path);
|
||||
this.stmtDelete.bindByName(
|
||||
"originAttributes",
|
||||
ChromeUtils.originAttributesToSuffix(cookie.originAttributes)
|
||||
);
|
||||
this.stmtUpdate.bindByName("name", cookie.name);
|
||||
this.stmtUpdate.bindByName("host", cookie.host);
|
||||
this.stmtUpdate.bindByName("path", cookie.path);
|
||||
this.stmtUpdate.bindByName(
|
||||
"originAttributes",
|
||||
ChromeUtils.originAttributesToSuffix(cookie.originAttributes)
|
||||
);
|
||||
this.stmtUpdate.bindByName("lastAccessed", cookie.lastAccessed);
|
||||
break;
|
||||
|
||||
|
|
|
@ -135,14 +135,29 @@ function* run_test_1(generator) {
|
|||
yield;
|
||||
|
||||
// Open a database connection now, before we load the profile and begin
|
||||
// asynchronous write operations.
|
||||
let db = new CookieDatabaseConnection(do_get_cookie_file(profile), 11);
|
||||
Assert.equal(do_count_cookies_in_db(db.db), 1);
|
||||
// asynchronous write operations. In order to tell when the async delete
|
||||
// statement has completed, we do something tricky: open a schema 2 connection
|
||||
// and add a cookie with null baseDomain. We can then wait until we see it
|
||||
// deleted in the new database.
|
||||
let db2 = new CookieDatabaseConnection(do_get_cookie_file(profile), 2);
|
||||
db2.db.executeSimpleSQL("INSERT INTO moz_cookies (baseDomain) VALUES (NULL)");
|
||||
db2.close();
|
||||
let db = new CookieDatabaseConnection(do_get_cookie_file(profile), 4);
|
||||
Assert.equal(do_count_cookies_in_db(db.db), 2);
|
||||
|
||||
// Load the profile, and wait for async read completion...
|
||||
do_load_profile(sub_generator);
|
||||
yield;
|
||||
|
||||
// ... and the DELETE statement to finish.
|
||||
while (do_count_cookies_in_db(db.db) == 2) {
|
||||
executeSoon(function() {
|
||||
do_run_generator(sub_generator);
|
||||
});
|
||||
yield;
|
||||
}
|
||||
Assert.equal(do_count_cookies_in_db(db.db), 1);
|
||||
|
||||
// Insert a row.
|
||||
db.insertCookie(cookie);
|
||||
db.close();
|
||||
|
@ -255,18 +270,23 @@ function* run_test_2(generator) {
|
|||
// succeeded.
|
||||
Assert.ok(!do_get_backup_file(profile).exists());
|
||||
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("0.com"), 1);
|
||||
Assert.equal(do_count_cookies(), 3000);
|
||||
// Recreate a new database since it was corrupted
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("0.com"), 0);
|
||||
Assert.equal(do_count_cookies(), 0);
|
||||
|
||||
// Close the profile.
|
||||
do_close_profile(sub_generator);
|
||||
yield;
|
||||
|
||||
Assert.ok(!do_get_backup_file(profile).exists());
|
||||
// Check that the original database was renamed.
|
||||
Assert.ok(do_get_backup_file(profile).exists());
|
||||
Assert.equal(do_get_backup_file(profile).fileSize, size);
|
||||
let db = Services.storage.openDatabase(do_get_cookie_file(profile));
|
||||
db.close();
|
||||
|
||||
do_load_profile();
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("0.com"), 1);
|
||||
Assert.equal(do_count_cookies(), 3000);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("0.com"), 0);
|
||||
Assert.equal(do_count_cookies(), 0);
|
||||
|
||||
// Close the profile.
|
||||
do_close_profile(sub_generator);
|
||||
|
@ -274,6 +294,7 @@ function* run_test_2(generator) {
|
|||
|
||||
// Clean up.
|
||||
do_get_cookie_file(profile).remove(false);
|
||||
do_get_backup_file(profile).remove(false);
|
||||
Assert.ok(!do_get_cookie_file(profile).exists());
|
||||
Assert.ok(!do_get_backup_file(profile).exists());
|
||||
do_run_generator(generator);
|
||||
|
@ -322,22 +343,46 @@ function* run_test_3(generator) {
|
|||
Assert.ok(!do_get_backup_file(profile).exists());
|
||||
|
||||
// Recreate a new database since it was corrupted
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("hither.com"), 10);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("haithur.com"), 2990);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("hither.com"), 0);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("haithur.com"), 0);
|
||||
|
||||
// Close the profile.
|
||||
do_close_profile(sub_generator);
|
||||
yield;
|
||||
let db = Services.storage.openDatabase(do_get_cookie_file(profile));
|
||||
Assert.equal(do_count_cookies_in_db(db, "hither.com"), 10);
|
||||
Assert.equal(do_count_cookies_in_db(db), 3000);
|
||||
Assert.equal(do_count_cookies_in_db(db, "hither.com"), 0);
|
||||
Assert.equal(do_count_cookies_in_db(db), 0);
|
||||
db.close();
|
||||
|
||||
// Check that the original database was removed.
|
||||
// Check that the original database was renamed.
|
||||
Assert.ok(do_get_backup_file(profile).exists());
|
||||
Assert.equal(do_get_backup_file(profile).fileSize, size);
|
||||
|
||||
// Rename it back, and try loading the entire database synchronously.
|
||||
do_get_backup_file(profile).moveTo(null, "cookies.sqlite");
|
||||
do_load_profile();
|
||||
|
||||
// At this point, the database connection should be open. Ensure that it
|
||||
// succeeded.
|
||||
Assert.ok(!do_get_backup_file(profile).exists());
|
||||
|
||||
// Synchronously read in everything.
|
||||
Assert.equal(do_count_cookies(), 0);
|
||||
|
||||
// Close the profile.
|
||||
do_close_profile(sub_generator);
|
||||
yield;
|
||||
db = Services.storage.openDatabase(do_get_cookie_file(profile));
|
||||
Assert.equal(do_count_cookies_in_db(db), 0);
|
||||
db.close();
|
||||
|
||||
// Check that the original database was renamed.
|
||||
Assert.ok(do_get_backup_file(profile).exists());
|
||||
Assert.equal(do_get_backup_file(profile).fileSize, size);
|
||||
|
||||
// Clean up.
|
||||
do_get_cookie_file(profile).remove(false);
|
||||
do_get_backup_file(profile).remove(false);
|
||||
Assert.ok(!do_get_cookie_file(profile).exists());
|
||||
Assert.ok(!do_get_backup_file(profile).exists());
|
||||
do_run_generator(generator);
|
||||
|
@ -368,7 +413,7 @@ function* run_test_4(generator) {
|
|||
Assert.ok(!do_get_backup_file(profile).exists());
|
||||
|
||||
// Recreate a new database since it was corrupted
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("0.com"), 1);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("0.com"), 0);
|
||||
|
||||
// Queue up an INSERT for the same base domain. This should also go into
|
||||
// memory and be written out during database rebuild.
|
||||
|
@ -376,20 +421,21 @@ function* run_test_4(generator) {
|
|||
Services.cookies.setCookieString(uri, null, "oh2=hai; max-age=1000", null);
|
||||
|
||||
// At this point, the cookies should still be in memory.
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("0.com"), 2);
|
||||
Assert.equal(do_count_cookies(), 3001);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("0.com"), 1);
|
||||
Assert.equal(do_count_cookies(), 1);
|
||||
|
||||
// Close the profile.
|
||||
do_close_profile(sub_generator);
|
||||
yield;
|
||||
|
||||
// Check that the backup file does not exist.
|
||||
Assert.ok(!do_get_backup_file(profile).exists());
|
||||
// Check that the original database was renamed.
|
||||
Assert.ok(do_get_backup_file(profile).exists());
|
||||
Assert.equal(do_get_backup_file(profile).fileSize, size);
|
||||
|
||||
// Load the profile, and check that it contains the new cookie.
|
||||
do_load_profile();
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("0.com"), 2);
|
||||
Assert.equal(do_count_cookies(), 3001);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("0.com"), 1);
|
||||
Assert.equal(do_count_cookies(), 1);
|
||||
|
||||
// Close the profile.
|
||||
do_close_profile(sub_generator);
|
||||
|
@ -397,6 +443,7 @@ function* run_test_4(generator) {
|
|||
|
||||
// Clean up.
|
||||
do_get_cookie_file(profile).remove(false);
|
||||
do_get_backup_file(profile).remove(false);
|
||||
Assert.ok(!do_get_cookie_file(profile).exists());
|
||||
Assert.ok(!do_get_backup_file(profile).exists());
|
||||
do_run_generator(generator);
|
||||
|
@ -434,26 +481,28 @@ function* run_test_5(generator) {
|
|||
Assert.ok(!do_get_backup_file(profile).exists());
|
||||
|
||||
// Recreate a new database since it was corrupted
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("bar.com"), 1);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("0.com"), 1);
|
||||
Assert.equal(do_count_cookies(), 3001);
|
||||
Assert.ok(!do_get_backup_file(profile).exists());
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("bar.com"), 0);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("0.com"), 0);
|
||||
Assert.equal(do_count_cookies(), 0);
|
||||
Assert.ok(do_get_backup_file(profile).exists());
|
||||
Assert.equal(do_get_backup_file(profile).fileSize, size);
|
||||
Assert.ok(!do_get_rebuild_backup_file(profile).exists());
|
||||
|
||||
// Open a database connection, and write a row that will trigger a constraint
|
||||
// violation.
|
||||
let db = new CookieDatabaseConnection(do_get_cookie_file(profile), 11);
|
||||
try {
|
||||
db.insertCookie(cookie);
|
||||
} catch (e) {}
|
||||
let db = new CookieDatabaseConnection(do_get_cookie_file(profile), 4);
|
||||
db.insertCookie(cookie);
|
||||
Assert.equal(do_count_cookies_in_db(db.db, "bar.com"), 1);
|
||||
Assert.equal(do_count_cookies_in_db(db.db), 3001);
|
||||
Assert.equal(do_count_cookies_in_db(db.db), 1);
|
||||
db.close();
|
||||
|
||||
Assert.ok(!do_get_backup_file(profile).exists());
|
||||
// Check that the original backup and the database itself are gone.
|
||||
Assert.ok(do_get_backup_file(profile).exists());
|
||||
Assert.equal(do_get_backup_file(profile).fileSize, size);
|
||||
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("bar.com"), 1);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("0.com"), 1);
|
||||
Assert.equal(do_count_cookies(), 3001);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("bar.com"), 0);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("0.com"), 0);
|
||||
Assert.equal(do_count_cookies(), 0);
|
||||
|
||||
// Close the profile. We do not need to wait for completion, because the
|
||||
// database has already been closed. Ensure the cookie file is unlocked.
|
||||
|
@ -462,6 +511,7 @@ function* run_test_5(generator) {
|
|||
|
||||
// Clean up.
|
||||
do_get_cookie_file(profile).remove(false);
|
||||
do_get_backup_file(profile).remove(false);
|
||||
Assert.ok(!do_get_cookie_file(profile).exists());
|
||||
Assert.ok(!do_get_backup_file(profile).exists());
|
||||
do_run_generator(generator);
|
||||
|
|
|
@ -34,7 +34,7 @@ function* do_run_test() {
|
|||
// completed. We may not be able to open one later once asynchronous writing
|
||||
// begins.
|
||||
Assert.ok(do_get_cookie_file(profile).exists());
|
||||
let db = new CookieDatabaseConnection(do_get_cookie_file(profile), 11);
|
||||
let db = new CookieDatabaseConnection(do_get_cookie_file(profile), 4);
|
||||
|
||||
for (let i = 0; i < CMAX; ++i) {
|
||||
let uri = NetUtil.newURI("http://" + i + ".com/");
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
// c) Schema 3: the 'creationTime' column already exists; or the
|
||||
// 'moz_uniqueid' index already exists.
|
||||
|
||||
var COOKIE_DATABASE_SCHEMA_CURRENT = 11;
|
||||
var COOKIE_DATABASE_SCHEMA_CURRENT = 10;
|
||||
|
||||
var test_generator = do_run_test();
|
||||
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
function getDBVersion(dbfile) {
|
||||
let dbConnection = Services.storage.openDatabase(dbfile);
|
||||
let version = dbConnection.schemaVersion;
|
||||
dbConnection.close();
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
function indexExists(dbfile, indexname) {
|
||||
let dbConnection = Services.storage.openDatabase(dbfile);
|
||||
let result = dbConnection.indexExists(indexname);
|
||||
dbConnection.close();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
add_task(async function() {
|
||||
try {
|
||||
let testfile = do_get_file("data/cookies_v10.sqlite");
|
||||
let profileDir = do_get_profile();
|
||||
|
||||
// Cleanup from any previous tests or failures.
|
||||
let destFile = profileDir.clone();
|
||||
destFile.append("cookies.sqlite");
|
||||
if (destFile.exists()) {
|
||||
destFile.remove(false);
|
||||
}
|
||||
|
||||
testfile.copyTo(profileDir, "cookies.sqlite");
|
||||
Assert.equal(10, getDBVersion(destFile));
|
||||
|
||||
Assert.ok(destFile.exists());
|
||||
|
||||
// Check that the index exists
|
||||
Assert.ok(indexExists(destFile, "moz_basedomain"));
|
||||
|
||||
// Do something that will cause the cookie service access and upgrade the
|
||||
// database.
|
||||
let cookies = Services.cookies.cookies;
|
||||
|
||||
// Pretend that we're about to shut down, to tell the cookie manager
|
||||
// to clean up its connection with its database.
|
||||
Services.obs.notifyObservers(null, "profile-before-change");
|
||||
|
||||
// check for upgraded schema.
|
||||
Assert.equal(11, getDBVersion(destFile));
|
||||
|
||||
// Check that the index was deleted
|
||||
Assert.ok(!indexExists(destFile, "moz_basedomain"));
|
||||
} catch (e) {
|
||||
throw new Error(`FAILED: ${e}`);
|
||||
}
|
||||
});
|
|
@ -1,180 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
// Test cookie database migration from version 10 (prerelease Gecko 2.0) to the
|
||||
// current version, presently 11.
|
||||
|
||||
var test_generator = do_run_test();
|
||||
|
||||
function run_test() {
|
||||
do_test_pending();
|
||||
test_generator.next();
|
||||
}
|
||||
|
||||
function finish_test() {
|
||||
executeSoon(function() {
|
||||
test_generator.return();
|
||||
do_test_finished();
|
||||
});
|
||||
}
|
||||
|
||||
function* do_run_test() {
|
||||
// Set up a profile.
|
||||
let profile = do_get_profile();
|
||||
|
||||
// Start the cookieservice, to force creation of a database.
|
||||
// Get the sessionCookies to join the initialization in cookie thread
|
||||
Services.cookiemgr.sessionCookies;
|
||||
|
||||
// Close the profile.
|
||||
do_close_profile(test_generator);
|
||||
yield;
|
||||
|
||||
// Remove the cookie file in order to create another database file.
|
||||
do_get_cookie_file(profile).remove(false);
|
||||
|
||||
// Create a schema 10 database.
|
||||
let schema10db = new CookieDatabaseConnection(
|
||||
do_get_cookie_file(profile),
|
||||
10
|
||||
);
|
||||
|
||||
let now = Date.now() * 1000;
|
||||
let futureExpiry = Math.round(now / 1e6 + 1000);
|
||||
let pastExpiry = Math.round(now / 1e6 - 1000);
|
||||
|
||||
// Populate it, with:
|
||||
// 1) Unexpired, unique cookies.
|
||||
for (let i = 0; i < 20; ++i) {
|
||||
let cookie = new Cookie(
|
||||
"oh" + i,
|
||||
"hai",
|
||||
"foo.com",
|
||||
"/",
|
||||
futureExpiry,
|
||||
now,
|
||||
now + i,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
schema10db.insertCookie(cookie);
|
||||
}
|
||||
|
||||
// 2) Expired, unique cookies.
|
||||
for (let i = 20; i < 40; ++i) {
|
||||
let cookie = new Cookie(
|
||||
"oh" + i,
|
||||
"hai",
|
||||
"bar.com",
|
||||
"/",
|
||||
pastExpiry,
|
||||
now,
|
||||
now + i,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
schema10db.insertCookie(cookie);
|
||||
}
|
||||
|
||||
// 3) Many copies of the same cookie, some of which have expired and
|
||||
// some of which have not.
|
||||
for (let i = 40; i < 45; ++i) {
|
||||
let cookie = new Cookie(
|
||||
"oh",
|
||||
"hai",
|
||||
"baz.com",
|
||||
"/",
|
||||
futureExpiry + i,
|
||||
now,
|
||||
now + i,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
try {
|
||||
schema10db.insertCookie(cookie);
|
||||
} catch (e) {}
|
||||
}
|
||||
for (let i = 45; i < 50; ++i) {
|
||||
let cookie = new Cookie(
|
||||
"oh",
|
||||
"hai",
|
||||
"baz.com",
|
||||
"/",
|
||||
pastExpiry - i,
|
||||
now,
|
||||
now + i,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
try {
|
||||
schema10db.insertCookie(cookie);
|
||||
} catch (e) {}
|
||||
}
|
||||
for (let i = 50; i < 55; ++i) {
|
||||
let cookie = new Cookie(
|
||||
"oh",
|
||||
"hai",
|
||||
"baz.com",
|
||||
"/",
|
||||
futureExpiry - i,
|
||||
now,
|
||||
now + i,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
try {
|
||||
schema10db.insertCookie(cookie);
|
||||
} catch (e) {}
|
||||
}
|
||||
for (let i = 55; i < 60; ++i) {
|
||||
let cookie = new Cookie(
|
||||
"oh",
|
||||
"hai",
|
||||
"baz.com",
|
||||
"/",
|
||||
pastExpiry + i,
|
||||
now,
|
||||
now + i,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
try {
|
||||
schema10db.insertCookie(cookie);
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
// Close it.
|
||||
schema10db.close();
|
||||
schema10db = null;
|
||||
|
||||
// Load the database, forcing migration to the current schema version. Then
|
||||
// test the expected set of cookies:
|
||||
do_load_profile();
|
||||
|
||||
// 1) All unexpired, unique cookies exist.
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("foo.com"), 20);
|
||||
|
||||
// 2) All expired, unique cookies exist.
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("bar.com"), 20);
|
||||
|
||||
// 3) Only one cookie remains, and it's the one with the highest expiration
|
||||
// time.
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("baz.com"), 1);
|
||||
let cookies = Services.cookiemgr.getCookiesFromHost("baz.com", {});
|
||||
let cookie = cookies[0];
|
||||
Assert.equal(cookie.expiry, futureExpiry + 40);
|
||||
|
||||
finish_test();
|
||||
}
|
|
@ -243,14 +243,21 @@ function* do_run_test() {
|
|||
yield;
|
||||
|
||||
// Test the expected set of cookies.
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("foo.com"), 40);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("foo.com"), 20);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("bar.com"), 20);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("baz.com"), 1);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("cat.com"), 20);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("baz.com"), 0);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("cat.com"), 0);
|
||||
|
||||
do_close_profile(test_generator);
|
||||
yield;
|
||||
|
||||
// Open the database and prove that they were deleted.
|
||||
schema2db = new CookieDatabaseConnection(do_get_cookie_file(profile), 2);
|
||||
Assert.equal(do_count_cookies_in_db(schema2db.db), 40);
|
||||
Assert.equal(do_count_cookies_in_db(schema2db.db, "foo.com"), 20);
|
||||
Assert.equal(do_count_cookies_in_db(schema2db.db, "bar.com"), 20);
|
||||
schema2db.close();
|
||||
|
||||
// Copy the database back.
|
||||
file.remove(false);
|
||||
copy.copyTo(null, file.leafName);
|
||||
|
@ -259,18 +266,18 @@ function* do_run_test() {
|
|||
do_load_profile();
|
||||
|
||||
// Test the expected set of cookies.
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("foo.com"), 40);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("foo.com"), 20);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("bar.com"), 20);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("baz.com"), 1);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("cat.com"), 20);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("baz.com"), 0);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("cat.com"), 0);
|
||||
|
||||
do_close_profile(test_generator);
|
||||
yield;
|
||||
|
||||
// Open the database and prove that they were deleted.
|
||||
schema2db = new CookieDatabaseConnection(do_get_cookie_file(profile), 2);
|
||||
Assert.equal(do_count_cookies_in_db(schema2db.db), 81);
|
||||
Assert.equal(do_count_cookies_in_db(schema2db.db, "foo.com"), 40);
|
||||
Assert.equal(do_count_cookies_in_db(schema2db.db), 40);
|
||||
Assert.equal(do_count_cookies_in_db(schema2db.db, "foo.com"), 20);
|
||||
Assert.equal(do_count_cookies_in_db(schema2db.db, "bar.com"), 20);
|
||||
schema2db.close();
|
||||
|
||||
|
@ -280,21 +287,21 @@ function* do_run_test() {
|
|||
|
||||
// Load the database synchronously, in its entirety.
|
||||
do_load_profile();
|
||||
Assert.equal(do_count_cookies(), 81);
|
||||
Assert.equal(do_count_cookies(), 40);
|
||||
|
||||
// Test the expected set of cookies.
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("foo.com"), 40);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("foo.com"), 20);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("bar.com"), 20);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("baz.com"), 1);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("cat.com"), 20);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("baz.com"), 0);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("cat.com"), 0);
|
||||
|
||||
do_close_profile(test_generator);
|
||||
yield;
|
||||
|
||||
// Open the database and prove that they were deleted.
|
||||
schema2db = new CookieDatabaseConnection(do_get_cookie_file(profile), 2);
|
||||
Assert.equal(do_count_cookies_in_db(schema2db.db), 81);
|
||||
Assert.equal(do_count_cookies_in_db(schema2db.db, "foo.com"), 40);
|
||||
Assert.equal(do_count_cookies_in_db(schema2db.db), 40);
|
||||
Assert.equal(do_count_cookies_in_db(schema2db.db, "foo.com"), 20);
|
||||
Assert.equal(do_count_cookies_in_db(schema2db.db, "bar.com"), 20);
|
||||
schema2db.close();
|
||||
|
||||
|
|
|
@ -165,5 +165,43 @@ function* do_run_test() {
|
|||
let cookie = cookies[0];
|
||||
Assert.equal(cookie.expiry, futureExpiry + 44);
|
||||
|
||||
do_close_profile(test_generator);
|
||||
yield;
|
||||
|
||||
// Open the database so we can execute some more schema 3 statements on it.
|
||||
schema3db = new CookieDatabaseConnection(do_get_cookie_file(profile), 3);
|
||||
|
||||
// Populate it with more cookies.
|
||||
for (let i = 60; i < 80; ++i) {
|
||||
let cookie = new Cookie(
|
||||
"oh" + i,
|
||||
"hai",
|
||||
"cat.com",
|
||||
"/",
|
||||
futureExpiry,
|
||||
now,
|
||||
now + i,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
schema3db.insertCookie(cookie);
|
||||
}
|
||||
|
||||
// Close it.
|
||||
schema3db.close();
|
||||
schema3db = null;
|
||||
|
||||
// Load the database. The cookies added immediately prior will have a NULL
|
||||
// creationTime column.
|
||||
do_load_profile();
|
||||
|
||||
// Test the expected set of cookies.
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("cat.com"), 20);
|
||||
cookies = Services.cookiemgr.getCookiesFromHost("cat.com", {});
|
||||
cookie = cookies[0];
|
||||
Assert.equal(cookie.creationTime, 0);
|
||||
|
||||
finish_test();
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ support-files =
|
|||
http2-ca.pem
|
||||
client_cert_chooser.js
|
||||
client_cert_chooser.manifest
|
||||
data/cookies_v10.sqlite
|
||||
data/image.png
|
||||
data/system_root.lnk
|
||||
data/test_psl.txt
|
||||
|
@ -197,7 +196,6 @@ skip-if = true # Bug 863738
|
|||
[test_cookies_thirdparty.js]
|
||||
[test_cookies_thirdparty_nonsecure_session.js]
|
||||
[test_cookies_thirdparty_session.js]
|
||||
[test_cookies_upgrade_10-11.js]
|
||||
[test_dns_cancel.js]
|
||||
[test_data_protocol.js]
|
||||
[test_dns_service.js]
|
||||
|
@ -299,7 +297,6 @@ skip-if = os == "win"
|
|||
[test_safeoutputstream.js]
|
||||
[test_schema_2_migration.js]
|
||||
[test_schema_3_migration.js]
|
||||
[test_schema_10_migration.js]
|
||||
[test_simple.js]
|
||||
[test_sockettransportsvc_available.js]
|
||||
[test_socks.js]
|
||||
|
|
Загрузка…
Ссылка в новой задаче