-
Notifications
You must be signed in to change notification settings - Fork 54
/
test_incremental_vacuum.js
37 lines (31 loc) · 1.42 KB
/
test_incremental_vacuum.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests incremental vacuum of the favicons database.
const {PlacesDBUtils} = ChromeUtils.import("resource://gre/modules/PlacesDBUtils.jsm");
add_task(async function() {
let icon = {
file: do_get_file("noise.png"),
mimetype: "image/png",
};
let url = "http://foo.bar/";
await PlacesTestUtils.addVisits(url);
for (let i = 0; i < 10; ++i) {
let iconUri = NetUtil.newURI("http://mozilla.org/" + i);
let data = readFileData(icon.file);
PlacesUtils.favicons.replaceFaviconData(iconUri, data, icon.mimetype);
await setFaviconForPage(url, iconUri);
}
let promise = TestUtils.topicObserved("places-favicons-expired");
PlacesUtils.favicons.expireAllFavicons();
await promise;
let db = await PlacesUtils.promiseDBConnection();
let state = (await db.execute("PRAGMA favicons.auto_vacuum"))[0].getResultByIndex(0);
Assert.equal(state, 2, "auto_vacuum should be incremental");
let count = (await db.execute("PRAGMA favicons.freelist_count"))[0].getResultByIndex(0);
info(`Found ${count} freelist pages`);
let log = await PlacesDBUtils.incrementalVacuum();
info(log);
let newCount = (await db.execute("PRAGMA favicons.freelist_count"))[0].getResultByIndex(0);
info(`Found ${newCount} freelist pages`);
Assert.ok(newCount < count, "The number of freelist pages should have reduced");
});