Skip to content

Commit

Permalink
Bug 608422 - cookies.sqlite-wal takes too much space for Fennec. Add …
Browse files Browse the repository at this point in the history
…test. r=mfinkle, a=beta2+
  • Loading branch information
Dan Witte committed Nov 2, 2010
1 parent e66e086 commit 4df35d9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
17 changes: 12 additions & 5 deletions extensions/cookie/test/unit/head_cookies.js
Expand Up @@ -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();
Expand Down
16 changes: 16 additions & 0 deletions extensions/cookie/test/unit/test_cookies_read.js
Expand Up @@ -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;
Expand Down

0 comments on commit 4df35d9

Please sign in to comment.