blob: 43b8fb1f643559b75c5f01d1244e3b9b05a478b0 (
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
48
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
add_task(function* setup() {
yield setupPlacesDatabase("places_v11.sqlite");
});
add_task(function* database_is_valid() {
Assert.equal(PlacesUtils.history.databaseStatus,
PlacesUtils.history.DATABASE_STATUS_UPGRADED);
let db = yield PlacesUtils.promiseDBConnection();
Assert.equal((yield db.getSchemaVersion()), CURRENT_SCHEMA_VERSION);
});
add_task(function* test_moz_hosts() {
let db = yield PlacesUtils.promiseDBConnection();
// This will throw if the column does not exist.
yield db.execute("SELECT host, frecency, typed, prefix FROM moz_hosts");
// moz_hosts is populated asynchronously, so we need to wait.
yield PlacesTestUtils.promiseAsyncUpdates();
// check the number of entries in moz_hosts equals the number of
// unique rev_host in moz_places
let rows = yield db.execute(
`SELECT (SELECT COUNT(host) FROM moz_hosts),
(SELECT COUNT(DISTINCT rev_host)
FROM moz_places
WHERE LENGTH(rev_host) > 1)
`);
Assert.equal(rows.length, 1);
let mozHostsCount = rows[0].getResultByIndex(0);
let mozPlacesCount = rows[0].getResultByIndex(1);
Assert.ok(mozPlacesCount > 0, "There is some url in the database");
Assert.equal(mozPlacesCount, mozHostsCount, "moz_hosts has the expected number of entries");
});
add_task(function* test_journal() {
let db = yield PlacesUtils.promiseDBConnection();
let rows = yield db.execute("PRAGMA journal_mode");
Assert.equal(rows.length, 1);
// WAL journal mode should be set on this database.
Assert.equal(rows[0].getResultByIndex(0), "wal");
});
|