blob: 2c1a5ad3f92520493bab5576b2ccc6aeb41c6ea1 (
plain)
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
38
39
40
41
42
43
44
45
46
47
|
/* 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.importESModule(
"resource://gre/modules/PlacesDBUtils.sys.mjs"
);
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 = "http://mozilla.org/" + i;
let dataURL = await readFileDataAsDataURL(icon.file, icon.mimetype);
await PlacesTestUtils.setFaviconForPage(url, iconUri, dataURL);
}
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"
);
});
|