Bug 608422 - cookies.sqlite-wal takes too much space for Fennec. Add test. r=mfinkle, a=beta2+

This commit is contained in:
Dan Witte 2010-11-02 15:56:20 -07:00
parent e66e086b97
commit 4df35d9668
2 changed files with 28 additions and 5 deletions

View File

@ -477,19 +477,26 @@ CookieDatabaseConnection.prototype =
}
}
// Count the cookies from 'host' in a database.
// Count the cookies from 'host' in a database. If 'host' is null, count all
// cookies.
function do_count_cookies_in_db(profile, host)
{
let file = profile.clone();
file.append("cookies.sqlite");
let connection = Services.storage.openDatabase(file);
let select = connection.createStatement(
"SELECT COUNT(1) FROM moz_cookies WHERE host = :host");
select.bindByName("host", host);
let select = null;
if (host) {
select = connection.createStatement(
"SELECT COUNT(1) FROM moz_cookies WHERE host = :host");
select.bindByName("host", host);
} else {
select = connection.createStatement(
"SELECT COUNT(1) FROM moz_cookies");
}
select.executeStep();
let result = select.getInt32(0);
select.reset();
select.finalize();
connection.close();

View File

@ -29,6 +29,22 @@ function do_run_test() {
do_check_eq(do_count_cookies(), 3000);
// Wait until all 3000 cookies have been written out to the database.
let db = new CookieDatabaseConnection(profile, 4);
while (do_count_cookies_in_db(profile) < 3000) {
do_execute_soon(function() {
do_run_generator(test_generator);
});
yield;
}
// Check the WAL file size. We set it to 16 pages of 32k, which means it
// should be around 500k.
let file = db.db.databaseFile;
do_check_true(file.exists());
do_check_true(file.fileSize < 1e6);
db.close();
// fake a profile change
do_close_profile(test_generator);
yield;